<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6288032787085179957</id><updated>2024-10-28T01:58:37.664-07:00</updated><category term="Cpanel"/><category term="System administration commands"/><category term="Linux Hardening"/><category term="Recover deleted files in linux"/><category term="Virtuzzo"/><category term="sed command with examples"/><category term="-bash: /usr/local/tomcat/bin/startup.sh: Permission denied"/><category term="/usr/bin/ld: cannot find"/><category term="389 Directory server installation"/><category term="Advanced examples with awk command."/><category term="Apache"/><category term="Awstats"/><category term="Backup data using rsnapshot"/><category term="Backup database in mysql. backup tables in mysql"/><category term="Basic mysql commands"/><category term="Block ssh access for root in linux"/><category term="Block telnet"/><category term="Check HBA card status in linux"/><category term="Check httpd status in command line"/><category term="Check inode usage of files in linux. Inode usage details in linux"/><category term="Check lvm command usage in lvm logs. Maintain  lvm logs in Linux"/><category term="Color settings in linux server"/><category term="Commands to check the hard ware details in linux"/><category term="Configure Wild Card SSL in Cpanel /WHM"/><category term="Cpanel back end files. Cpanel/WHM scripts"/><category term="Cpanel scripts"/><category term="Crash dump analysis"/><category term="Create temporary swap and permanent swap space in linux"/><category term="DDOS attack prevention in linux."/><category term="Disable  shell built in commands in linux"/><category term="Disable login for users not in wheel group linux"/><category term="Disable telnet in linux servers"/><category term="Display or change ethernet card settings in linux"/><category term="Enable Awstats in Cpanel"/><category term="Enable home directory for users in linux to publish their data.. Apache configuration to enable user home directory in linux"/><category term="Enable spell check in cpanel"/><category term="Enable spell check in round cube"/><category term="Environment variable in linux"/><category term="Essential commands in linux"/><category term="Exim commands"/><category term="Exim mail server command and details."/><category term="Exim mail server commands"/><category term="Global and local variable in linux"/><category term="Hard disk details in linux"/><category term="Hardware changes with out reboot in linux"/><category term="How to restore deleted lvm partition in linux. Steps to restore removed lvm partition."/><category term="Install CSF firewall in linux. CSF firewall installation steps in linux"/><category term="Install apache from  source in linux"/><category term="Install berkely db from source"/><category term="Install boost from source in linux"/><category term="Install fantastico in Linux"/><category term="Install gcc from scratch in linux"/><category term="Install java in linux"/><category term="Install mod_wsgi from source"/><category term="Install mod_wsgi in linux"/><category term="Install php from source in linux"/><category term="Install python from source in linux"/><category term="Install python in linux"/><category term="Install subversion in linux"/><category term="Install trendly flash and softaculous in linux cpanel server."/><category term="Know your current shell in linux"/><category term="Kudzu command"/><category term="LFTP installation"/><category term="Limit emails per hour in Linux server."/><category term="Linux exim commands"/><category term="Log rotate in linux"/><category term="Login message in linux"/><category term="Mod_evasive installation in linux"/><category term="Mysql commands used in system administration"/><category term="Mysql hardening in Linux."/><category term="NTP synchronization failed"/><category term="NTP synchronization in linux"/><category term="Neither an F77 compiler nor f2c found error"/><category term="PROMPT command"/><category term="Password protection in linux"/><category term="Php shield installation in linux"/><category term="Php shiled module for video encrypt and decrypt"/><category term="Postgresql  installation in linux"/><category term="Process and it details in linux"/><category term="Process priority settings in linux"/><category term="Protect a directory with password in linux"/><category term="Rebuild corrupted rpm database"/><category term="Rebuild rpm"/><category term="Reset default permissions in linux"/><category term="Rotate apache logs with out log rotate in linux"/><category term="SPRI installation in linux"/><category term="Send email alert for recent login deails in shell"/><category term="Set background colors in linux server"/><category term="Set email relay limit"/><category term="Shell script to create multiple users at a time."/><category term="Shell script to sort numbers in ascending and descending order."/><category term="Simple script to create multiple files at time in linux"/><category term="Smartctl command in linux"/><category term="Start tomcat at the boot time"/><category term="Step by step instructions to install cpanel. Install cpanel in Linux"/><category term="Steps to reset mysql root password."/><category term="Steps to uninstall zimbra in linux"/><category term="Swapiness"/><category term="Uninstall zimbra collaboration suite"/><category term="Virtuzzo commands in linux."/><category term="Virutzzo command line"/><category term="WHM shout cast installation"/><category term="Welcome message in linux server"/><category term="Wild card SSL"/><category term="Wild card dns in linux"/><category term="add blank lines in a file using sed command."/><category term="all commands in linux."/><category term="append files in linux disable"/><category term="awk command usage"/><category term="awk command with examples"/><category term="backup all the databases in mysql."/><category term="backup data using lvm snapshot"/><category term="backup mysql database in linux"/><category term="backup using lvm snapshot in linux"/><category term="bash: locate: command not found"/><category term="change runlevel with out reboot. runlevel changes with out reboot"/><category term="check  hardware errors using smartctl command in linux"/><category term="check disk model number serial number in linux using hdparm"/><category term="check environment in linux"/><category term="check hardrive is active or idle using hdparm command"/><category term="check open and closed ports in linux"/><category term="command to check all the country times in linux"/><category term="commands in linux"/><category term="configure client and server nfs in linux"/><category term="configure subversion in linux"/><category term="configure swap and physical memory usage in linux"/><category term="configure: error: --with-x=yes (default) and X11 headers/libs are not available"/><category term="cpanel exim"/><category term="crash installation in linux"/><category term="cron format in linux"/><category term="cron syntax in linux"/><category term="cron syntax with examples"/><category term="cron with examples"/><category term="date command"/><category term="date command with examples."/><category term="debug command to recover deleted files"/><category term="display your message with prompt command in linux"/><category term="echo"/><category term="echo command in  linux shell scripting"/><category term="enable webalizer stats in linux. Update webalizer for single domain in cpanel"/><category term="find lvm logs in linux"/><category term="full duplex"/><category term="half duplex"/><category term="hdparm command to check hardware parameters in linux"/><category term="how to avoid  swap usage when physical ram is present"/><category term="how to check the process states and its information in linux"/><category term="install R from source in linux"/><category term="install gcc from source in linux"/><category term="ipbonding in linux"/><category term="java"/><category term="kdump installation"/><category term="ldap installation in linux"/><category term="locate: can not open `/var/lib/mlocate/mlocate.db&#39;: No such file or directory"/><category term="lvm snapshot installation in linux"/><category term="mysql basic commands."/><category term="nfs server in linux"/><category term="ngnix installation"/><category term="ntp error"/><category term="ntpd dead but pid file exists"/><category term="ntpq: read: Connection refused"/><category term="postgresql"/><category term="record every command and its output in linux"/><category term="restore mysql database in linux"/><category term="root cause analysis in linux"/><category term="rpm command usage in linux"/><category term="rpm options"/><category term="sample cron syntax"/><category term="save every command in linux"/><category term="search and replace using sed command."/><category term="sed command"/><category term="sed command examples to delete or remove specific lines in linux"/><category term="set environment in linux"/><category term="shell script to find the remote server details in linux"/><category term="shout cast"/><category term="smart ctl command in linux"/><category term="smartctl on 3ware hardware RAID"/><category term="smartmon tool installation"/><category term="ssh remote servers in shell script using ssh pass"/><category term="sshpass command"/><category term="startup script for tomcat."/><category term="step by step instructions to install nginx in linux"/><category term="steps to configure nfs in linux"/><category term="sytem priority in linux"/><category term="tool to recover deleted files in linux"/><category term="touch: cannot touch `/usr/local/tomcat/logs/catalina.out&#39;: No such file or directory"/><category term="tune mysql"/><category term="use awk command to filter the columns"/><category term="use date command in shell scripting"/><category term="user login details in Linux"/><category term="vim shortcuts in linux"/><category term="virutzzo commands"/><category term="vzquota"/><title type='text'>I&#39;m beginning to think Linux Really!</title><subtitle type='html'>Happy to learn and share the information&#39;s.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>110</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-2363032352451015236</id><published>2014-01-12T07:17:00.000-08:00</published><updated>2014-01-12T07:17:04.427-08:00</updated><title type='text'> Read files line by line using simple script.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
2. Read files line by line using simple script.&lt;br /&gt;
&lt;br /&gt;
[saikrishna.b@gai-1339 Documents]$ cat testfile&lt;br /&gt;
This is a sample script.&lt;br /&gt;
To test&lt;br /&gt;
the file is read line by line.&lt;br /&gt;
Hope this works.&lt;br /&gt;
Lets c.&lt;br /&gt;
Done&lt;br /&gt;
&lt;br /&gt;
[saikrishna.b@gai-1339 Documents]$ cat line.sh&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
filename=$1&lt;br /&gt;
count=0&lt;br /&gt;
cat $filename | while read a&lt;br /&gt;
do&lt;br /&gt;
let count++&lt;br /&gt;
echo &quot; $count $a &quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[saikrishna.b@gai-1339 Documents]$ sh line.sh testfile&lt;br /&gt;
&amp;nbsp;1 This is a sample script.&lt;br /&gt;
&amp;nbsp;2 To test&lt;br /&gt;
&amp;nbsp;3 the file is read line by line.&lt;br /&gt;
&amp;nbsp;4 Hope this works.&lt;br /&gt;
&amp;nbsp;5 Lets c.&lt;br /&gt;
&amp;nbsp;6 Done&lt;br /&gt;
&lt;br /&gt;
[saikrishna.b@gai-1339 Documents]$ cat line.sh&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
filename=$1&lt;br /&gt;
count=0&lt;br /&gt;
cat $filename | while read a&lt;br /&gt;
do&lt;br /&gt;
let count++&lt;br /&gt;
echo &quot; $count $a &quot;&lt;br /&gt;
done&lt;br /&gt;
echo -e &quot;\n Total $count lines read&quot; #Add this line to see how many line read is working.&lt;br /&gt;
&lt;br /&gt;
[saikrishna.b@gai-1339 Documents]$ sh line.sh testfile&lt;br /&gt;
&amp;nbsp;1 This is a sample script. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp;2 To test &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp;3 the file is read line by line. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp;4 Hope this works.&lt;br /&gt;
&amp;nbsp;5 Lets c.&lt;br /&gt;
&amp;nbsp;6 Done&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Total 0 lines read&lt;br /&gt;
&lt;br /&gt;
Instead use the below syntax to count the lines.&lt;br /&gt;
&lt;br /&gt;
[saikrishna.b@gai-1339 Documents]$ cat line.sh&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
filename=$1&lt;br /&gt;
count=0&lt;br /&gt;
while read a&lt;br /&gt;
do&lt;br /&gt;
let count++&lt;br /&gt;
echo &quot; $count $a &quot;&lt;br /&gt;
done &amp;lt; $filename&lt;br /&gt;
echo -e &quot;\n Total $count lines read&quot;&lt;br /&gt;
&lt;br /&gt;
[saikrishna.b@gai-1339 Documents]$ sh line.sh testfile&lt;br /&gt;
&amp;nbsp;1 This is a sample script.&lt;br /&gt;
&amp;nbsp;2 To test&lt;br /&gt;
&amp;nbsp;3 the file is read line by line.&lt;br /&gt;
&amp;nbsp;4 Hope this works.&lt;br /&gt;
&amp;nbsp;5 Lets c.&lt;br /&gt;
&amp;nbsp;6 Done&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Total 6 lines read&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/2363032352451015236/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/2363032352451015236?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/2363032352451015236'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/2363032352451015236'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2014/01/read-files-line-by-line-using-simple.html' title=' Read files line by line using simple script.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-3756200475656533052</id><published>2013-12-14T04:38:00.000-08:00</published><updated>2013-12-14T04:38:18.630-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Shell script to sort numbers in ascending and descending order."/><title type='text'>shellscript to sort numbers in ascending, descending order with the arguments supplied.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
shellscript to sort numbers in ascending, descending order with the arguments supplied.&lt;br /&gt;
&lt;br /&gt;
cat sort.sh&lt;br /&gt;
if [ $# -eq 0 ]&lt;br /&gt;
then&lt;br /&gt;
echo &quot;Enter valid Argument &quot;&lt;br /&gt;
exit&lt;br /&gt;
fi&lt;br /&gt;
for i in $*&lt;br /&gt;
do&lt;br /&gt;
echo $i &amp;gt;&amp;gt; tmpfile&lt;br /&gt;
done&lt;br /&gt;
echo &quot;Your sorted data are below&quot;&lt;br /&gt;
sort -nr tmpfile&lt;br /&gt;
echo &quot;Script Ends&quot;&lt;br /&gt;
&lt;br /&gt;
output:&lt;br /&gt;
&lt;br /&gt;
sh sort.sh &amp;nbsp;3 4 5 6 7&lt;br /&gt;
Your sorted data are below&lt;br /&gt;
7&lt;br /&gt;
6&lt;br /&gt;
5&lt;br /&gt;
4&lt;br /&gt;
3&lt;br /&gt;
&lt;br /&gt;
Script Ends&lt;br /&gt;
&lt;br /&gt;
Ascending order use sort -n&lt;br /&gt;
&lt;br /&gt;
sh sort.sh &amp;nbsp;3 4 5 6 7&lt;br /&gt;
&lt;br /&gt;
Your sorted data are below&lt;br /&gt;
3&lt;br /&gt;
4&lt;br /&gt;
5&lt;br /&gt;
6&lt;br /&gt;
7&lt;br /&gt;
Script Ends&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/3756200475656533052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/3756200475656533052?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/3756200475656533052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/3756200475656533052'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/12/shellscript-to-sort-numbers-in.html' title='shellscript to sort numbers in ascending, descending order with the arguments supplied.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-5678680540307717784</id><published>2013-12-14T04:35:00.000-08:00</published><updated>2013-12-14T04:35:16.215-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bash: locate: command not found"/><category scheme="http://www.blogger.com/atom/ns#" term="locate: can not open `/var/lib/mlocate/mlocate.db&#39;: No such file or directory"/><title type='text'>bash: locate: command not found </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
bash: locate: command not found&lt;br /&gt;
&lt;br /&gt;
1. yum install mlocate*&lt;br /&gt;
2. &amp;nbsp;locate filename&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; locate: can not open `/var/lib/mlocate/mlocate.db&#39;: No such file or directory&lt;br /&gt;
&lt;br /&gt;
3. updatedb&lt;br /&gt;
&lt;br /&gt;
4. locate&lt;i&gt; filename&lt;/i&gt;.will display the file location.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/5678680540307717784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/5678680540307717784?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/5678680540307717784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/5678680540307717784'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/12/bash-locate-command-not-found.html' title='bash: locate: command not found '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-6576785828917289046</id><published>2013-11-06T00:37:00.000-08:00</published><updated>2013-11-06T00:37:17.887-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Check lvm command usage in lvm logs. Maintain  lvm logs in Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="find lvm logs in linux"/><title type='text'>Configure  Logs for LVM  in linux</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp;Log all LVM commands&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf_backup&lt;br /&gt;
[root@test ~]# vi /etc/lvm/lvm.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
log {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # Controls the messages sent to stdout or stderr.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # There are three levels of verbosity, 3 being the most verbose.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; verbose = 0&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # Should we send log messages through syslog?&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # 1 is yes; 0 is no.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; syslog = 1&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # Should we log error and debug messages to a file?&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # By default there is no log file.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; #file = &quot;/var/log/lvm2.log&quot;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # Should we overwrite the log file each tisme the program is run?&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # By default we append.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; overwrite = 0&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # What level of log messages should we send to the log file and/or syslog?&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # There are 6 syslog-like log levels currently in use - 2 to 7 inclusive.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # 7 is the most verbose (LOG_DEBUG).&lt;br /&gt;
&amp;nbsp; &amp;nbsp; level = 0&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;# Format of output messages&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # Whether or not (1 or 0) to indent messages according to their severity&lt;br /&gt;
&amp;nbsp; &amp;nbsp; indent = 1&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # Whether or not (1 or 0) to display the command name on each line output&lt;br /&gt;
&amp;nbsp; &amp;nbsp; command_names = 0&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # A prefix to use before the message text (but after the command name,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # if selected). &amp;nbsp;Default is two spaces, so you can see/grep the severity&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # of each message.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; prefix = &quot; &amp;nbsp;&quot;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # To make the messages look similar to the original LVM tools use:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # &amp;nbsp; indent = 0&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # &amp;nbsp; command_names = 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # &amp;nbsp; prefix = &quot; -- &quot;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # Set this if you want log messages during activation.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # Don&#39;t use this in low memory situations (can deadlock).&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # activation = 0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
2 modifications to be done&lt;br /&gt;
&lt;br /&gt;
Uncomment the line # file = “/var/log/lvm2.log&lt;br /&gt;
&lt;br /&gt;
Change the level = 0 to a value between 2 and 7.&lt;br /&gt;
&lt;br /&gt;
What level of log messages should we send to the log file and/or syslog?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # There are 6 syslog-like log levels currently in use - 2 to 7 inclusive.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; # 7 is the most verbose (LOG_DEBUG).&lt;br /&gt;
&lt;br /&gt;
Enter level=7&lt;br /&gt;
&lt;br /&gt;
save and exit.&lt;br /&gt;
&lt;br /&gt;
Just test it with the lvm command and view the logs&lt;br /&gt;
&lt;br /&gt;
This is not the right syntax, just showed here for example.&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# lvcreate VG1&lt;br /&gt;
&amp;nbsp; Please specify either size or extents&lt;br /&gt;
&amp;nbsp; Run `lvcreate --help&#39; for more information.&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# tail -f /var/log/lvm2.log&lt;br /&gt;
activate/activate.c:471 &amp;nbsp; Getting target version for striped&lt;br /&gt;
ioctl/libdm-iface.c:1687 &amp;nbsp; dm versions &amp;nbsp; OF &amp;nbsp; [16384] (*1)&lt;br /&gt;
lvcreate.c:363 &amp;nbsp; Please specify either size or extents&lt;br /&gt;
lvcreate.c:768 &amp;nbsp; &amp;lt;backtrace&amp;gt;&lt;br /&gt;
lvmcmdline.c:623 &amp;nbsp; Run `lvcreate --help&#39; for more information.&lt;br /&gt;
lvmcmdline.c:1123 &amp;nbsp; Completed: lvcreate VG1&lt;br /&gt;
cache/lvmcache.c:1602 &amp;nbsp; Wiping internal VG cache&lt;br /&gt;
metadata/vg.c:74 &amp;nbsp; Freeing VG #orphans_lvm1 at 0x1f09d90.&lt;br /&gt;
metadata/vg.c:74 &amp;nbsp; Freeing VG #orphans_pool at 0x1f0e600.&lt;br /&gt;
metadata/vg.c:74 &amp;nbsp; Freeing VG #orphans_lvm2 at 0x1f13110.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/6576785828917289046/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/6576785828917289046?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/6576785828917289046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/6576785828917289046'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/11/configure-logs-for-lvm-in-linux.html' title='Configure  Logs for LVM  in linux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-5434402030988862343</id><published>2013-11-06T00:34:00.000-08:00</published><updated>2013-11-06T00:34:26.614-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="How to restore deleted lvm partition in linux. Steps to restore removed lvm partition."/><title type='text'>Restore removed LVM partition</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
[root@test ~]# df -h&lt;br /&gt;
Filesystem &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Size &amp;nbsp;Used Avail Use% Mounted on&lt;br /&gt;
/dev/sda2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20G &amp;nbsp; 18G &amp;nbsp;698M &amp;nbsp;97% /&lt;br /&gt;
/dev/mapper/VG1-backup&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;49G &amp;nbsp;197M &amp;nbsp; 46G &amp;nbsp; 1% /backup&lt;br /&gt;
/dev/mapper/VG1-downloads&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50G &amp;nbsp; 52M &amp;nbsp; 47G &amp;nbsp; 1% /downloads&lt;br /&gt;
/dev/mapper/VG1-home &amp;nbsp; 49G &amp;nbsp;181M &amp;nbsp; 46G &amp;nbsp; 1% /home&lt;br /&gt;
tmpfs &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 979M &amp;nbsp; &amp;nbsp; 0 &amp;nbsp;979M &amp;nbsp; 0% /dev/shm&lt;br /&gt;
/dev/mapper/VG1-public&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;59G &amp;nbsp;641M &amp;nbsp; 55G &amp;nbsp; 2% /public&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# lvremove /dev/VG1/public&lt;br /&gt;
&amp;nbsp; Can&#39;t remove open logical volume &quot;public&quot;&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# dmsetup info -c /dev/VG1/public&lt;br /&gt;
Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Maj Min Stat Open Targ Event &amp;nbsp;UUID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
VG1-public &amp;nbsp; &amp;nbsp; &amp;nbsp; 253 &amp;nbsp; 7 L--w &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 LVM-8FQ0SbqlR7hlFHpG2rnxUQ2WvafgEa1yMvxZcKGIIj6Rippe9VdxO4MptcgKaO1O&lt;br /&gt;
&lt;br /&gt;
Device mapper maintains entry for logical drives, so first we need to delete it from there. Then it can&#39;t restrict us while removing logical volumes which are in open status.&lt;br /&gt;
rom above table you can see Open = 1 which means the logical volume testlv is open status, so we need to delete entry for this logical volume from dmsetup table then only we can delete any logical volume with open status. &amp;nbsp;let&#39;s do it&lt;br /&gt;
&lt;br /&gt;
[root@test /]# dmsetup remove --force /dev/VG1/backup&lt;br /&gt;
device-mapper: remove ioctl failed: Device or resource busy&lt;br /&gt;
Command failed&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# umount /public/&lt;br /&gt;
[root@test ~]# lvremove /dev/VG1/public&lt;br /&gt;
Do you really want to remove active logical volume public? [y/n]: y&lt;br /&gt;
&amp;nbsp; Logical volume &quot;public&quot; successfully removed&lt;br /&gt;
[root@test ~]# lvs&lt;br /&gt;
&amp;nbsp; LV &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VG &amp;nbsp; Attr &amp;nbsp; LSize &amp;nbsp; Origin Snap% &amp;nbsp;Move Log Copy% &amp;nbsp;Convert&lt;br /&gt;
&amp;nbsp; backup &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp;-wi-ao &amp;nbsp;50.00G&lt;br /&gt;
&amp;nbsp; downloads VG1 &amp;nbsp;-wi-ao &amp;nbsp;54.00G&lt;br /&gt;
&amp;nbsp; home &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp;-wi-ao &amp;nbsp;50.00G&lt;br /&gt;
&amp;nbsp; images &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp;-wi-a- &amp;nbsp;50.00G&lt;br /&gt;
&amp;nbsp; stripe &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp;-wi-a- 128.00M&lt;br /&gt;
[root@test ~]# vgcfgrestore --list VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00011-1959345004.vg &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvremove /dev/VG1/snap1&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Wed Sep 11 20:23:22 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00012-1817284231.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvcreate -s --name backup-snap --size 1G /dev/VG1/backup&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Wed Sep 11 20:48:21 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00013-1680048821.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvremove /dev/VG1/backup-snap&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 09:13:22 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00014-2084989037.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvremove /dev/VG1/dbba&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 09:13:47 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00015-1654653445.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvremove /dev/VG1/public_snap&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 09:14:14 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00016-1108210628.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvremove /dev/VG1/test1&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 09:14:25 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00017-319369726.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvremove /dev/VG1/home1&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 09:14:35 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00018-1088715738.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvremove /dev/VG1/home2&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 09:14:45 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00019-950166769.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvremove /dev/VG1/dbbackup&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 09:15:03 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00020-722332065.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvresize -L -1G /dev/VG1/public&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 09:20:38 2013 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00021-227400998.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1&lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvresize -L +1G /dev/VG1/public&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 09:21:18 2013&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00022-271935578.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1&lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;vgsplit VG1 test /dev/sda5&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Mon Sep 16 10:01:04 2013&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/archive/VG1_00023-196107041.vg&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1&lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *before* executing &#39;lvremove /dev/VG1/public&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Tue Sep 17 09:35:07 2013&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; File: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /etc/lvm/backup/VG1&lt;br /&gt;
&amp;nbsp; VG name: &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1&lt;br /&gt;
&amp;nbsp; Description: &amp;nbsp;Created *after* executing &#39;lvremove /dev/VG1/public&#39;&lt;br /&gt;
&amp;nbsp; Backup Time: &amp;nbsp;Tue Sep 17 09:35:07 2013&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# vgcfgrestore -f /etc/lvm/archive/VG1_00023-196107041.vg&lt;br /&gt;
&amp;nbsp; Please specify a *single* volume group to restore. &lt;br /&gt;
&lt;br /&gt;
You also need to specify the volume group name&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# vgcfgrestore -f &amp;nbsp;/etc/lvm/archive/VG1_00023-196107041.vg VG1&lt;br /&gt;
&amp;nbsp; Restored volume group VG1&lt;br /&gt;
[root@test ~]# lvs&lt;br /&gt;
&amp;nbsp; LV &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VG &amp;nbsp; Attr &amp;nbsp; LSize &amp;nbsp; Origin Snap% &amp;nbsp;Move Log Copy% &amp;nbsp;Convert&lt;br /&gt;
&amp;nbsp; backup &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp;-wi-ao &amp;nbsp;50.00G&lt;br /&gt;
&amp;nbsp; downloads VG1 &amp;nbsp;-wi-ao &amp;nbsp;54.00G&lt;br /&gt;
&amp;nbsp; home &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp;-wi-ao &amp;nbsp;50.00G&lt;br /&gt;
&amp;nbsp; images &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp;-wi-a- &amp;nbsp;50.00G&lt;br /&gt;
&amp;nbsp; public &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp;-wi--- &amp;nbsp;60.00G&lt;br /&gt;
&amp;nbsp; stripe &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp;-wi-a- 128.00M&lt;br /&gt;
&lt;br /&gt;
Logical volume public is present now.&lt;br /&gt;
&lt;br /&gt;
lvdisplay&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; --- Logical volume --- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; LV Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/dev/VG1/public &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; VG Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; LV UUID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MvxZcK-GIIj-6Rip-pe9V-dxO4-Mptc-gKaO1O&lt;br /&gt;
&amp;nbsp; LV Write Access &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;read/write &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; LV Status &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NOT available &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; LV Size &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;60.00 GB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Current LE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1920 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Segments &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Allocation &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; inherit &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Read ahead sectors &amp;nbsp; &amp;nbsp; auto &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
The status is not available. Make it active&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# lvchange -a y /dev/VG1/public&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# lvdisplay&lt;br /&gt;
--- Logical volume --- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; LV Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/dev/VG1/public &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; VG Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;VG1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; LV UUID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MvxZcK-GIIj-6Rip-pe9V-dxO4-Mptc-gKaO1O&lt;br /&gt;
&amp;nbsp; LV Write Access &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;read/write &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; LV Status &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;available &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; # open &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; LV Size &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;60.00 GB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Current LE &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1920 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Segments &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Allocation &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; inherit &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Read ahead sectors &amp;nbsp; &amp;nbsp; auto &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; - currently set to &amp;nbsp; &amp;nbsp; 256 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; Block device &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 253:1 &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now it is in available state, mount and see the data is present or not.&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# mount /dev/VG1/public /public&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# df -h&lt;br /&gt;
Filesystem &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Size &amp;nbsp;Used Avail Use% Mounted on&lt;br /&gt;
/dev/sda2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20G &amp;nbsp; 18G &amp;nbsp;699M &amp;nbsp;97% /&lt;br /&gt;
/dev/mapper/VG1-backup&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;49G &amp;nbsp;197M &amp;nbsp; 46G &amp;nbsp; 1% /backup&lt;br /&gt;
/dev/mapper/VG1-downloads&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;50G &amp;nbsp; 52M &amp;nbsp; 47G &amp;nbsp; 1% /downloads&lt;br /&gt;
/dev/mapper/VG1-home &amp;nbsp; 49G &amp;nbsp;181M &amp;nbsp; 46G &amp;nbsp; 1% /home&lt;br /&gt;
tmpfs &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 979M &amp;nbsp; &amp;nbsp; 0 &amp;nbsp;979M &amp;nbsp; 0% /dev/shm&lt;br /&gt;
/dev/mapper/VG1-public&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;59G &amp;nbsp;641M &amp;nbsp; 55G &amp;nbsp; 2% /public&lt;br /&gt;
[root@test public]# ls&lt;br /&gt;
testdir&lt;br /&gt;
[root@test public]# cd testdir/&lt;br /&gt;
[root@test testdir]# ls&lt;br /&gt;
1 &amp;nbsp; &amp;nbsp;11 &amp;nbsp;14 &amp;nbsp;17 &amp;nbsp;2 &amp;nbsp; 22 &amp;nbsp;25 &amp;nbsp;28 &amp;nbsp;30 &amp;nbsp;33 &amp;nbsp;36 &amp;nbsp;39 &amp;nbsp;41 &amp;nbsp;44 &amp;nbsp;47 &amp;nbsp;5 &amp;nbsp; 52 &amp;nbsp;55 &amp;nbsp;58 &amp;nbsp;60 &amp;nbsp;63 &amp;nbsp;66 &amp;nbsp;69 &amp;nbsp;71 &amp;nbsp;74 &amp;nbsp;77 &amp;nbsp;8 &amp;nbsp; 82 &amp;nbsp;85 &amp;nbsp;88 &amp;nbsp;90 &amp;nbsp;93 &amp;nbsp;96 &amp;nbsp;99&lt;br /&gt;
10 &amp;nbsp; 12 &amp;nbsp;15 &amp;nbsp;18 &amp;nbsp;20 &amp;nbsp;23 &amp;nbsp;26 &amp;nbsp;29 &amp;nbsp;31 &amp;nbsp;34 &amp;nbsp;37 &amp;nbsp;4 &amp;nbsp; 42 &amp;nbsp;45 &amp;nbsp;48 &amp;nbsp;50 &amp;nbsp;53 &amp;nbsp;56 &amp;nbsp;59 &amp;nbsp;61 &amp;nbsp;64 &amp;nbsp;67 &amp;nbsp;7 &amp;nbsp; 72 &amp;nbsp;75 &amp;nbsp;78 &amp;nbsp;80 &amp;nbsp;83 &amp;nbsp;86 &amp;nbsp;89 &amp;nbsp;91 &amp;nbsp;94 &amp;nbsp;97&lt;br /&gt;
100 &amp;nbsp;13 &amp;nbsp;16 &amp;nbsp;19 &amp;nbsp;21 &amp;nbsp;24 &amp;nbsp;27 &amp;nbsp;3 &amp;nbsp; 32 &amp;nbsp;35 &amp;nbsp;38 &amp;nbsp;40 &amp;nbsp;43 &amp;nbsp;46 &amp;nbsp;49 &amp;nbsp;51 &amp;nbsp;54 &amp;nbsp;57 &amp;nbsp;6 &amp;nbsp; 62 &amp;nbsp;65 &amp;nbsp;68 &amp;nbsp;70 &amp;nbsp;73 &amp;nbsp;76 &amp;nbsp;79 &amp;nbsp;81 &amp;nbsp;84 &amp;nbsp;87 &amp;nbsp;9 &amp;nbsp; 92 &amp;nbsp;95 &amp;nbsp;98&lt;br /&gt;
&lt;br /&gt;
the data are present.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/5434402030988862343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/5434402030988862343?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/5434402030988862343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/5434402030988862343'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/11/restore-removed-lvm-partition.html' title='Restore removed LVM partition'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-810484250757575481</id><published>2013-11-06T00:32:00.000-08:00</published><updated>2013-11-06T00:32:09.676-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="configure swap and physical memory usage in linux"/><category scheme="http://www.blogger.com/atom/ns#" term="how to avoid  swap usage when physical ram is present"/><category scheme="http://www.blogger.com/atom/ns#" term="Swapiness"/><title type='text'>Configure Swapiness in Linux</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Setting swapiness means that virtual swap memory is not used until the physical memory gets full. To avoid this you can set swapiness value.&lt;br /&gt;
&lt;br /&gt;
Linux system comes with a default of 60, meaning that the swap file will be used fairly often if the memory usage is around half of my RAM.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can check your system&#39;s swappiness value by running:&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# cat /proc/sys/vm/swappiness&lt;br /&gt;
60&lt;br /&gt;
&lt;br /&gt;
So If i have 4 GB of RAM, and I like to turn that down to 10 or 15. The swap file will then only be used when my RAM usage is around 85 or 90 percent.&lt;br /&gt;
&lt;br /&gt;
To change the system swappiness value&lt;br /&gt;
&lt;br /&gt;
vim /etc/sysctl.conf as root. Then, change or add this line to the file:&lt;br /&gt;
&lt;br /&gt;
vm.swappiness = 10&lt;br /&gt;
&lt;br /&gt;
Reboot for the change to take effect&lt;br /&gt;
&lt;br /&gt;
You can also change the value while your system is still running&lt;br /&gt;
&lt;br /&gt;
sysctl vm.swappiness=10&lt;br /&gt;
&lt;br /&gt;
You can also clear your swap by running swapoff -a and then swapon -a as root instead of rebooting to achieve the same effect.&lt;br /&gt;
&lt;br /&gt;
To calculate your swap Formula&lt;br /&gt;
&lt;br /&gt;
free -m (total) / 100 = A&lt;br /&gt;
&lt;br /&gt;
A * 10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# free -m&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;total &amp;nbsp; &amp;nbsp; &amp;nbsp; used &amp;nbsp; &amp;nbsp; &amp;nbsp; free &amp;nbsp; &amp;nbsp; shared &amp;nbsp; &amp;nbsp;buffers &amp;nbsp; &amp;nbsp; cached&lt;br /&gt;
Mem: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3950 &amp;nbsp; &amp;nbsp; &amp;nbsp; 2262 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1687 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;407 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;952&lt;br /&gt;
-/+ buffers/cache: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;903 &amp;nbsp; &amp;nbsp; &amp;nbsp; 3047&lt;br /&gt;
Swap: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1953 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1953&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; so total is 3950 / 100 = 39.5 * 10 = 395&lt;br /&gt;
&lt;br /&gt;
It means that when 10 % 395 MB of ram left, then it start using swapiness.&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/810484250757575481/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/810484250757575481?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/810484250757575481'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/810484250757575481'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/11/configure-swapiness-in-linux.html' title='Configure Swapiness in Linux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-2371688609478886992</id><published>2013-10-05T08:09:00.000-07:00</published><updated>2013-10-05T08:09:03.000-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="rpm command usage in linux"/><category scheme="http://www.blogger.com/atom/ns#" term="rpm options"/><title type='text'>RPM Usage in Linux</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
1.How to install RPM in linux ?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#rpm –ivh packagename &amp;nbsp;// To install a RPM we need to use -i option.&lt;br /&gt;
&lt;br /&gt;
2. How to remove a RPM ?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#rpm -e packagename &amp;nbsp;// To remove a RPM file we need to use -e option.&lt;br /&gt;
&lt;br /&gt;
3.How to Upgrade a RPM ?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#rpm -Uvh packagename // To upgrade a RPM we need to use -U option.&lt;br /&gt;
&lt;br /&gt;
4.How to check installed RPM?&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#rpm -qa packagename &amp;nbsp; // To list or find a installed RPM we need to use -q option.&lt;br /&gt;
&lt;br /&gt;
5. How to List all files of an installed RPM package&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#rpm -ql packagename &amp;nbsp; // To list all files of installed rpm we need to use -ql ( query list) option.&lt;br /&gt;
&lt;br /&gt;
6.How to Install a RPM Package Without Dependencies&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#rpm -ivh --nodeps packagename // To install a RPM without any dependencies we need to use --nodeps option.&lt;br /&gt;
&lt;br /&gt;
7.How to check dependencies of RPM Package before Installing&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;#rpm -qpR packagename &amp;nbsp; // To check the dependeny for a RPM we need to use -qpR option.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; -q : Query a package&lt;br /&gt;
&amp;nbsp; -p : List capabilities this package provides.&lt;br /&gt;
&amp;nbsp; -R: List capabilities on which this package depends.&lt;br /&gt;
&lt;br /&gt;
8. How to Check an RPM Signature for a Package?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; #rpm --checksig &amp;nbsp;packagename.rpm &amp;nbsp; &amp;nbsp;// We need to use the option --checksig for signature verification.&lt;br /&gt;
&lt;br /&gt;
9. How to List Recently Installed RPM Packages&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; #rpm -qa --last &amp;nbsp; // To list recently installed RPM we need to use --last option&lt;br /&gt;
&lt;br /&gt;
10. How to Query a file that belongs which RPM Package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; #rpm -qf /etc/passwd &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // To find a file owned by which package&lt;br /&gt;
&lt;br /&gt;
11.Get the Information of RPM Package Before Installing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; #rpm -qip packagename&lt;br /&gt;
&lt;br /&gt;
12. How to Verify a RPM Package&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; #rpm -Vp &amp;nbsp;// To verify the installed RPM&lt;br /&gt;
&lt;br /&gt;
13.How to List all Imported RPM GPG keys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; #rpm -qa gpg-pubkey*&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
14. How to Remove an RPM Package Without Dependencies&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; #rpm -ev --nodeps packagename // same --nodeps option we need to use&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/2371688609478886992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/2371688609478886992?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/2371688609478886992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/2371688609478886992'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/10/rpm-usage-in-linux.html' title='RPM Usage in Linux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-2805069709183835523</id><published>2013-10-05T08:07:00.001-07:00</published><updated>2013-10-05T08:07:07.582-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="backup all the databases in mysql."/><category scheme="http://www.blogger.com/atom/ns#" term="Backup database in mysql. backup tables in mysql"/><title type='text'>Backup datbases and tables in Mysql </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Backup all databases uncompressed from the command line (not from within MySQL):&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;backup:&lt;/b&gt; mysqldump -u root -pmypass --all-databases &amp;gt; alldatabases.sql&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;restore full:&lt;/b&gt; mysql -u username -pmypass &amp;lt; alldatabases.sql (no space in between -p and mypass)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;restore single:&lt;/b&gt; mysql -u username -pmypass mydb &amp;lt; mydb.sql (no space in between -p and mypass)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Backup all databases compressed from the command line (not from within MySQL):&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;With bzip2:&lt;/b&gt; mysqldump --all-databases | bzip2 -c &amp;gt; databasebackup.sql.bz2 (use bunzip2 to uncompress)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;With gzip&lt;/b&gt;: mysqldump --all-databases | gzip &amp;gt; databasebackup.sql.gz (use gunzip to uncompress)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Mini script to backup all databases and tables using gzip:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
date=`date -I`&lt;br /&gt;
mysqldump --all-databases | gzip &amp;gt; /var/backup/dbbackup-$date.sql.gz&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Backup a specific database only:&lt;/b&gt;&lt;br /&gt;
mysqldump -u username -pmypass databasename &amp;gt; backupfile.sql&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Backup database structure only&lt;/b&gt;&lt;br /&gt;
mysqldump --no-data --databases databasename &amp;gt; structurebackup.sql&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Backup a specific database and specific tables within that database only:&lt;/b&gt;&lt;br /&gt;
mysqldump --add-drop-table -u username -pmypass databasename table_1 table_2 &amp;gt; databasebackup.sql&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The syntax for the command to issue is:&lt;/b&gt;&lt;br /&gt;
mysqldump -u [username] -p[password] [databasename] [table1 table2 ....] &amp;gt; backupfilename.sql&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Backing up only the database structure of specific databases, not the actual data:&lt;/b&gt;&lt;br /&gt;
mysqldump --no-data --databases db1 db2 db3 &amp;gt; structurebackup.sql&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/2805069709183835523/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/2805069709183835523?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/2805069709183835523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/2805069709183835523'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/10/backup-datbases-and-tables-in-mysql.html' title='Backup datbases and tables in Mysql '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-333298365679143367</id><published>2013-10-05T08:04:00.000-07:00</published><updated>2013-10-05T08:04:57.862-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Steps to reset mysql root password."/><title type='text'>Reset Mysql root password </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Reset root password in Mysql&lt;br /&gt;
&lt;br /&gt;
Method 1: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; use mysql;&lt;br /&gt;
Reading table information for completion of table and column names&lt;br /&gt;
You can turn off this feature to get a quicker startup with -A&lt;br /&gt;
&lt;br /&gt;
Database changed&lt;br /&gt;
mysql&amp;gt; update user set password=password(&#39;&#39;) where user=&#39;root&#39;;&lt;br /&gt;
Query OK, 3 rows affected (0.00 sec)&lt;br /&gt;
Rows matched: 3 &amp;nbsp;Changed: 3 &amp;nbsp;Warnings: 0&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# mysqladmin -u root -p&#39;global!23&#39; password &#39;linklinux&#39;&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
Welcome to the MySQL monitor. &amp;nbsp;Commands end with ; or \g.&lt;br /&gt;
Your MySQL connection id is 17&lt;br /&gt;
Server version: 5.1.69 Source distribution&lt;br /&gt;
&lt;br /&gt;
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.&lt;br /&gt;
&lt;br /&gt;
Oracle is a registered trademark of Oracle Corporation and/or its&lt;br /&gt;
affiliates. Other names may be trademarks of their respective&lt;br /&gt;
owners.&lt;br /&gt;
&lt;br /&gt;
Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the current input statement.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[root@gai-1347 ~]# mysqladmin -u root -p&#39;linklinux&#39; password &#39;&#39;&lt;br /&gt;
&lt;br /&gt;
Empty password&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Method 2:&lt;br /&gt;
&lt;br /&gt;
Stop mysql&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# mysqld_safe --skip-grant-tables &amp;amp;&lt;br /&gt;
[1] 8747 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
130810 11:38:36 mysqld_safe Logging to &#39;/var/log/mysqld.log&#39;.&lt;br /&gt;
130810 11:38:36 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql&lt;br /&gt;
&lt;br /&gt;
[root@test ~]# mysql -u root&lt;br /&gt;
Welcome to the MySQL monitor. &amp;nbsp;Commands end with ; or \g.&lt;br /&gt;
Your MySQL connection id is 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Server version: 5.1.69 Source distribution &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.&lt;br /&gt;
&lt;br /&gt;
Oracle is a registered trademark of Oracle Corporation and/or its&lt;br /&gt;
affiliates. Other names may be trademarks of their respective&lt;br /&gt;
owners.&lt;br /&gt;
&lt;br /&gt;
Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the current input statement.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; use mysql;&lt;br /&gt;
Reading table information for completion of table and column names&lt;br /&gt;
You can turn off this feature to get a quicker startup with -A&lt;br /&gt;
&lt;br /&gt;
Database changed&lt;br /&gt;
mysql&amp;gt; update user set password=password(&#39;linklinux&#39;) where user=&#39;root&#39;;&lt;br /&gt;
Query OK, 3 rows affected (0.00 sec)&lt;br /&gt;
Rows matched: 3 &amp;nbsp;Changed: 3 &amp;nbsp;Warnings: 0&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; \q&lt;br /&gt;
Bye&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/333298365679143367/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/333298365679143367?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/333298365679143367'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/333298365679143367'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/10/reset-mysql-root-password.html' title='Reset Mysql root password '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-4538413210945047494</id><published>2013-10-05T08:00:00.001-07:00</published><updated>2013-10-05T08:00:16.810-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mysql basic commands."/><category scheme="http://www.blogger.com/atom/ns#" term="Mysql commands used in system administration"/><title type='text'>MySQL Administrative commands </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp;MySQL Administration&lt;br /&gt;
&lt;br /&gt;
This is just &amp;nbsp;basics of maintaining a database including creation of databases, creation of users, granting of priveleges to users, changing passwords, and other activities from within the mysql CLI front end to MySQL.&lt;br /&gt;
Entering and Exiting the mysql Program&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[sai@test ~]$ mysql &lt;br /&gt;
ERROR 1045: Access denied for user: &#39;sai@localhost&#39; (Using password: NO)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
OOPs! User sai is apparently password protected, so we must run mysql to query for a password, and then type in the password.&lt;br /&gt;
&lt;br /&gt;
[sai@test ~]$ mysql -p&lt;br /&gt;
Enter password:&lt;br /&gt;
Welcome to the MySQL monitor. &amp;nbsp;Commands end with ; or \g.&lt;br /&gt;
Your MySQL connection id is 41 to server version: 4.0.18&lt;br /&gt;
&lt;br /&gt;
Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; quit&lt;br /&gt;
Bye&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the preceding, you ran mysql with the -p option so that it would query for the password, you typed in the password, and then you exited the mysql program by typing quit.&lt;br /&gt;
&lt;br /&gt;
By the way, if the account has no password (this is sometimes an installation default), you would just press Enter when prompted for the password.&lt;br /&gt;
&lt;br /&gt;
Perhaps if you want to log in as root instead of sai. This would probably be the case if you wanted to add a database or any other high responsibility action.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s how you log in as root:&lt;br /&gt;
&lt;br /&gt;
[sai@test ~]$ mysql -u root -p&lt;br /&gt;
Enter password:&lt;br /&gt;
Welcome to the MySQL monitor. &amp;nbsp;Commands end with ; or \g.&lt;br /&gt;
Your MySQL connection id is 42 to server version: 4.0.18&lt;br /&gt;
&lt;br /&gt;
Type &#39;help;&#39; or &#39;\h&#39; for help. Type &#39;\c&#39; to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; quit&lt;br /&gt;
Bye&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The -u root tells mysql to log you in as root user, and as previously discussed, the -p tells mysql to query for a password.&lt;br /&gt;
&lt;br /&gt;
In mysql, when you see a prompt like this:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you are in the mysql program. For the rest of this section, most examples will begin and end in mysql.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As a preventive measure&lt;br /&gt;
&lt;br /&gt;
There may be more than one root account, and you must password protect all of them.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; use mysql&lt;br /&gt;
Database changed&lt;br /&gt;
mysql&amp;gt; select host, user, password from user;&lt;br /&gt;
+-----------------------+-------+------------------+&lt;br /&gt;
| host &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| user &amp;nbsp;| password &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-----------------------+-------+------------------+&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | root &amp;nbsp;| 2aa0e9e91dbd7cf2 |&lt;br /&gt;
| localhost.localdomain | root &amp;nbsp;| 2aa0e9e91dbd7cf2 |&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;br /&gt;
| localhost.localdomain | &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | sai | 2aa0e9e91dbd7cf2 |&lt;br /&gt;
+-----------------------+-------+------------------+&lt;br /&gt;
5 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As you can see, there&#39;s a root account at localhost and another to localhost.localdomain. Both must be password protected. In reality, all &amp;nbsp;accounts should be password protected.&lt;br /&gt;
&lt;br /&gt;
Exploring Your MySQL Installation&lt;br /&gt;
&lt;br /&gt;
From within mysql you can find quite a bit of information concerning your installation.&lt;br /&gt;
&lt;br /&gt;
As what user are you logged into mysql? What databases exist? What tables exist in a database? What is the structure of a table? What users exist?&lt;br /&gt;
&lt;br /&gt;
Because different operations require different priveleges, to save time we&#39;ll perform all these actions logged into mysql &amp;nbsp;as root.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s start with finding out your username within mysql:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; select user();&lt;br /&gt;
+----------------+&lt;br /&gt;
| user() &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+----------------+&lt;br /&gt;
| root@localhost |&lt;br /&gt;
+----------------+&lt;br /&gt;
1 row in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let&#39;s list all the users authorized to log into mysql:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; use mysql&lt;br /&gt;
Database changed&lt;br /&gt;
mysql&amp;gt; select host, user, password from user;&lt;br /&gt;
+-----------------------+-------+------------------+&lt;br /&gt;
| host &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| user &amp;nbsp;| password &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-----------------------+-------+------------------+&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | root &amp;nbsp;| 2aa0e9e91dbd7cf2 |&lt;br /&gt;
| localhost.localdomain | root &amp;nbsp;| 2aa0e9e91dbd7cf2 |&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;br /&gt;
| localhost.localdomain | &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | sai | 2aa0e9e91dbd7cf2 |&lt;br /&gt;
+-----------------------+-------+------------------+&lt;br /&gt;
5 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice there are two root logons -- one at localhost and one at localhost.localdomain.&lt;br /&gt;
&lt;br /&gt;
They can have different passwords, or one of them can even have no password. Therefore, You&#39;d Better check to make sure they&#39;re both password protected.&lt;br /&gt;
&lt;br /&gt;
DO NOT forget the password(s). If you lose all administrative passwords, you lose control of your mysql installation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
User Maintenance&lt;br /&gt;
&lt;br /&gt;
Before discussing user maintenance, it&#39;s necessary to understand what properties exist for each user. To do that, we&#39;ll use mysql -e option to execute SQL commands and push the output to stdout.&lt;br /&gt;
&lt;br /&gt;
Watch this:&lt;br /&gt;
&lt;br /&gt;
[sai@test ~]$ mysql -u root -p -e &quot;use mysql;describe user;&quot; | cut -f 1&lt;br /&gt;
Enter password:&lt;br /&gt;
Field&lt;br /&gt;
Host&lt;br /&gt;
User&lt;br /&gt;
password&lt;br /&gt;
Select_priv&lt;br /&gt;
Insert_priv&lt;br /&gt;
Update_priv&lt;br /&gt;
Delete_priv&lt;br /&gt;
Create_priv&lt;br /&gt;
Drop_priv&lt;br /&gt;
Reload_priv&lt;br /&gt;
Shutdown_priv&lt;br /&gt;
Process_priv&lt;br /&gt;
File_priv&lt;br /&gt;
Grant_priv&lt;br /&gt;
References_priv&lt;br /&gt;
Index_priv&lt;br /&gt;
Alter_priv&lt;br /&gt;
Show_db_priv&lt;br /&gt;
Super_priv&lt;br /&gt;
Create_tmp_table_priv&lt;br /&gt;
Lock_tables_priv&lt;br /&gt;
Execute_priv&lt;br /&gt;
Repl_slave_priv&lt;br /&gt;
Repl_client_priv&lt;br /&gt;
ssl_type&lt;br /&gt;
ssl_cipher&lt;br /&gt;
x509_issuer&lt;br /&gt;
x509_subject&lt;br /&gt;
max_questions&lt;br /&gt;
max_updates&lt;br /&gt;
max_connections&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The word &quot;Field&quot; is a heading, not a piece of information about a user. After that, the first three fields are the user&#39;s host, username and password.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;The password is encoded. If you hadn&#39;t included the cut command, you&#39;d have seen that the same username can exist in multiple hosts, even if both hosts refer to the same physical machine.&lt;br /&gt;
&lt;br /&gt;
That&#39;s why it&#39;s vital to MAKE SURE TO password protect ALL users. The next several fields after password are priveleges that can be granted to the user, or not.&lt;br /&gt;
There&#39;s also a way to grant ALL privileges to a user. But from a security point of view this is very dangerous, as ordinary looking users can be turned into backdoors.&lt;br /&gt;
&lt;br /&gt;
I&#39;d suggest always granting and revoking specific privileges. Here is a list of the privileges that MySQL users can have, and what those privileges allow them to do:&lt;br /&gt;
&lt;br /&gt;
USER FIELD &amp;nbsp; &amp;nbsp;PRIVILEGE &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;FUNCTION&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Select_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Select &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to use the select command. In other words, ability to read.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Insert_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Insert &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to insert new data -- insert a new row.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Update_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Update &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to change existing data -- change contents of a row.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Delete_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Delete &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to delete rows of existing data.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Create_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Create &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to create a new table.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Drop_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Drop &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to drop a table.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Reload_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Reload &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Shutdown_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Shutdown &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Process_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Process &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
File_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;File &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Grant_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Grant &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to grant and revoke privileges to others.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
References_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;References &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Index_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Index &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to create new indexes or drop indexes.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Alter_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Alter &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to change the structure of a table.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Show_db_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Super_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Create_tmp_table_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to create temporary tables.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Lock_tables_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ability to lock tables.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Execute_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Repl_slave_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
Repl_client_priv &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The root user, or any user given sufficient privileges, can create new users with the grant command:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; grant select on test2.* to myuid@localhost identified by &#39;mypassword&#39;;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; select host, user, password from mysql.user;&lt;br /&gt;
+-----------------------+-------+------------------+&lt;br /&gt;
| host &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| user &amp;nbsp;| password &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-----------------------+-------+------------------+&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | root &amp;nbsp;| 7939f45f28d0aa41 |&lt;br /&gt;
| localhost.localdomain | root &amp;nbsp;| 2aa0e9e91dbd7cf2 |&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;br /&gt;
| localhost.localdomain | &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | sai &amp;nbsp; | 2aa0e9e91dbd7cf2 |&lt;br /&gt;
| localhost &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | myuid | 162eebfb6477e5d3 |&lt;br /&gt;
+-----------------------+-------+------------------+&lt;br /&gt;
6 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the preceding, we grant one privilege, select, on every table in the test2 database (test2.*), to user myuid at host localhost (myuid@localhost), giving that user the password &quot;mypassword&quot;. We then query table user in the mysql database (mysql.user) in &amp;nbsp;order to see whether user myuid has been created. Indeed he has.&lt;br /&gt;
&lt;br /&gt;
Granting select privilege is insufficient for any user using any app that modies data. Let&#39;s give myuid more privileges in the test2 database:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; grant Insert, Update, Delete, Create on test2.* to myuid@localhost;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now user myuid can not only select, but can insert rows, update rows, delete rows, and create tables and databases. Conspicuously missing is the ability to drop tables and databases -- that can be more dangerous, in the hands of a careless but not malicious user, than some of the other abilities.&lt;br /&gt;
&lt;br /&gt;
Privileges granted by the grant command are not kept in the mysql.user table, but instead in the mysql.db table. You can see results by issuing this command from the operating system:&lt;br /&gt;
&lt;br /&gt;
[sai@test ~]$ mysql -u root -p -e &#39;select * from mysql.db where host=&quot;localhost&quot; and user=&quot;myuid&quot;;&#39; &amp;gt; temp.txt&lt;br /&gt;
Enter password:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The results look like this:&lt;br /&gt;
&lt;br /&gt;
Host&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Db&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;User&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Select_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Insert_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Update_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Delete_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Create_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Drop_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Grant_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;References_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Index_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Alter_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Create_tmp_table_priv&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Lock_tables_priv&lt;br /&gt;
localhost&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;test2&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;myuid&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Y&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Y&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Y&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Y&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Y&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;N&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;N&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;N&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;N&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;N&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;N&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;N&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can revoke privileges like this:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; revoke Delete, Create on test2.* from myuid@localhost;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you redo the select on mysql.db, you&#39;ll see that those two privileges are now marked N.&lt;br /&gt;
&lt;br /&gt;
To actually delete a user, you use a SQL statement to delete him from the mysql.users table after revoking all his privileges.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When deleting the user from mysql.user, if you forget the where clause, or any of its tests, especially the test on column user, you will delete too many users -- possibly all users, in which case you&#39;ll have no way to operate the database. BE VERY CAREFUL!&lt;br /&gt;
&lt;br /&gt;
Now that you understand the potential landmines, here&#39;s how you delete a user:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; revoke all on test2.* from myuid@localhost;&lt;br /&gt;
Query OK, 0 rows affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; delete from mysql.user where user=&#39;myuid&#39; and host=&#39;localhost&#39;;&lt;br /&gt;
Query OK, 1 row affected (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exploring Your Databases&lt;br /&gt;
&lt;br /&gt;
You can refer to a table in two ways: By name after connecting to its database with a use statement, and with the databasename.tablename syntax.&lt;br /&gt;
The former is much more common in applications, but the latter is often used in database administration, especially when you must access the system database (mysql) in order to perform work on a different database.&lt;br /&gt;
&lt;br /&gt;
The first item for exploration is to find all databases:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; show databases;&lt;br /&gt;
+-------------------+&lt;br /&gt;
| Database &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;br /&gt;
+-------------------+&lt;br /&gt;
| depot_development |&lt;br /&gt;
| depot_production &amp;nbsp;|&lt;br /&gt;
| depot_test &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;br /&gt;
| mysql &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| test &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;br /&gt;
| test2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-------------------+&lt;br /&gt;
6 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the preceding, you went into the mysql program, determined what databases existed. Now let&#39;s explore the test database:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; use test;&lt;br /&gt;
Database changed&lt;br /&gt;
mysql&amp;gt; show tables;&lt;br /&gt;
+----------------+&lt;br /&gt;
| Tables_in_test |&lt;br /&gt;
+----------------+&lt;br /&gt;
| dogs &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| people &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+----------------+&lt;br /&gt;
2 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So the database test has two tables, dogs and people. Let&#39;s examine the columns in each of those tables:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; show columns from dogs;&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
| Field | Type &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Null | Key | Default | Extra |&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
| owner | varchar(20) | &amp;nbsp; &amp;nbsp; &amp;nbsp;| PRI | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| name &amp;nbsp;| varchar(20) | &amp;nbsp; &amp;nbsp; &amp;nbsp;| PRI | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
2 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; show columns from people;&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
| Field | Type &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Null | Key | Default | Extra |&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
| lname | varchar(20) | &amp;nbsp; &amp;nbsp; &amp;nbsp;| PRI | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| fname | varchar(20) | &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| mname | varchar(16) | YES &amp;nbsp;| &amp;nbsp; &amp;nbsp; | NULL &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
3 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another way to get the same information is with the describe command:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; describe dogs;&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
| Field | Type &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Null | Key | Default | Extra |&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
| owner | varchar(20) | &amp;nbsp; &amp;nbsp; &amp;nbsp;| PRI | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| name &amp;nbsp;| varchar(20) | &amp;nbsp; &amp;nbsp; &amp;nbsp;| PRI | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
2 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; describe people;&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
| Field | Type &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Null | Key | Default | Extra |&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
| lname | varchar(20) | &amp;nbsp; &amp;nbsp; &amp;nbsp;| PRI | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| fname | varchar(20) | &amp;nbsp; &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
| mname | varchar(16) | YES &amp;nbsp;| &amp;nbsp; &amp;nbsp; | NULL &amp;nbsp; &amp;nbsp;| &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;br /&gt;
+-------+-------------+------+-----+---------+-------+&lt;br /&gt;
3 rows in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; \q&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/4538413210945047494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/4538413210945047494?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4538413210945047494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4538413210945047494'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/10/mysql-administrative-commands.html' title='MySQL Administrative commands '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-4064375427475455578</id><published>2013-09-23T04:46:00.000-07:00</published><updated>2013-09-23T04:46:13.658-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="date command"/><category scheme="http://www.blogger.com/atom/ns#" term="date command with examples."/><category scheme="http://www.blogger.com/atom/ns#" term="use date command in shell scripting"/><title type='text'>Date command with examples</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre style=&quot;white-space: pre-wrap; word-wrap: break-word;&quot;&gt;Date command is most essentially used in scripting for date wise backups and in other scenarios.                                                                
                                                                     
                                                                     
                                             
    date +&quot;%Y/%m/%d %H:%M&quot;

is correct and 

    date +%Y/%m/%d %H:%M  

is not.&lt;/pre&gt;
&lt;pre style=&quot;white-space: pre-wrap; word-wrap: break-word;&quot;&gt;Please note that if you date conversion template contains spaces you need to put it in single or double quotes

If  you are OK with two year year representation you can use %y instead of %Y. There is also a macro %D that provides date in  mm/dd/yy format, so we can rewrite the previous example as

     date +&quot;%D %H:%M&quot;

Here  are most important build-in macros:

        %% a literal %
        %a locale&#39;s abbreviated weekday name (Sun..Sat)
        %A locale&#39;s full weekday name, variable length (Sunday..Saturday) %b locale&#39;s abbreviated month name (Jan..Dec)
        %B locale&#39;s full month name, variable length (January..December)
        %c locale&#39;s date and time (Sat Nov 04 12:02:33 EST 1989)
        %d day of month (01..31)
        %D date (mm/dd/yy)
        %e day of month, blank padded ( 1..31)
        %H hour (00..23)
        %j day of year (001..366)
        %m month (01..12)
        %M minute (00..59)
        %n a newline
        %p locale&#39;s AM or PM
        %r time, 12-hour (hh:mm:ss [AP]M)
        %S second (00..60)
        %t a horizontal tab
        %T time, 24-hour (hh:mm:ss)
        %U week number of year with Sunday as first day of week (00..53)
        %V week number of year with Monday as first day of week (01..52)
        %w day of week (0..6); 0 represents Sunday
        %W week number of year with Monday as first day of week (00..53)
        %x locale&#39;s date representation (mm/dd/yy)
        %X locale&#39;s time representation (%H:%M:%S)
        %y last two digits of year (00..99)
        %Y -- ccyy year

Date also can work not with the current time, but with time of modification of the referenced file

    date -r /etc/passwd +&quot;%y%m%d&quot;

It also can serve as data calculator.
Various options for past days (GNU date only):

date +&quot;%Y%m%d&quot; -d sunday # GNU date
20060709

date +&quot;%Y%m%d&quot; -d last-sunday # GNU date
20060702

date +&quot;%Y%m%d&quot; -d last-week # GNU date
date -v -1m +&quot;%Y%m%d&quot; # BSD date
20060627

date +&quot;%Y%m%d&quot; -d last-month # GNU date
date -v -1w +&quot;%Y%m%d&quot; # BSD date
20060604

date +&quot;%Y%m%d&quot; -d last-year # GNU date
date -v -1y +&quot;%Y%m%d&quot; # BSD date
20050704

date +&quot;%Y%m%d&quot; -d next-week # GNU date
date -v 1w +&quot;%Y%m%d&quot; # BSD date
20060711

date +&quot;%Y%m%d&quot; -d next-month # GNU date
date -v 1m +&quot;%Y%m%d&quot; # BSD date
20060804

date +&quot;%Y%m%d&quot; -d next-year # GNU date
date -v 1y +&quot;%Y%m%d&quot; # BSD date
20070704

To show the time in seconds since 1970-01-01 (Unix epoch):

date +&quot;%s&quot; -d &quot;Fri Apr 24 13:14:39 CDT 2009&quot;
1240596879

To convert Unix epoch time (seconds since 1970-01-01) to a human readable format:

date -d &quot;UTC 1970-01-01 1240596879 secs&quot;
Fri Apr 24 13:14:39 CDT 2009

Or:

date -ud @1000000000
Sun Sep  9 01:46:40 UTC 2001

    Examples

date &quot;+%-m/%-d/%y&quot; 
7/4/06

date &quot;+%Y%m%d&quot;
20060704

    $ date  +&quot;%b %d, %Y&quot;
    Mar 14, 2010

    date -d yesterday +&quot;%Y/%m/%d&quot;
    2010/03/13

Yesterday assigned to variable

DATE=$(date -d yesterday +&quot;%Y%m%d&quot;)
echo $DATE
20060704

To assign the time to a variable

START=`date &#39;+%r&#39;`
echo $START
03:06:02 PM
sleep 5
echo $START
03:06:02 PM

To show the time in a different timezone, the TZ environment variable is read, Timezone types is found in /usr/share/zoneinfo

OLDTZ=$TZ
export TZ=GMT; echo &quot;GMT:               `date +\&quot;%F %R (%Z)\&quot;`&quot;
GMT:               2008-10-31 12:30 (GMT)
export TZ=Europe/Stockholm; echo &quot;Stockholm:    `date +\&quot;%F %R (%Z)\&quot;`&quot;
Stockholm:    2008-10-31 13:30 (CET)
export TZ=Asia/Kuala_Lumpur; echo &quot;Kuala Lumpur: `date +\&quot;%F %R (%Z)\&quot;`&quot;
Kuala Lumpur:        2008-10-31 20:30 (MYT)
export TZ=US/Central; echo &quot;Dallas:             `date +\&quot;%F %R (%Z)\&quot;`&quot;
Dallas:             2008-10-31 07:30 (CDT)
export TZ=$OLDTZ

Using date for offset calculation:

date +&quot;%Y%m%d&quot; -d sunday
20060709

date +&quot;%Y%m%d&quot; -d last-sunday
20060702

date +&quot;%Y%m%d&quot; -d last-week
20060627

date +&quot;%Y%m%d&quot; -d last-month
20060604

date +&quot;%Y%m%d&quot; -d last-year
20050704

date +&quot;%Y%m%d&quot; -d next-week
20060711

date +&quot;%Y%m%d&quot; -d next-month
20060804

date +&quot;%Y%m%d&quot; -d next-year
20070704&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/4064375427475455578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/4064375427475455578?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4064375427475455578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4064375427475455578'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/09/date-command-with-examples.html' title='Date command with examples'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-4620495873365245585</id><published>2013-09-03T02:58:00.000-07:00</published><updated>2013-09-03T02:58:16.092-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cron format in linux"/><category scheme="http://www.blogger.com/atom/ns#" term="cron syntax in linux"/><category scheme="http://www.blogger.com/atom/ns#" term="cron syntax with examples"/><category scheme="http://www.blogger.com/atom/ns#" term="cron with examples"/><category scheme="http://www.blogger.com/atom/ns#" term="sample cron syntax"/><title type='text'>Cron Format in linux.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Cron Format&lt;br /&gt;
&lt;br /&gt;
Cron is a simple and powerful way to perform various actions in a timely manner. It also plays a main role in automating tasks.&lt;br /&gt;
&lt;br /&gt;
cron format consists of five fields separated by white spaces:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Minute&amp;gt; &amp;lt;Hour&amp;gt; &amp;lt;Day_of_the_Month&amp;gt; &amp;lt;Month_of_the_Year&amp;gt; &amp;lt;Day_of_the_Week&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cron format:&lt;br /&gt;
&lt;br /&gt;
* * * * * &amp;nbsp; &amp;nbsp; followed by command to be executed.&lt;br /&gt;
| | | | | &lt;br /&gt;
| | | | |&lt;br /&gt;
| | | | +---- &amp;nbsp; Day of the Week &amp;nbsp; (range: 1-7, 1 standing for Monday)&lt;br /&gt;
| | | +------ &amp;nbsp;Month of the Year (range: 1-12)&lt;br /&gt;
| | +-------- Day of the Month &amp;nbsp;(range: 1-31)&lt;br /&gt;
&lt;br /&gt;
| +---------- Hour &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(range: 0-23)&lt;br /&gt;
+------------ Minute &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(range: 0-59)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Any of these 5 fields may be an asterisk (*). This would mean the entire range of possible values, i.e. each minute, each hour, etc.&lt;br /&gt;
&lt;br /&gt;
Any field may contain a list of values separated by commas, (e.g. 1,3,7) or a range of values (two integers separated by a hyphen, e.g. 1-5).&lt;br /&gt;
&lt;br /&gt;
After the asterisk or values, you can use character / to do repeated action with certain intervals.&lt;br /&gt;
&lt;br /&gt;
For example, you can write &quot;0-23/2&quot; in Hour field to specify that some action should be performed every two hours (it will have the same effect as &quot;0,2,4,6,8,10,12,14,16,18,20,22&quot;); value &quot;*/4&quot; in Minute field means that the action should be performed every 4 minutes, &quot;1-30/3&quot; means the same as &quot;1,4,7,10,13,16,19,22,25,28&quot;.&lt;br /&gt;
&lt;br /&gt;
In Month and Day of Week fields, you can use names of months or days of weeks abbreviated to first three letters (&quot;Jan,Feb,...,Dec&quot; or &quot;Mon,Tue,...,Sun&quot;) instead of their numeric values.&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&lt;br /&gt;
* * * * * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Each minute&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
59 23 31 12 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;One minute &amp;nbsp;before the end of year if the last day of the year is Friday.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;(or)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;         &lt;/span&gt;&lt;br /&gt;
59 23 31 DEC Fri &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Same as above&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
00 12 13 7 * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Every &amp;nbsp;year, on July 13th at 12:00&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
0,15,30,45 0,6,12,18 1,15,31 * 1-5 &amp;nbsp;At 00:00, 00:15, 00:30, 00:45, 06:00, 06:15, 06:30,06:45, 12:00, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12:15, 12:30, 12:45, 18:00, 18:15,18:30, 18:45, on 1st, 15th or &amp;nbsp;31st &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;of each &amp;nbsp;month, but not on weekends&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*/15 */6 1,15,31 * 1-5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Same as above&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
0 12 * * 1-5 * &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; At midday on weekdays&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* * * 1,3,5,7,9,11 * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Each minute in January, &amp;nbsp;March, &amp;nbsp;May, July, September, and November&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1,2,3,5,20-25,30-35,59 23 31 12 * &amp;nbsp;On the &amp;nbsp;last day of year, at 23:01, 23:02, 23:03, 23:05,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;23:20, 23:21, 23:22, 23:23, 23:24, 23:25, 23:30,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 23:31, 23:32, 23:33, 23:34, 23:35, 23:59&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
0 9 1-7 * 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;First Monday of each month, at 9 a.m.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
0 0 1 * * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;At midnight, on the first day of each month&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* 0-11 * * * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Each minute before midday&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* * * 1,2,3 * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Each minute in January, February or March&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* * * Jan,Feb,Mar * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Same as above&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
0 0 * * * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Daily at midnight&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
0 0 * * 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Each Wednesday at midnight&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also use special strings like below&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@reboot&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;nbsp; At startup.&lt;br /&gt;
&lt;br /&gt;
@yearly&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;nbsp; Run once a year&lt;br /&gt;
&lt;br /&gt;
0 0 1 1 *&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp; (Same as above)&lt;br /&gt;
&lt;br /&gt;
@annually&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;(same as @yearly)&lt;br /&gt;
&lt;br /&gt;
@monthly&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp; Run once a month&lt;br /&gt;
&lt;br /&gt;
0 0 1 * * &amp;nbsp; &amp;nbsp; (same as above)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
@weekly&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;&amp;nbsp;Run once a week&lt;br /&gt;
&lt;br /&gt;
0 0 * * 0 &amp;nbsp; &amp;nbsp; (same as above)&lt;br /&gt;
&lt;br /&gt;
@daily&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Run once a day&lt;br /&gt;
&lt;br /&gt;
0 0 * * * &amp;nbsp; &amp;nbsp; &amp;nbsp;(same as above)&lt;br /&gt;
&lt;br /&gt;
@midnight&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp;(same as @daily)&lt;br /&gt;
&lt;br /&gt;
@hourly&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Run once an hour&lt;br /&gt;
&lt;br /&gt;
0 * * * * &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(same as above)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
you can use&lt;br /&gt;
&lt;br /&gt;
crontab -e to edit and add your cronjobs.&lt;br /&gt;
&lt;br /&gt;
crontab -l to list the cronjobs.&lt;br /&gt;
&lt;br /&gt;
Before pressing the enter button , ensure that you haven&#39;t entered crontab -r as it would delete all the cronjobs.&lt;br /&gt;
&lt;br /&gt;
To check the users cronjobs, use the below syntax.&lt;br /&gt;
&lt;br /&gt;
crontab -u username -l&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/4620495873365245585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/4620495873365245585?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4620495873365245585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4620495873365245585'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/09/cron-format-in-linux.html' title='Cron Format in linux.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-7566044303090089556</id><published>2013-09-03T02:52:00.000-07:00</published><updated>2013-09-03T02:52:36.453-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="postgresql"/><category scheme="http://www.blogger.com/atom/ns#" term="Postgresql  installation in linux"/><title type='text'>Install postgresql in linux</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Download postgresql software&lt;br /&gt;
&lt;br /&gt;
wget http://ftp.postgresql.org/pub/source/v9.2.3/postgresql-9.2.3.tar.bz2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tar -jxvf postgresql-9.2.3.tar.bz2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
cd postgresql-9.2.3 &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
./configure --without-readline&lt;br /&gt;
&amp;nbsp;make&lt;br /&gt;
&amp;nbsp;make install&lt;br /&gt;
&lt;br /&gt;
[root@machine1 postgresql-9.2.3]# useradd postgres &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine1 postgresql-9.2.3]# mkdir /usr/local/&lt;br /&gt;
bin/ &amp;nbsp; &amp;nbsp; etc/ &amp;nbsp; &amp;nbsp; games/ &amp;nbsp; include/ lib/ &amp;nbsp; &amp;nbsp; lib64/ &amp;nbsp; libexec/ pgsql/ &amp;nbsp; sbin/ &amp;nbsp; &amp;nbsp;share/ &amp;nbsp; src/ &amp;nbsp; &lt;br /&gt;
[root@machine1 postgresql-9.2.3]# mkdir /usr/local/pgsql/data&lt;br /&gt;
[root@machine1 postgresql-9.2.3]# chown postgres /usr/local/pgsql/data&lt;br /&gt;
[root@machine1 postgresql-9.2.3]# /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data&lt;br /&gt;
initdb: cannot be run as root &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Please log in (using, e.g., &quot;su&quot;) as the (unprivileged) user that will &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
own the server process. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine1 postgresql-9.2.3]# su - postgres&lt;br /&gt;
[postgres@machine1 ~]$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data&lt;br /&gt;
The files belonging to this database system will be owned by user &quot;postgres&quot;.&lt;br /&gt;
This user must also own the server process. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
The database cluster will be initialized with locale &quot;en_US.UTF-8&quot;.&lt;br /&gt;
The default database encoding has accordingly been set to &quot;UTF8&quot;. &lt;br /&gt;
The default text search configuration will be set to &quot;english&quot;. &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
fixing permissions on existing directory /usr/local/pgsql/data ... ok&lt;br /&gt;
creating subdirectories ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
selecting default max_connections ... 100 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
selecting default shared_buffers ... 32MB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
creating configuration files ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
creating template1 database in /usr/local/pgsql/data/base/1 ... ok &lt;br /&gt;
initializing pg_authid ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
initializing dependencies ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
creating system views ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
loading system objects&#39; descriptions ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
creating collations ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
creating conversions ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
creating dictionaries ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
setting privileges on built-in objects ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
creating information schema ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
loading PL/pgSQL server-side language ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
vacuuming database template1 ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
copying template1 to template0 ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
copying template1 to postgres ... ok &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
WARNING: enabling &quot;trust&quot; authentication for local connections&lt;br /&gt;
You can change this by editing pg_hba.conf or using the option -A, or&lt;br /&gt;
--auth-local and --auth-host, the next time you run initdb.&lt;br /&gt;
&lt;br /&gt;
Success. You can now start the database server using:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data&lt;br /&gt;
or&lt;br /&gt;
&amp;nbsp; &amp;nbsp; /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start&lt;br /&gt;
&lt;br /&gt;
[postgres@machine1 ~]$ /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data &amp;gt;logfile 2&amp;gt;&amp;amp;1 &amp;amp;&lt;br /&gt;
[1] 26097&lt;br /&gt;
[postgres@machine1 ~]$ /usr/local/pgsql/bin/createdb test&lt;br /&gt;
/usr/local/pgsql/bin/createdb: symbol lookup error: /usr/local/pgsql/bin/createdb: undefined symbol: PQconnectdbParams&lt;br /&gt;
[postgres@machine1 ~]$ &amp;nbsp;LD_LIBRARY_PATH=/usr/local/pgsql/lib&lt;br /&gt;
[postgres@machine1 ~]$ export &amp;nbsp;LD_LIBRARY_PATH=/usr/local/pgsql/lib&lt;br /&gt;
[postgres@machine1 ~]$ /usr/local/pgsql/bin/createdb test&lt;br /&gt;
[postgres@machine1 ~]$&lt;br /&gt;
&lt;br /&gt;
create database&lt;br /&gt;
&lt;br /&gt;
[postgres@machine1 ~]$ /usr/local/pgsql/bin/psql test&lt;br /&gt;
psql (9.2.3)&lt;br /&gt;
Type &quot;help&quot; for help.&lt;br /&gt;
&lt;br /&gt;
test=#&lt;br /&gt;
test=#&lt;br /&gt;
test=#&lt;br /&gt;
&lt;br /&gt;
change postgres password&lt;br /&gt;
&lt;br /&gt;
[postgres@machine1 ~]$ /usr/local/pgsql/bin/psql test&lt;br /&gt;
psql (9.2.3)&lt;br /&gt;
Type &quot;help&quot; for help.&lt;br /&gt;
&lt;br /&gt;
test=# ALTER USER postgres WITH ENCRYPTED PASSWORD &#39;postgres&#39;;&lt;br /&gt;
ALTER ROLE&lt;br /&gt;
test=# \q&lt;br /&gt;
&lt;br /&gt;
Edit the postgre configuration file and add the below lines&lt;br /&gt;
&lt;br /&gt;
[root@machine1 postgresql-9.2.3]# vi /usr/local/pgsql/data/pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
#host &amp;nbsp; &amp;nbsp;all &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; all &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 127.0.0.1/32 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;trust&lt;br /&gt;
to&lt;br /&gt;
host &amp;nbsp; &amp;nbsp;all &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; all &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 127.0.0.1/32 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;md5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
vi /usr/local/pgsql/data/postgresql.conf&lt;br /&gt;
&lt;br /&gt;
# - Connection Settings -&lt;br /&gt;
&lt;br /&gt;
#listen_addresses = &#39;localhost&#39; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # what IP address(es) to listen on;&lt;br /&gt;
to&lt;br /&gt;
listen_addresses = &#39;*&#39; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;# what IP address(es) to listen on;&lt;br /&gt;
&lt;br /&gt;
uncomment&lt;br /&gt;
password_encryption = on&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first time you run &quot;service postgresql start&quot;, it asks you to initialize a database, run:&lt;br /&gt;
&lt;br /&gt;
service postgresql initdb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To start the postgres service while starting the server, follow the below steps&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# cp -rf /usr/local/src/postgresql-9.2.3/contrib/start-scripts/linux /etc/init.d/postgres&lt;br /&gt;
[root@machine1 ~]# chmod 755 /etc/init.d/postgres&lt;br /&gt;
[root@machine1 ~]# /etc/init.d/postgres start&lt;br /&gt;
Starting PostgreSQL: ok&lt;br /&gt;
[root@machine1 ~]# /etc/init.d/postgres restart&lt;br /&gt;
Restarting PostgreSQL: ok&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To have PostgreSQL start automatically when the computer boots add&lt;br /&gt;
symbolic links from the correct /etc/rc*.d/ directories to&lt;br /&gt;
/etc/init.d/postgres. If the normal runlevel is 3 then you really only&lt;br /&gt;
need to add it to rc3.d:&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# ln -s /etc/init.d/postgres /etc/rc3.d/S85postgres&lt;br /&gt;
[root@machine1 ~]# ll /etc/rc3.d/S85postgres&lt;br /&gt;
lrwxrwxrwx 1 root root 20 Jun 28 16:25 /etc/rc3.d/S85postgres -&amp;gt; /etc/init.d/postgres&lt;br /&gt;
&lt;br /&gt;
We now successfully installed the postgresql, if you would like to change the port number, do the changes in &amp;nbsp;the below configuration file&lt;br /&gt;
&lt;br /&gt;
/usr/local/pgsql/data/postgresql.conf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/7566044303090089556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/7566044303090089556?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/7566044303090089556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/7566044303090089556'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/09/install-postgresql-in-linux.html' title='Install postgresql in linux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-9053130244872332405</id><published>2013-08-05T00:35:00.002-07:00</published><updated>2013-08-05T00:35:55.473-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="search and replace using sed command."/><category scheme="http://www.blogger.com/atom/ns#" term="sed command"/><category scheme="http://www.blogger.com/atom/ns#" term="sed command with examples"/><title type='text'>Advanced examples with sed command,</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Sed - Stream Editor is a powerful command to modify the files in linux. Sed command is one of most useful commands used in shell scripting. Some of the sed examples&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# cat test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Search and replace certain patterns in a file&lt;br /&gt;
&lt;br /&gt;
Replaces first occurance of the pattern in file &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/unix/1&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
unix &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Replaces second occurance of pattern in the file&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/unix/2&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. unix is assembled under the model of free and open source software development and distribution. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Even this syntax replaces the first occurance.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/unix/&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
unix &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Replaces all the matching pattern in the file.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/unix/g&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
unix &amp;nbsp;is a Unix-like computer operating system. unix is assembled under the model of free and open source software development and distribution.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# cat test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Replaces the matching pattern from the second occurances to the last.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/unix/2g&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. unix is assembled under the model of free and open source software development and distribution.Love to work with unix. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# cat &amp;gt; test1.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
http://google.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
http://yahoo.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# cat test1.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
http://google.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
http://yahoo.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Replacing a url. Here \ is the delimiter&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/http:\/\//www/&#39; test1.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
wwwgoogle.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
wwwyahoo.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/http:\/\//www./&#39; test1.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
www.google.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
www.yahoo.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
We can also use _ as a delimiter&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s_http://_www._&#39; test1.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
www.google.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
www.yahoo.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Here | is the delimiter.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s|http:|_www.|&#39; test1.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
_www.//google.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
_www.//yahoo.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s|http:|www.|&#39; test1.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
www.//google.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
www.//yahoo.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s|http://|www.|&#39; test1.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
www.google.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
www.yahoo.com &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# cat test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Searches for a specific pattern and add some extra characters, symbols using &amp;amp;&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/{&amp;amp;}/&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
{Linux} &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/,&amp;amp;/&#39; test.txt&lt;br /&gt;
,Linux &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/&amp;amp;,/&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux, &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
To include the same patter once again use &amp;amp;&amp;amp;&lt;br /&gt;
&lt;br /&gt;
only in First occurance.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/{&amp;amp;&amp;amp;}/&#39; test.txt&lt;br /&gt;
{LinuxLinux} &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&lt;br /&gt;
Includes the extra characters to all the matching pattern.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/{&amp;amp;}/g&#39; test.txt&lt;br /&gt;
{Linux} &amp;nbsp;is a Unix-like computer operating system. {Linux} is assembled under the model of free and open source software development and distribution.Love to work with {Linux}.&lt;br /&gt;
&lt;br /&gt;
Search and replaces the matching pattern and prints line double.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;s/Linux/unix/p&#39; test.txt&lt;br /&gt;
unix &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
unix &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&lt;br /&gt;
Search, replace and prints the line.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed -n &#39;s/Linux/unix/p&#39; test.txt&lt;br /&gt;
unix &amp;nbsp;is a Unix-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&lt;br /&gt;
Executing multiple sed commands in single line using | symbol and -e option&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &amp;nbsp;&#39;s/Linux/LINUXOS/&#39; test.txt | sed &#39;s/Unix/UnixOS/&#39;&lt;br /&gt;
LINUXOS &amp;nbsp;is a UnixOS-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed -e &#39;s/Linux/LINUXOperatingSystem/&#39; -e &#39;s/Unix/UnixOperatingSystem/&#39; test.txt&lt;br /&gt;
LINUXOperatingSystem &amp;nbsp;is a UnixOperatingSystem-like computer operating system. Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# cat test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning Linux is very easy. &lt;br /&gt;
&lt;br /&gt;
Replaces word Linux with unix in the second line of the file&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine2 ~]# sed &#39;2 s/Linux/unix/&#39; test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
unix is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning Linux is very easy. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Replaces word Linux with unix in the first and second line of the file. We can also specify the line range.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;1,2 s/Linux/unix/&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
unix &amp;nbsp;is a Unix-like computer operating system. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
unix is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning Linux is very easy. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Replaces word Linux with unix from first to last line of the file&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;1,$ s/Linux/unix/&#39; test.txt&lt;br /&gt;
unix &amp;nbsp;is a Unix-like computer operating system. &amp;nbsp; &lt;br /&gt;
unix is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning unix is very easy. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Search for a specific pattern and replaces it.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine2 ~]# sed &#39;/Linux/ s/Linux/centos/&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
centos &amp;nbsp;is a Unix-like computer operating system. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
centos is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning centos is very easy. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Here, Search for the occurances a matching pattern and replaces it with the given word.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;/Linux/ s/Unix/Fedora/&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux &amp;nbsp;is a Fedora-like computer operating system. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning Linux is very easy. &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
In above searches for Unix and replaces with Fedora.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Prints the line twice in a file.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;p&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning Linux is very easy. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning Linux is very easy. &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Like grep command fetches and prints the line where the matching string found.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine2 ~]# sed -n &#39;/free/ p&#39; test.txt&lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Prints the line other than the matching string line.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed -n &#39;/free/ !p&#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning Linux is very easy. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Add a new line after the matching pattern.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;/Learning/ a &quot;Adding a new line&quot; &#39; test.txt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
Learning Linux is very easy. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&quot;Adding a new line&quot;&lt;br /&gt;
&lt;br /&gt;
Add a new line before the matching pattern.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;/Learning/ i &quot;Adding a new line&quot; &#39; test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&quot;Adding a new line&quot;&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
&lt;br /&gt;
Change the line where the matching string found.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;/Learning/ c &quot;chaning with a new line&quot; &#39; test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&quot;chaning with a new line&quot;&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;/Learning/ c &quot;changing with a new line&quot; &#39; test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&quot;changing with a new line&quot;&lt;br /&gt;
&lt;br /&gt;
Transfrom with the specific letters like tr command.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;y/L/l&#39; test.txt&lt;br /&gt;
sed: -e expression #1, char 5: unterminated `y&#39; command&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;y/L/l/&#39; test.txt&lt;br /&gt;
linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
linux is assembled under the model of free and open source software development and distribution.love to work with linux.&lt;br /&gt;
learning linux is very easy&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/9053130244872332405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/9053130244872332405?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/9053130244872332405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/9053130244872332405'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/08/advanced-examples-with-sed-command.html' title='Advanced examples with sed command,'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-4186722878377281530</id><published>2013-08-05T00:35:00.001-07:00</published><updated>2013-08-05T00:35:26.430-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="sed command examples to delete or remove specific lines in linux"/><title type='text'>Remove specific lines in a file using sed command.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
sed command examples to delete or remove specific lines in linux&lt;br /&gt;
Here file is the file name.&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# cat &amp;gt; file &lt;br /&gt;
first &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
END &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
[root@machine1 ~]# cat file &amp;nbsp; &lt;br /&gt;
first &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
END &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Here 1 is the line number and d is the option to delete first line&lt;br /&gt;
&lt;br /&gt;
[root@machine1~]# sed &#39;1d&#39; file &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
END &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# cat file &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
first &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
END &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
This will not remove in the orignal file, to remove in original use -i option&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed -i &#39;1d&#39; file&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# cat file &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
END &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
We also have the option to redirect it to the other file&lt;br /&gt;
[root@machine1 ~]# sed &#39;2d&#39; file &amp;gt; &amp;nbsp;file1&lt;br /&gt;
&lt;br /&gt;
To delete a last line in linux.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine1 ~]# sed &#39;$d&#39; file &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine1 ~]# cat file &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
END &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine1 ~]# sed -i &#39;$d&#39; file &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# cat file &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete for specific range. here i delete from 2nd to 4th line&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;2,4d&#39; file &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# cat file &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete except first line&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;1!d&#39; file &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete except last line&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;$!d&#39; file&lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete except specific line range from 2 to 4&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;2,4!d&#39; file&lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete first and last line, here ; specify multiple conditions&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;1d;$d&#39; file&lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete blank or empty lines&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;/^$/d&#39; file&lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete line starts with pariticular characters&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;/^f/d&#39; file&lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete line end with particular character&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;/d$/d&#39; file&lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# cat file&lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
LINUX &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
UBUNTU &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete lines in upper case&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;/^[A-Z]*$/d&#39; file&lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Delete lines that contain a specific pattern here i delete a line starts with a pattern UBUNTU &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;/UBUNTU/d&#39; file&lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
LINUX &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Delete line starting from a pattern till the last line.&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;/fifth/,$d&#39; file&lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Delete last line only if it contains a specific pattern&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed &#39;${/UBUNTU/d;}&#39; file &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
second &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
third &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fourth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
fifth &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
LINUX &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
prints specific line which contain a pattern fifth&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
[root@machine1 ~]# cat file&lt;br /&gt;
second&lt;br /&gt;
third&lt;br /&gt;
fourth&lt;br /&gt;
fifth&lt;br /&gt;
LINUX&lt;br /&gt;
UBUNTU&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed -n &#39;/fifth/p&#39; file&lt;br /&gt;
fifth&lt;br /&gt;
&lt;br /&gt;
To print between 2 patterns&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# sed -n &#39;/fifth/,/UBUNTU/p&#39; file&lt;br /&gt;
fifth&lt;br /&gt;
LINUX&lt;br /&gt;
UBUNTU&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/4186722878377281530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/4186722878377281530?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4186722878377281530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4186722878377281530'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/08/remove-specific-lines-in-file-using-sed.html' title='Remove specific lines in a file using sed command.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-4673368234230601266</id><published>2013-08-05T00:35:00.000-07:00</published><updated>2013-08-05T00:35:03.380-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="add blank lines in a file using sed command."/><category scheme="http://www.blogger.com/atom/ns#" term="sed command with examples"/><title type='text'>Add blank lines using sed command.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Add a double blank lines after each line&lt;br /&gt;
&lt;br /&gt;
sed G test.txt&lt;br /&gt;
&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
&lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
&lt;br /&gt;
Add triple blank lines after each lines.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;G;G&#39; test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &amp;nbsp;-i &#39;G;G&#39; test.txt&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# cat test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Linux is assembled under the model of free and open source software development and distribution.Love to work with Linux.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
&lt;br /&gt;
Undo double space.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;n;d&#39; test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
&lt;br /&gt;
Add a single blank line above the matching pattern.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;/Redhat/{x;p;x}&#39; test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
&lt;br /&gt;
Redhat Enterprise linux&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# cat test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
Redhat Enterprise linux&lt;br /&gt;
&lt;br /&gt;
Add a blank line below the matching pattern.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;/Redhat/G&#39; test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
Redhat Enterprise linux&lt;br /&gt;
&lt;br /&gt;
Add a blank line above and below the matching pattern.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed &#39;/Redhat/{x;p;x;G}&#39; test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
&lt;br /&gt;
Redhat Enterprise linux&lt;br /&gt;
&lt;br /&gt;
Number the lines in linux&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed = test.txt | sed &#39;N;s/\n/\t/&#39;&lt;br /&gt;
1 &amp;nbsp; &amp;nbsp; &amp;nbsp; Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
2&lt;br /&gt;
3 &amp;nbsp; &amp;nbsp; &amp;nbsp; Learning Linux is very easy.&lt;br /&gt;
4 &amp;nbsp; &amp;nbsp; &amp;nbsp; Redhat Enterprise linux&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;[root@machine2 ~]# sed = test.txt&lt;br /&gt;
1&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
3&lt;br /&gt;
Learning Linux is very easy.&lt;br /&gt;
4&lt;br /&gt;
Redhat Enterprise linux&lt;br /&gt;
&lt;br /&gt;
N join the lines.&lt;br /&gt;
&lt;br /&gt;
The &#39;s/\n/\t/&#39; replaces the newline chars with tabs,&lt;br /&gt;
&lt;br /&gt;
1 &amp;nbsp; &amp;nbsp; &amp;nbsp; Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
2&lt;br /&gt;
3 &amp;nbsp; &amp;nbsp; &amp;nbsp; Learning Linux is very easy.&lt;br /&gt;
4 &amp;nbsp; &amp;nbsp; &amp;nbsp; Redhat Enterprise linux&lt;br /&gt;
&lt;br /&gt;
Cound the number of lines in a file&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed -n &#39;$=&#39; test.txt&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
Print number of lines in a file.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 ~]# sed 2q test.txt&lt;br /&gt;
Linux &amp;nbsp;is a Unix-like computer operating system.&lt;br /&gt;
&lt;br /&gt;
Prints specific line number in a file&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/4673368234230601266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/4673368234230601266?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4673368234230601266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4673368234230601266'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/08/add-blank-lines-using-sed-command.html' title='Add blank lines using sed command.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-4623814669803238175</id><published>2013-08-05T00:34:00.001-07:00</published><updated>2013-08-05T00:34:36.580-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Advanced examples with awk command."/><title type='text'>Advanced examples with awk command.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
[root@machine2 test]# awk &#39;1;{print &quot;&quot;}&#39; testdoc &lt;br /&gt;
total 4.0K &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:46 testdoc&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;BEGIN{ORS=&quot;\n\n&quot;}&#39; testdoc&lt;br /&gt;
ORS- output row separator&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;BEGIN{ORS=&quot;\n\n&quot;};1&#39; testdoc&lt;br /&gt;
total 4.0K &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:46 testdoc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;NF{print $0 &quot;\n&quot;}&#39; testdoc&lt;br /&gt;
&lt;br /&gt;
triple space a file&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;1;{print &quot;\n&quot;}&#39; testdoc&lt;br /&gt;
total 4.0K &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
&lt;br /&gt;
Print each line with its line number using thebelow syntax&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;{print NR &quot;\t&quot; $0}&#39; testdoc&lt;br /&gt;
1 &amp;nbsp; &amp;nbsp; &amp;nbsp; total 4.0K &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
2 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
3 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
4 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
5 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
6 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
7 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
8 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
9 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
10 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
11 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
12 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
13 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
14 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
15 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
16 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
17 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
18 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:46 testdoc&lt;br /&gt;
[root@machine2 test]# awk &#39;{print FNR &quot;\t&quot; $0}&#39; testdoc&lt;br /&gt;
1 &amp;nbsp; &amp;nbsp; &amp;nbsp; total 4.0K&lt;br /&gt;
2 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
3 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
4 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
5 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
6 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
7 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
8 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
9 &amp;nbsp; &amp;nbsp; &amp;nbsp; -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
10 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
11 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
12 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
13 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
14 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
15 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
16 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
17 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
18 &amp;nbsp; &amp;nbsp; &amp;nbsp;-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:46 testdoc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;{printf(&quot;%5d : %s\n&quot;, NR,$0)}&#39; testdoc&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 1 : total 4.0K&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 2 : -rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 3 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 4 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 5 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 6 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 7 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 8 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
&amp;nbsp; &amp;nbsp; 9 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
&amp;nbsp; &amp;nbsp;10 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
&amp;nbsp; &amp;nbsp;11 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
&amp;nbsp; &amp;nbsp;12 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
&amp;nbsp; &amp;nbsp;13 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
&amp;nbsp; &amp;nbsp;14 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
&amp;nbsp; &amp;nbsp;15 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
&amp;nbsp; &amp;nbsp;16 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
&amp;nbsp; &amp;nbsp;17 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
&amp;nbsp; &amp;nbsp;18 : -rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:46 testdoc&lt;br /&gt;
&lt;br /&gt;
Left align and right align using the above syntax&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;{ total = total + NF }; END {print total}&#39; testdoc&lt;br /&gt;
155&lt;br /&gt;
print the total number of fields (&quot;words&quot;) in all lines&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;{print $NF}&#39; testdoc&lt;br /&gt;
4.0K&lt;br /&gt;
for.sh&lt;br /&gt;
testing1&lt;br /&gt;
testing2&lt;br /&gt;
testing4&lt;br /&gt;
testing3&lt;br /&gt;
testing6&lt;br /&gt;
testing5&lt;br /&gt;
testing8&lt;br /&gt;
testing7&lt;br /&gt;
testing9&lt;br /&gt;
testing10&lt;br /&gt;
testing12&lt;br /&gt;
testing11&lt;br /&gt;
testing13&lt;br /&gt;
testing14&lt;br /&gt;
testing15&lt;br /&gt;
testdoc&lt;br /&gt;
&lt;br /&gt;
Prints the last filed in every line with above syntax&lt;br /&gt;
[root@machine2 test]# awk &#39;{print NF &quot;:&quot; $0 }&#39; testdoc&lt;br /&gt;
2:total 4.0K&lt;br /&gt;
9:-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
9:-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:46 testdoc&lt;br /&gt;
&lt;br /&gt;
Prints number of fields followed by a character in each line.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;{test=$NF}; END{print test }&#39; testdoc&lt;br /&gt;
testdoc&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;END{print $NF}&#39; testdoc&lt;br /&gt;
testdoc&lt;br /&gt;
&lt;br /&gt;
Find the last field of the last line using the above syntaxes&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;NF &amp;gt; 3&#39; testdoc&lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:46 testdoc&lt;br /&gt;
&lt;br /&gt;
Prints number of fields larger than 3&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;NF &amp;lt; 3&#39; testdoc&lt;br /&gt;
total 4.0K&lt;br /&gt;
&lt;br /&gt;
Prints number of fields less than 3&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;NR &amp;lt; 4&#39; testdoc&lt;br /&gt;
total 4.0K&lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;NR &amp;lt;=4&#39; testdoc&lt;br /&gt;
total 4.0K&lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
&lt;br /&gt;
Prints number of rows less than 4 and equal to 4 using above syntax.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;/total/&#39; testdoc&lt;br /&gt;
total 4.0K&lt;br /&gt;
search for a pattern using above syntax.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;!/total/&#39; testdoc&lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:46 testdoc&lt;br /&gt;
&lt;br /&gt;
Prints other than the searching pattern using above syntax.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;/total/; /for/&#39; testdoc&lt;br /&gt;
total 4.0K&lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
&lt;br /&gt;
search multiple pattern using above syntax.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;length&amp;gt; 48&#39; testdoc&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
&lt;br /&gt;
print only line above 48 characters through above syntax.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;length&amp;lt; 15&#39; testdoc&lt;br /&gt;
total 4.0K&lt;br /&gt;
prints less than 15 characters&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# &amp;nbsp;awk &#39;NR==8,NR==12&#39; testdoc&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
&lt;br /&gt;
Prints specific rows from 8 to 12 with the above syntaxes&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# &amp;nbsp;awk &#39;NR==12&#39; testdoc&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
&lt;br /&gt;
prints specific line.&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/4623814669803238175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/4623814669803238175?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4623814669803238175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4623814669803238175'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/08/advanced-examples-with-awk-command.html' title='Advanced examples with awk command.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-2171317889880974797</id><published>2013-08-05T00:34:00.000-07:00</published><updated>2013-08-05T00:34:19.639-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="awk command usage"/><category scheme="http://www.blogger.com/atom/ns#" term="awk command with examples"/><category scheme="http://www.blogger.com/atom/ns#" term="use awk command to filter the columns"/><title type='text'>awk command with examples</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
[root@machine2 test]# for i in `seq 1 1 15`; do touch &amp;nbsp;testing$i; done&lt;br /&gt;
[root@machine2 test]# ls&lt;br /&gt;
for.sh &amp;nbsp; &amp;nbsp;testing10 &amp;nbsp;testing12 &amp;nbsp;testing14 &amp;nbsp;testing2 &amp;nbsp;testing4 &amp;nbsp;testing6 &amp;nbsp;testing8&lt;br /&gt;
testing1 &amp;nbsp;testing11 &amp;nbsp;testing13 &amp;nbsp;testing15 &amp;nbsp;testing3 &amp;nbsp;testing5 &amp;nbsp;testing7 &amp;nbsp;testing9&lt;br /&gt;
[root@machine2 test]# ls -lrth&lt;br /&gt;
total 4.0K&lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# ls -lrth &amp;gt; testdoc&lt;br /&gt;
&lt;br /&gt;
To fetch only the column type $followed by the column number.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# cat testdoc | awk &#39;{print$1}&#39;&lt;br /&gt;
total &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# cat testdoc | awk &#39;{print$1,$2}&#39;&lt;br /&gt;
total 4.0K &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# cat testdoc | awk &#39;{print$1,$5}&#39;&lt;br /&gt;
total &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 166 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# cat testdoc | awk &#39;{print$1,$6}&#39;&lt;br /&gt;
total &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jan &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- Jun&lt;br /&gt;
-rw-r--r-- Jun&lt;br /&gt;
-rw-r--r-- Jun&lt;br /&gt;
-rw-r--r-- Jun&lt;br /&gt;
-rw-r--r-- Jun&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# cat testdoc | awk &#39;{print$1,$9}&#39;&lt;br /&gt;
total&lt;br /&gt;
-rw-r--r-- for.sh&lt;br /&gt;
-rw-r--r-- testing1&lt;br /&gt;
-rw-r--r-- testing2&lt;br /&gt;
-rw-r--r-- testing4&lt;br /&gt;
-rw-r--r-- testing3&lt;br /&gt;
-rw-r--r-- testing6&lt;br /&gt;
-rw-r--r-- testing5&lt;br /&gt;
-rw-r--r-- testing8&lt;br /&gt;
-rw-r--r-- testing7&lt;br /&gt;
-rw-r--r-- testing9&lt;br /&gt;
-rw-r--r-- testing10&lt;br /&gt;
-rw-r--r-- testing12&lt;br /&gt;
-rw-r--r-- testing11&lt;br /&gt;
-rw-r--r-- testing13&lt;br /&gt;
-rw-r--r-- testing14&lt;br /&gt;
-rw-r--r-- testing15&lt;br /&gt;
-rw-r--r-- testdoc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;BEGIN {total=0} {total=total+$5} END {print total}&#39; testdoc&lt;br /&gt;
166&lt;br /&gt;
&lt;br /&gt;
The above syntax will print the sum of 5th column in the testdoc file. Here total is the variable &amp;nbsp;assigned to zero in the begin syntax.&lt;br /&gt;
In the action block, the value of 5th column is passed for each row .After all values are processed, it prints the total value in END block.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk -f totalscript testdoc&lt;br /&gt;
166&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# cat totalscript&lt;br /&gt;
#!/usr/bin/awk -f&lt;br /&gt;
BEGIN {total=0} {total=total+$5} END {print total}&lt;br /&gt;
&lt;br /&gt;
We can use the script in a file and use -f option to run it.&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;{if($9 == &quot;testing9&quot;) print$0;}&#39; testdoc&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;BEGIN{for(i=1;i&amp;lt;=10;i++) print &quot;square of&quot;, i, &quot;is&quot;, i*i;}&#39;&lt;br /&gt;
square of 1 is 1&lt;br /&gt;
square of 2 is 4&lt;br /&gt;
square of 3 is 9&lt;br /&gt;
square of 4 is 16&lt;br /&gt;
square of 5 is 25&lt;br /&gt;
square of 6 is 36&lt;br /&gt;
square of 7 is 49&lt;br /&gt;
square of 8 is 64&lt;br /&gt;
square of 9 is 81&lt;br /&gt;
square of 10 is 100&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk -F: &#39;{print$3}&#39; /etc/passwd &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
7 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
12 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
14 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
99 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
81 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
170 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
69 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
32 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
499 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
173 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
68&lt;br /&gt;
38&lt;br /&gt;
498&lt;br /&gt;
89&lt;br /&gt;
27&lt;br /&gt;
70&lt;br /&gt;
29&lt;br /&gt;
65534&lt;br /&gt;
497&lt;br /&gt;
74&lt;br /&gt;
72&lt;br /&gt;
55&lt;br /&gt;
28&lt;br /&gt;
65&lt;br /&gt;
96&lt;br /&gt;
52&lt;br /&gt;
496&lt;br /&gt;
495&lt;br /&gt;
48&lt;br /&gt;
50022&lt;br /&gt;
75&lt;br /&gt;
107&lt;br /&gt;
141&lt;br /&gt;
14&lt;br /&gt;
Here -F is the field separator . We can also use &amp;nbsp;awk &#39;BEGIN {FS=&quot;:&quot;} {print $3}&#39; /etc/passwd&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;{print$8,$9}&#39; testdoc&lt;br /&gt;
&lt;br /&gt;
18:53 for.sh&lt;br /&gt;
17:43 testing1&lt;br /&gt;
17:43 testing2&lt;br /&gt;
17:43 testing4&lt;br /&gt;
17:43 testing3&lt;br /&gt;
17:43 testing6&lt;br /&gt;
17:43 testing5&lt;br /&gt;
17:43 testing8&lt;br /&gt;
17:43 testing7&lt;br /&gt;
17:43 testing9&lt;br /&gt;
17:43 testing10&lt;br /&gt;
17:43 testing12&lt;br /&gt;
17:43 testing11&lt;br /&gt;
17:43 testing13&lt;br /&gt;
17:43 testing14&lt;br /&gt;
17:43 testing15&lt;br /&gt;
17:46 testdoc&lt;br /&gt;
0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;BEGIN{OFS=&quot;:&quot;}{print$8,$9}&#39; testdoc&lt;br /&gt;
:&lt;br /&gt;
18:53:for.sh&lt;br /&gt;
17:43:testing1&lt;br /&gt;
17:43:testing2&lt;br /&gt;
17:43:testing4&lt;br /&gt;
17:43:testing3&lt;br /&gt;
17:43:testing6&lt;br /&gt;
17:43:testing5&lt;br /&gt;
17:43:testing8&lt;br /&gt;
17:43:testing7&lt;br /&gt;
17:43:testing9&lt;br /&gt;
17:43:testing10&lt;br /&gt;
17:43:testing12&lt;br /&gt;
17:43:testing11&lt;br /&gt;
17:43:testing13&lt;br /&gt;
17:43:testing14&lt;br /&gt;
17:43:testing15&lt;br /&gt;
17:46:testdoc&lt;br /&gt;
&lt;br /&gt;
OFS- Output Field separator , we add any character with this option&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# ls -l &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
total 12 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root 166 Jan 25 18:53 for.sh &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root 847 Jun &amp;nbsp;9 17:46 testdoc &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing11 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing12 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing13 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing14 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing6&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing7&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing8&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp; 0 Jun &amp;nbsp;9 17:43 testing9&lt;br /&gt;
-rw-r--r-- 1 root root &amp;nbsp;71 Jun &amp;nbsp;9 17:59 totalscript&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;{print NF}&#39; testdoc&lt;br /&gt;
2&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
9&lt;br /&gt;
&lt;br /&gt;
NF - Number of field variables This will print number of columns in each row&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;{print NR}&#39; testdoc&lt;br /&gt;
1&lt;br /&gt;
2&lt;br /&gt;
3&lt;br /&gt;
4&lt;br /&gt;
5&lt;br /&gt;
6&lt;br /&gt;
7&lt;br /&gt;
8&lt;br /&gt;
9&lt;br /&gt;
10&lt;br /&gt;
11&lt;br /&gt;
12&lt;br /&gt;
13&lt;br /&gt;
14&lt;br /&gt;
15&lt;br /&gt;
16&lt;br /&gt;
17&lt;br /&gt;
18&lt;br /&gt;
NR- Number of records, prints count of lines in a file or line number&lt;br /&gt;
&lt;br /&gt;
For total line numbers type the below syntax&lt;br /&gt;
&lt;br /&gt;
[root@machine2 test]# awk &#39;END{print NR}&#39; testdoc&lt;br /&gt;
18&lt;br /&gt;
&lt;br /&gt;
to search the contents in awk with out casesensitive IGNORECASE=1&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/2171317889880974797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/2171317889880974797?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/2171317889880974797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/2171317889880974797'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/08/awk-command-with-examples.html' title='awk command with examples'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-7132412870093080015</id><published>2013-08-05T00:33:00.000-07:00</published><updated>2013-08-05T00:33:41.497-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Display or change ethernet card settings in linux"/><category scheme="http://www.blogger.com/atom/ns#" term="full duplex"/><category scheme="http://www.blogger.com/atom/ns#" term="half duplex"/><title type='text'>Ethtool - Display or change ethernet card settings</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
ethtool - Display or change ethernet card settings&lt;br /&gt;
&lt;br /&gt;
Full duplex -sending and receiving data simultaneously.&lt;br /&gt;
half duplex - half duplex, you can either send or receive data at a time (&lt;br /&gt;
to find nic card half or full duplex&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# dmesg | grep -i duplex&lt;br /&gt;
e1000e: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# ethtool eth0&lt;br /&gt;
Settings for eth0:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Supported ports: [ TP ]&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Supported link modes: &amp;nbsp; 10baseT/Half 10baseT/Full&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100baseT/Half 100baseT/Full&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000baseT/Full&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Supports auto-negotiation: Yes&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Advertised link modes: &amp;nbsp;10baseT/Half 10baseT/Full&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100baseT/Half 100baseT/Full&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000baseT/Full&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Advertised pause frame use: No&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Advertised auto-negotiation: Yes&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Speed: 1000Mb/s&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Duplex: &lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Full&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Port: Twisted Pair&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PHYAD: 2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Transceiver: internal&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Auto-negotiation: on&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MDI-X: off&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Supports Wake-on: pumbg&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Wake-on: g&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Current message level: 0x00000007 (7)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Link detected: yes&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# mii-tool eth0&lt;br /&gt;
eth0: negotiated 100baseTx-FD flow-control, link ok&lt;br /&gt;
&lt;br /&gt;
You can change the ethernet setttings using ethtool -s option&lt;br /&gt;
&lt;br /&gt;
ethtool -s eth0 speed 100 duplex full&lt;br /&gt;
ethtool -s eth0 speed 10 duplex half&lt;br /&gt;
&lt;br /&gt;
OR&lt;br /&gt;
&lt;br /&gt;
mii-tool -F 100baseTx-HD&lt;br /&gt;
mii-tool -F 10baseT-HD&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/7132412870093080015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/7132412870093080015?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/7132412870093080015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/7132412870093080015'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/08/ethtool-display-or-change-ethernet-card.html' title='Ethtool - Display or change ethernet card settings'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-4049014939194746551</id><published>2013-07-11T06:55:00.002-07:00</published><updated>2013-07-11T06:55:41.312-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Start tomcat at the boot time"/><category scheme="http://www.blogger.com/atom/ns#" term="startup script for tomcat."/><title type='text'>Tomcat start up script.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
1.Ensure there is tomcat user and it has read, write permission to the $CATALINA_HOME/conf and $CATALINA_HOME/logs directories.&lt;br /&gt;
&lt;br /&gt;
2. Also make sure that you have set $JAVA_HOME.&lt;br /&gt;
&lt;br /&gt;
3. Ensure that the tomcat processes are ran by the tomcat user.&lt;br /&gt;
&lt;br /&gt;
4. Save the following scripts as /etc/init.d/tomcat. They will automatically be read and run at boot time.&lt;br /&gt;
&lt;br /&gt;
Check the log files if it does not start properly.&lt;br /&gt;
&lt;br /&gt;
Make a soft link to it from /etc/rc5.d such as:&lt;br /&gt;
&lt;br /&gt;
cd /etc/rc5.d&lt;br /&gt;
sudo ln -s /etc//init.d/tomcat S71tomcat&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/tomcat&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
# tomcat &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
#&lt;br /&gt;
# chkconfig:&lt;br /&gt;
# description: &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Start up the Tomcat servlet engine.&lt;br /&gt;
&lt;br /&gt;
# Source function library.&lt;br /&gt;
. /etc/init.d/functions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RETVAL=$?&lt;br /&gt;
CATALINA_HOME=&quot;/usr/local/tomcat/&quot;&lt;br /&gt;
&lt;br /&gt;
case &quot;$1&quot; in&lt;br /&gt;
&amp;nbsp;start)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if [ -f $CATALINA_HOME/bin/startup.sh ];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; then&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;echo $&quot;Starting Tomcat&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /bin/su tomcat $CATALINA_HOME/bin/startup.sh&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fi&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;;;&lt;br /&gt;
&amp;nbsp;stop)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if [ -f $CATALINA_HOME/bin/shutdown.sh ];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; then&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;echo $&quot;Stopping Tomcat&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /bin/su tomcat $CATALINA_HOME/bin/shutdown.sh&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fi&lt;br /&gt;
&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;;;&lt;br /&gt;
&amp;nbsp;*)&lt;br /&gt;
&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo $&quot;Usage: $0 {start|stop}&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;exit 1&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
exit $RETVAL&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inspired from&amp;nbsp;&lt;a href=&quot;http://www.raibledesigns.com/&quot; target=&quot;_blank&quot;&gt;http://www.raibledesigns.com/&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/4049014939194746551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/4049014939194746551?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4049014939194746551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/4049014939194746551'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/07/tomcat-start-up-script.html' title='Tomcat start up script.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-8273135989752120089</id><published>2013-07-08T03:27:00.000-07:00</published><updated>2013-07-08T03:31:32.928-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="-bash: /usr/local/tomcat/bin/startup.sh: Permission denied"/><category scheme="http://www.blogger.com/atom/ns#" term="touch: cannot touch `/usr/local/tomcat/logs/catalina.out&#39;: No such file or directory"/><title type='text'>Apache - Tomcat installation in Linux</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
[root@machine1 ~]# echo $JAVA_HOME&lt;br /&gt;
/usr/local/jdk1.7.0_17&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# wget http://apache.spinellicreations.com/tomcat/tomcat-7/v7.0.41/src/apache-tomcat-7.0.41-src.tar.gz&lt;br /&gt;
--2013-07-06 22:43:04-- &amp;nbsp;http://apache.spinellicreations.com/tomcat/tomcat-7/v7.0.41/src/apache-tomcat-7.0.41-src.tar.gz&lt;br /&gt;
Resolving apache.spinellicreations.com... 72.88.94.11&lt;br /&gt;
Connecting to apache.spinellicreations.com|72.88.94.11|:80... connected.&lt;br /&gt;
HTTP request sent, awaiting response... 200 OK&lt;br /&gt;
Length: 4407748 (4.2M) [application/x-gzip]&lt;br /&gt;
Saving to: “apache-tomcat-7.0.41-src.tar.gz”&lt;br /&gt;
&lt;br /&gt;
100%[====================================================================&amp;gt;] 4,407,748 &amp;nbsp; &amp;nbsp;698K/s &amp;nbsp; in 12s&lt;br /&gt;
&lt;br /&gt;
2013-07-06 22:43:24 (356 KB/s) - “apache-tomcat-7.0.41-src.tar.gz” saved [4407748/4407748]&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# tar -zxvf apache-tomcat-7.0.41-src.tar.gz&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# mv apache-tomcat-7.0.41-src /usr/local/&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# cd /usr/local/&lt;br /&gt;
&lt;br /&gt;
create symbolic link in the name tomcat&lt;br /&gt;
&lt;br /&gt;
[root@machine1 local]# ln -s /usr/local/apache-tomcat-7.0.41-src ./tomcat&lt;br /&gt;
&lt;br /&gt;
Run the following command and add it in .bash_profile.&lt;br /&gt;
&lt;br /&gt;
[root@machine1 local]# export CATALINA_HOME=/usr/local/tomcat&lt;br /&gt;
&lt;br /&gt;
[root@machine1 local]# cd&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# vi .bash_profile&lt;br /&gt;
# User specific environment and startup programs&lt;br /&gt;
&lt;br /&gt;
export JAVA_HOME=/usr/local/jdk1.7.0_17&lt;br /&gt;
&lt;br /&gt;
PATH=/usr/local/jdk1.7.0_17/bin:$PATH:$HOME/bin&lt;br /&gt;
&lt;br /&gt;
export JAVA_HOME&lt;br /&gt;
export CATALINA_HOME=/usr/local/tomcat&lt;br /&gt;
export PATH&lt;br /&gt;
&lt;br /&gt;
save and exit&lt;br /&gt;
&lt;br /&gt;
esnure that you also exported java path.&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# $CATALINA_HOME/bin/startup.sh&lt;br /&gt;
-bash: /usr/local/tomcat/bin/startup.sh: Permission denied&lt;br /&gt;
cd /usr/local/tomcat/bin&lt;br /&gt;
chmod 700 *.sh&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine1 bin]# /usr/local/tomcat/bin/startup.sh&lt;br /&gt;
Using CATALINA_BASE: &amp;nbsp; /usr/local/tomcat&lt;br /&gt;
Using CATALINA_HOME: &amp;nbsp; /usr/local/tomcat&lt;br /&gt;
Using CATALINA_TMPDIR: /usr/local/tomcat/temp&lt;br /&gt;
Using JRE_HOME: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/usr/local/jdk1.7.0_17&lt;br /&gt;
Using CLASSPATH: &amp;nbsp; &amp;nbsp; &amp;nbsp; /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar&lt;br /&gt;
touch: cannot touch `/usr/local/tomcat/logs/catalina.out&#39;: No such file or directory&lt;br /&gt;
/usr/local/tomcat/bin/catalina.sh: line 387: /usr/local/tomcat/logs/catalina.out: No such file or directory&lt;br /&gt;
&lt;br /&gt;
[root@machine1 bin]# mkdir /usr/local/tomcat/logs&lt;br /&gt;
&lt;br /&gt;
The problem is that the archive manager didn&#39;t create the empty logs folder, even though it was listed in the tar file. I guess it doesn&#39;t think empty directories are important. Anyway, just create a logs folder inside the tomcat folder:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; mkdir /usr/local/tomcat/logs&lt;br /&gt;
&lt;br /&gt;
Tomcat should startup now. Another option would be to simply use the command line tools to extract the archive.&lt;br /&gt;
[root@machine1 bin]# export CATALINA_BASE=/usr/local/tomcat/&lt;br /&gt;
&lt;br /&gt;
[root@machine1 bin]# /usr/local/tomcat/bin/startup.sh&lt;br /&gt;
Using CATALINA_BASE: &amp;nbsp; /usr/local/tomcat/&lt;br /&gt;
Using CATALINA_HOME: &amp;nbsp; /usr/local/tomcat&lt;br /&gt;
Using CATALINA_TMPDIR: /usr/local/tomcat//temp&lt;br /&gt;
Using JRE_HOME: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/usr/local/jdk1.7.0_17&lt;br /&gt;
Using CLASSPATH: &amp;nbsp; &amp;nbsp; &amp;nbsp; /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using CLASSPATH: &amp;nbsp; &amp;nbsp; &amp;nbsp; /usr/local/apache-tomcat-6.0.36/bin/bootstrap.jar&lt;br /&gt;
&lt;br /&gt;
[root@machine1 bin]# /etc/init.d/tomcat start&lt;br /&gt;
Starting Tomcat&lt;br /&gt;
Using CATALINA_BASE: &amp;nbsp; /usr/local/tomcat/&lt;br /&gt;
Using CATALINA_HOME: &amp;nbsp; /usr/local/tomcat/&lt;br /&gt;
Using CATALINA_TMPDIR: /usr/local/tomcat//temp&lt;br /&gt;
Using JRE_HOME: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/usr/local/jdk1.7.0_17&lt;br /&gt;
Using CLASSPATH: &amp;nbsp; &amp;nbsp; &amp;nbsp; /usr/local/tomcat//bin/bootstrap.jar&lt;br /&gt;
&lt;br /&gt;
[root@machine1 bin]# /etc/init.d/tomcat stop&lt;br /&gt;
Stopping Tomcat&lt;br /&gt;
Using CATALINA_BASE: &amp;nbsp; /usr/local/tomcat/&lt;br /&gt;
Using CATALINA_HOME: &amp;nbsp; /usr/local/tomcat/&lt;br /&gt;
Using CATALINA_TMPDIR: /usr/local/tomcat//temp&lt;br /&gt;
Using JRE_HOME: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/usr/local/jdk1.7.0_17&lt;br /&gt;
Using CLASSPATH: &amp;nbsp; &amp;nbsp; &amp;nbsp; /usr/local/tomcat//bin/bootstrap.jar&lt;br /&gt;
&lt;br /&gt;
[root@machine1&amp;nbsp;bin]# cat /etc/sysconfig/tomcat&lt;br /&gt;
JAVA_HOME=&quot;/usr/local/jdk1.7.0_17&quot;&lt;br /&gt;
CATALINA_HOME=&quot;/usr/local/tomcat&quot;&lt;br /&gt;
CATALINA_BASE=&quot;/usr/local/tomcat&quot;&lt;br /&gt;
You have new mail in /var/spool/mail/root&lt;br /&gt;
&lt;br /&gt;
add the script in /etc/init.d/tomcat&lt;br /&gt;
&lt;br /&gt;
chmod 755 /etc/init.d/tomcat&lt;br /&gt;
chkconfig --add tomcat&lt;br /&gt;
chkconfig --list tomcat&lt;br /&gt;
&lt;br /&gt;
Type localhost:8080 or your ip address:8080 in your browser to view&lt;br /&gt;
&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgONnps66geJwQ45g2_Jf8To2FdQoqMqVvXogK_2XsxoFv-zg-qangG69oLHVRqgNOz_sHNKKnjE-eEqsVNPrmd1kbg6jfj4PF9WYJUFRL0MCcpS4YcnsSAsVQkrzrjXtSakS6NXBYMTyfN/s1600/managedns5.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgONnps66geJwQ45g2_Jf8To2FdQoqMqVvXogK_2XsxoFv-zg-qangG69oLHVRqgNOz_sHNKKnjE-eEqsVNPrmd1kbg6jfj4PF9WYJUFRL0MCcpS4YcnsSAsVQkrzrjXtSakS6NXBYMTyfN/s320/managedns5.jpeg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/8273135989752120089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/8273135989752120089?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/8273135989752120089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/8273135989752120089'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/07/apache-tomcat-installation-in-linux.html' title='Apache - Tomcat installation in Linux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgONnps66geJwQ45g2_Jf8To2FdQoqMqVvXogK_2XsxoFv-zg-qangG69oLHVRqgNOz_sHNKKnjE-eEqsVNPrmd1kbg6jfj4PF9WYJUFRL0MCcpS4YcnsSAsVQkrzrjXtSakS6NXBYMTyfN/s72-c/managedns5.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-9153706111931699039</id><published>2013-07-08T03:26:00.000-07:00</published><updated>2013-07-08T03:26:24.672-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Install java in linux"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Java Installation in linux.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Check 32 or 64 bit using the below command and download the source accordingly.&lt;br /&gt;
&lt;br /&gt;
[root@machine1 gdp]# getconf LONG_BIT&lt;br /&gt;
32&lt;br /&gt;
[root@machine1 gdp]# wget jdk-7u17-linux-i586.tar.gz&lt;br /&gt;
&lt;br /&gt;
We can download the java software from &lt;a href=&quot;http://www.oracle.com/&quot; target=&quot;_blank&quot;&gt;oracle website&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
[root@machine1 gdp]# tar -zxvf jdk-7u17-linux-i586.tar.gz&lt;br /&gt;
&lt;br /&gt;
Edit your .bash_profile and add the path so that it will automatically load when the machine starts.&lt;br /&gt;
.bash_profile&lt;br /&gt;
&lt;br /&gt;
export JAVA_HOME=/usr/local/gdp/jdk1.7.0_17&lt;br /&gt;
export PATH=$PATH:$JAVA_HOME/bin&lt;br /&gt;
export PATH&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# /usr/local/gdp/jdk1.7.0_17/bin/java -version&lt;br /&gt;
java version &quot;1.7.0_17&quot;&lt;br /&gt;
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)&lt;br /&gt;
Java HotSpot(TM) Server VM (build 23.7-b01, mixed mode)&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# source .bash_profile&lt;br /&gt;
You have new mail in /var/spool/mail/root&lt;br /&gt;
&lt;br /&gt;
[root@machine1 ~]# java -version&lt;br /&gt;
java version &quot;1.7.0_19&quot;&lt;br /&gt;
OpenJDK Runtime Environment (rhel-2.3.9.1.el5_9-i386)&lt;br /&gt;
OpenJDK Server VM (build 23.7-b01, mixed mode)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/9153706111931699039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/9153706111931699039?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/9153706111931699039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/9153706111931699039'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/07/java-installation-in-linux.html' title='Java Installation in linux.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-5860198299045426014</id><published>2013-07-03T23:13:00.000-07:00</published><updated>2013-07-03T23:18:37.003-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Mysql hardening in Linux."/><category scheme="http://www.blogger.com/atom/ns#" term="tune mysql"/><title type='text'>Mysql hardening in Linux.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
1. &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Disable or restrict remote access&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Consider whether MySQL will be accessed from the network or only from its own server.&lt;br /&gt;
&lt;br /&gt;
If remote access is used, ensure that only defined hosts can access the server. This is typically done through TCP wrappers, iptables, or any other firewall software or hardware available on the market.&lt;br /&gt;
&lt;br /&gt;
To restrict MySQL from opening a network socket, the following parameter should be added in the [mysqld] section of my.cnf or my.ini:&lt;br /&gt;
&lt;br /&gt;
skip-networking&lt;br /&gt;
&lt;br /&gt;
The file is located in the &amp;nbsp;&quot;/etc/my.cnf&quot; or &quot;/etc/mysql/my.cnf&quot; on Linux.&lt;br /&gt;
&lt;br /&gt;
This line disables the initiation of networking during MySQL startup. Please note that a local connection can still be established to the MySQL server.&lt;br /&gt;
&lt;br /&gt;
Another possible solution is to force MySQL to listen only to the localhost by adding the following line in the [mysqld] section of my.cnf&lt;br /&gt;
&lt;br /&gt;
bind-address=127.0.0.1&lt;br /&gt;
&lt;br /&gt;
You may not be willing to disable network access to your database server if users in your organization connect to the server from their machines or the web server installed on a different machine. In that case, the following restrictive grant syntax should be considered:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; GRANT SELECT, INSERT ON mydb.* TO &#39;someuser&#39;@&#39;somehost&#39;;&lt;br /&gt;
&lt;br /&gt;
2. &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Disable the use of LOCAL INFILE&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The next change is to disable the use of the &quot;LOAD DATA LOCAL INFILE&quot; command, which will help to prevent unauthorized reading from local files. This is especially important when new SQL Injection vulnerabilities in PHP applications are found.&lt;br /&gt;
&lt;br /&gt;
In addition, in certain cases, the &quot;LOCAL INFILE&quot; command can be used to gain access to other files on the operating system, for instance &quot;/etc/passwd&quot;, using the following command:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; LOAD DATA LOCAL INFILE &#39;/etc/passwd&#39; INTO TABLE table1&lt;br /&gt;
&lt;br /&gt;
Or even simpler:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; SELECT load_file(&quot;/etc/passwd&quot;)&lt;br /&gt;
&lt;br /&gt;
To disable the usage of the &quot;LOCAL INFILE&quot; command, the following parameter should be added in the [mysqld] section of the MySQL configuration file.&lt;br /&gt;
&lt;br /&gt;
set-variable=local-infile=0&lt;br /&gt;
&lt;br /&gt;
3.&amp;nbsp;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Change root username and password&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The default administrator username on the MySQL server is &quot;root&quot;. Hackers often attempt to gain access to its permissions. To make this task harder, rename &quot;root&quot; to something else and provide it with a long, complex alphanumeric password.&lt;br /&gt;
&lt;br /&gt;
To rename the administrator’s username, use the rename command in the MySQL console:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; RENAME USER root TO new_user;&lt;br /&gt;
&lt;br /&gt;
The MySQL &quot;RENAME USER&quot; command first appeared in MySQL version 5.0.2. If you use an older version of MySQL, you can use other commands to rename a user:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; use mysql;&lt;br /&gt;
mysql&amp;gt; update user set user=&quot;new_user&quot; where user=&quot;root&quot;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&lt;br /&gt;
To change a user’s password, use the following command-line command:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; SET PASSWORD FOR &#39;username&#39;@&#39;%hostname&#39; = PASSWORD(&#39;newpass&#39;);&lt;br /&gt;
&lt;br /&gt;
It is also possible to change the password using the &quot;mysqladmin&quot; utility:&lt;br /&gt;
&lt;br /&gt;
shell&amp;gt; mysqladmin -u username -p password newpass&lt;br /&gt;
&lt;br /&gt;
4. &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Remove the &quot;test&quot; database&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
MySQL comes with a &quot;test&quot; database intended as a test space. It can be accessed by the anonymous user, and is therefore used by numerous attacks.&lt;br /&gt;
&lt;br /&gt;
To remove this database, use the drop command as follows:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; drop database test;&lt;br /&gt;
&lt;br /&gt;
Or use the &quot;mysqladmin&quot; command:&lt;br /&gt;
&lt;br /&gt;
shell&amp;gt; mysqladmin -u username -p drop test&lt;br /&gt;
&lt;br /&gt;
5. &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Remove Anonymous and obsolete accounts&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The MySQL database comes with some anonymous users with blank passwords. As a result, anyone can connect to the database To check whether this is the case, do the following:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; select * from mysql.user where user=&quot;&quot;;&lt;br /&gt;
&lt;br /&gt;
In a secure system, no lines should be echoed back. Another way to do the same:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; SHOW GRANTS FOR &#39;&#39;@&#39;localhost&#39;;&lt;br /&gt;
mysql&amp;gt; SHOW GRANTS FOR &#39;&#39;@&#39;myhost&#39;;&lt;br /&gt;
&lt;br /&gt;
If the grants exist, then anybody can access the database and at least use the default database &quot;test&quot;. Check this with:&lt;br /&gt;
&lt;br /&gt;
shell&amp;gt; mysql -u blablabla&lt;br /&gt;
&lt;br /&gt;
To remove the account, execute the following command:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; DROP USER &quot;&quot;;&lt;br /&gt;
&lt;br /&gt;
The MySQL &quot;DROP USER&quot; command is supported starting with MySQL version 5.0. If you use an older version of MySQL, you can remove the account as follows:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; use mysql;&lt;br /&gt;
mysql&amp;gt; DELETE FROM user WHERE user=&quot;&quot;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&lt;br /&gt;
6. &lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Lower system privileges&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
A very common database security recommendation is to lower the permissions given to various parties. MySQL is no different. Typically, when developers work, they use the system&#39;s maximum permission and give less consideration to permission principles than we might expect. This practice can expose the database to significant risk.&lt;br /&gt;
&lt;br /&gt;
* Any new MySQL 5.x installation already installed using the correct security measures.&lt;br /&gt;
&lt;br /&gt;
To protect your database, make sure that the file directory in which the MySQL database is actually stored is owned by the user &quot;mysql&quot; and the group &quot;mysql&quot;.&lt;br /&gt;
&lt;br /&gt;
shell&amp;gt;ls -l /var/lib/mysql&lt;br /&gt;
&lt;br /&gt;
In addition, ensure that only the user &quot;mysql&quot; and &quot;root&quot; have access to the directory /var/lib/mysql.&lt;br /&gt;
&lt;br /&gt;
The mysql binaries, which reside under the /usr/bin/ directory, should be owned by &quot;root&quot; or the specific system &quot;mysql&quot; user. Other users should not have write access to these files.&lt;br /&gt;
&lt;br /&gt;
shell&amp;gt;ls -l /usr/bin/my*&lt;br /&gt;
&lt;br /&gt;
7. &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Lower database privileges&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Operating system permissions were fixed in the preceding section. Now let’s talk about database permissions. In most cases, there is an administrator user (the renamed &quot;root&quot;) and one or more actual users who coexist in the database. Usually, the &quot;root&quot; has nothing to do with the data in the database; instead, it is used to maintain the server and its tables, to give and revoke permissions, etc.&lt;br /&gt;
&lt;br /&gt;
On the other hand, some user ids are used to access the data, such as the user id assigned to the web server to execute &quot;select\update\insert\delete&quot; queries and to execute stored procedures. In most cases, no other users are necessary; however, only you, as a system administrator can really know your application’s needs.&lt;br /&gt;
&lt;br /&gt;
Only administrator accounts need to be granted the SUPER / PROCESS /FILE privileges and access to the mysql database. Usually, it is a good idea to lower the administrator’s permissions for accessing the data.&lt;br /&gt;
&lt;br /&gt;
Review the privileges of the rest of the users and ensure that these are set appropriately. This can be done using the following steps.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; use mysql;&lt;br /&gt;
&lt;br /&gt;
[Identify users]&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; select * from users;&lt;br /&gt;
&lt;br /&gt;
[List grants of all users]&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; show grants for ‘root’@’localhost’;&lt;br /&gt;
&lt;br /&gt;
The above statement has to be executed for each user ! Note that only users who really need root privileges should be granted them.&lt;br /&gt;
&lt;br /&gt;
Another interesting privilege is &quot;SHOW DATABASES&quot;. By default, the command can be used by everyone having access to the MySQL prompt. They can use it to gather information (e.g., getting database names) before attacking the database by, for instance, stealing the data. To prevent this, it is recommended that you follow the procedures described below.&lt;br /&gt;
&lt;br /&gt;
Add &quot; &lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;--skip-show-database&lt;/b&gt;&lt;/span&gt;&quot; to the startup script of MySQL or add it to the MySQL configuration file&lt;br /&gt;
Grant the SHOW DATABASES privilege only to the users you want to use this command&lt;br /&gt;
To disable the usage of the &quot;SHOW DATABASES&quot; command, the following parameter should be added in the [mysqld] section of the /etc/my.cnf:&lt;br /&gt;
&lt;br /&gt;
[mysqld]&lt;br /&gt;
skip-show-database&lt;br /&gt;
&lt;br /&gt;
8.&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt; Enable Logging&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
If your database server does not execute many queries, it is recommended that you enable transaction logging, by adding the following line to [mysqld] section of the /etc/my.cnf file:&lt;br /&gt;
&lt;br /&gt;
[mysqld]&lt;br /&gt;
log =/var/log/mylogfile&lt;br /&gt;
&lt;br /&gt;
This is not recommended for heavy production MySQL servers because it causes high overhead on the server.&lt;br /&gt;
&lt;br /&gt;
In addition, verify that only the &quot;root&quot; and &quot;mysql&quot; ids have access to these logfiles (at least write access).&lt;br /&gt;
&lt;br /&gt;
Error log&lt;br /&gt;
&lt;br /&gt;
Ensure only &quot;root&quot; and &quot;mysql&quot; have access to the logfile &quot;hostname.err&quot;. The file is stored in the mysql data directory. This file contains very sensitive information such as passwords, addresses, table names, stored procedure names and code parts. It can be used for information gathering, and in some cases, can provide the attacker with the information needed to exploit the database, the machine on which the database is installed, or the data inside it.&lt;br /&gt;
&lt;br /&gt;
MySQL log&lt;br /&gt;
&lt;br /&gt;
Ensure only &quot;root&quot; and &quot;mysql&quot; have access to the logfile &quot;*logfileXY&quot;. The file is stored in the mysql data directory.&lt;br /&gt;
&lt;br /&gt;
9. &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Change the root directory&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
A chroot on Linux operating systems is an operation that changes the apparent disk root directory for the current running process and its children. A program that is re-rooted to another directory cannot access or name files outside that directory, and the directory is called a &quot;chroot jail&quot; or (less commonly) a &quot;chroot prison&quot;.&lt;br /&gt;
&lt;br /&gt;
By using the chroot environment, the write access of the MYSQL processes (and child processes) can be limited, increasing the security of the server.&lt;br /&gt;
&lt;br /&gt;
Ensure that a dedicated directory exists for the chrooted environment. This should be something like: /chroot/mysql In addition, to make the use of the database administrative tools convenient, the following parameter should be changed in the [client] section of MySQL configuration file:&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
socket = /chroot/mysql/tmp/mysql.sock&lt;br /&gt;
&lt;br /&gt;
Thanks to that line of code, there will be no need to supply the mysql, mysqladmin, mysqldump etc. commands with the --socket=/chroot/mysql/tmp/mysql.sock parameter every time these tools are run.&lt;br /&gt;
&lt;br /&gt;
10. &lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Remove History&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
During the installation procedures, there is a lot of sensitive information that can assist an intruder to assault a database. This information is stored in the server’s history and can be very helpful if something goes wrong during the installation. By analyzing the history files, administrators can figure out what has gone wrong and probably fix things up. However, these files are not needed after installation is complete.&lt;br /&gt;
&lt;br /&gt;
We should remove the content of the MySQL history file (~/.mysql_history), where all executed SQL commands are stored (especially passwords, which are stored as plain text):&lt;br /&gt;
&lt;br /&gt;
cat /dev/null &amp;gt; ~/.mysql_history&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
or mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;NOTE&lt;/span&gt;&lt;/b&gt;: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; SERVERS IN PRODUCTION USE! &amp;nbsp;PLEASE READ EACH STEP CAREFULLY!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In order to log into MySQL to secure it, we&#39;ll need the current&lt;br /&gt;
password for the root user. &amp;nbsp;If you&#39;ve just installed MySQL, and&lt;br /&gt;
you haven&#39;t set the root password yet, the password will be blank,&lt;br /&gt;
so you should just press enter here.&lt;br /&gt;
&lt;br /&gt;
Enter current password for root (enter for none):&lt;br /&gt;
OK, successfully used password, moving on...&lt;br /&gt;
&lt;br /&gt;
Setting the root password ensures that nobody can log into the MySQL&lt;br /&gt;
root user without the proper authorisation.&lt;br /&gt;
&lt;br /&gt;
Set root password? [Y/n] n&lt;br /&gt;
&amp;nbsp;... skipping.&lt;br /&gt;
&lt;br /&gt;
By default, a MySQL installation has an anonymous user, allowing anyone&lt;br /&gt;
to log into MySQL without having to have a user account created for&lt;br /&gt;
them. &amp;nbsp;This is intended only for testing, and to make the installation&lt;br /&gt;
go a bit smoother. &amp;nbsp;You should remove them before moving into a&lt;br /&gt;
production environment.&lt;br /&gt;
&lt;br /&gt;
Remove anonymous users? [Y/n] y&lt;br /&gt;
&amp;nbsp;... Success!&lt;br /&gt;
&lt;br /&gt;
Normally, root should only be allowed to connect from &#39;localhost&#39;. &amp;nbsp;This&lt;br /&gt;
ensures that someone cannot guess at the root password from the network.&lt;br /&gt;
&lt;br /&gt;
Disallow root login remotely? [Y/n] y&lt;br /&gt;
&amp;nbsp;... Success!&lt;br /&gt;
&lt;br /&gt;
By default, MySQL comes with a database named &#39;test&#39; that anyone can&lt;br /&gt;
access. &amp;nbsp;This is also intended only for testing, and should be removed&lt;br /&gt;
before moving into a production environment.&lt;br /&gt;
&lt;br /&gt;
Remove test database and access to it? [Y/n] y&lt;br /&gt;
&amp;nbsp;- Dropping test database...&lt;br /&gt;
&amp;nbsp;... Success!&lt;br /&gt;
&amp;nbsp;- Removing privileges on test database...&lt;br /&gt;
&amp;nbsp;... Success!&lt;br /&gt;
&lt;br /&gt;
Reloading the privilege tables will ensure that all changes made so far&lt;br /&gt;
will take effect immediately.&lt;br /&gt;
&lt;br /&gt;
Reload privilege tables now? [Y/n] y&lt;br /&gt;
&amp;nbsp;... Success!&lt;br /&gt;
&lt;br /&gt;
Cleaning up...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All done! &amp;nbsp;If you&#39;ve completed all of the above steps, your MySQL&lt;br /&gt;
installation should now be secure.&lt;br /&gt;
&lt;br /&gt;
Thanks for using MySQL!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/5860198299045426014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/5860198299045426014?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/5860198299045426014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/5860198299045426014'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/07/mysql-hardening-in-linux.html' title='Mysql hardening in Linux.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-5114340541547918725</id><published>2013-07-03T00:18:00.003-07:00</published><updated>2013-07-03T00:19:33.514-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="/usr/bin/ld: cannot find"/><title type='text'>/usr/bin/ld: cannot find -lpython2.7</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
/usr/bin/ld: cannot find -lpython2.7&lt;br /&gt;
collect2: ld returned 1 exit status&lt;br /&gt;
&lt;br /&gt;
[root@server1 lib]# ln -s /usr/local/python2.7.3/lib/python2.7/config/libpython2.7.a .&lt;br /&gt;
&lt;br /&gt;
[root@server1 lib]# pwd&lt;br /&gt;
/usr/lib&lt;br /&gt;
rwxrwxrwx &amp;nbsp; 1 root root &amp;nbsp; 58 Jun 27 11:55 libpython2.7.a -&amp;gt; /usr/local/python2.7.3/lib/python2.7/config/libpython2.7.a&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/5114340541547918725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/5114340541547918725?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/5114340541547918725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/5114340541547918725'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/07/usrbinld-cannot-find-lpython27.html' title='/usr/bin/ld: cannot find -lpython2.7'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6288032787085179957.post-8743513324664930316</id><published>2013-07-03T00:15:00.000-07:00</published><updated>2013-07-03T00:16:47.590-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ntp error"/><category scheme="http://www.blogger.com/atom/ns#" term="ntpd dead but pid file exists"/><category scheme="http://www.blogger.com/atom/ns#" term="ntpq: read: Connection refused"/><title type='text'>NTP error - ntpd dead but pid file exists</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
[root@server1~]# ntpq -np&lt;br /&gt;
ntpq: read: Connection refused&lt;br /&gt;
&lt;br /&gt;
[root@server1 ~]# /etc/init.d/ntpd status&lt;br /&gt;
ntpd dead but pid file exists&lt;br /&gt;
&lt;br /&gt;
[root@server1~]# cat /etc/sysconfig/ntpd&lt;br /&gt;
# Drop root to id &#39;ntp:ntp&#39; by default.&lt;br /&gt;
OPTIONS=&quot;-u ntp:ntp -p /var/run/ntpd.pid&quot;&lt;br /&gt;
&lt;br /&gt;
# Set to &#39;yes&#39; to sync hw clock after successful ntpdate&lt;br /&gt;
SYNC_HWCLOCK=no&lt;br /&gt;
&lt;br /&gt;
# Additional options for ntpdate&lt;br /&gt;
NTPDATE_OPTIONS=&quot;&quot;&lt;br /&gt;
&lt;br /&gt;
Edit the configuration file and change the contents like below&lt;br /&gt;
[root@server1 ~]# vi /etc/sysconfig/ntpd&lt;br /&gt;
&lt;br /&gt;
[root@server1~]# cat /etc/sysconfig/ntpd&lt;br /&gt;
# Drop root to id &#39;ntp:ntp&#39; by default.&lt;br /&gt;
#OPTIONS=&quot;-u ntp:ntp -p /var/run/ntpd.pid&quot;&lt;br /&gt;
&lt;br /&gt;
# Set to &#39;yes&#39; to sync hw clock after successful ntpdate&lt;br /&gt;
SYNC_HWCLOCK=no&lt;br /&gt;
&lt;br /&gt;
# Additional options for ntpdate&lt;br /&gt;
NTPDATE_OPTIONS=&quot;&quot;&lt;br /&gt;
&lt;br /&gt;
etc/init.d/ntpd restart&lt;br /&gt;
Shutting down ntpd: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[FAILED]&lt;br /&gt;
Starting ntpd: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ &amp;nbsp;OK &amp;nbsp;]&lt;br /&gt;
[root@server1 ~]# /etc/init.d/ntpd restart&lt;br /&gt;
Shutting down ntpd: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[ &amp;nbsp;OK &amp;nbsp;]&lt;br /&gt;
Starting ntpd: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
[root@server1~]# ntpdate -u pool.ntp.org&lt;br /&gt;
13 Jun 09:16:22 ntpdate[24783]: adjust time server 69.167.160.102 offset -0.064985 sec&lt;br /&gt;
&lt;br /&gt;
[root@server1 ~]# /etc/init.d/ntpd restart&lt;br /&gt;
Shutting down ntpd: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[ &amp;nbsp;OK &amp;nbsp;]&lt;br /&gt;
Starting ntpd: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [ &amp;nbsp;OK &amp;nbsp;]&lt;br /&gt;
[root@server1 ~]# ntpq -np&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;remote &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; refid &amp;nbsp; &amp;nbsp; &amp;nbsp;st t when poll reach &amp;nbsp; delay &amp;nbsp; offset &amp;nbsp;jitter&lt;br /&gt;
==============================================================================&lt;br /&gt;
&amp;nbsp;72.14.183.239 &amp;nbsp; 216.218.254.202 &amp;nbsp;2 u &amp;nbsp; &amp;nbsp;3 &amp;nbsp; 64 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp;0.001 &amp;nbsp;-38.576 &amp;nbsp; 0.001&lt;br /&gt;
&amp;nbsp;72.14.183.39 &amp;nbsp; &amp;nbsp;164.244.221.197 &amp;nbsp;2 u &amp;nbsp; &amp;nbsp;2 &amp;nbsp; 64 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp;0.001 &amp;nbsp;-37.146 &amp;nbsp; 0.001&lt;br /&gt;
&amp;nbsp;65.49.70.244 &amp;nbsp; &amp;nbsp;127.67.113.92 &amp;nbsp; &amp;nbsp;2 u &amp;nbsp; &amp;nbsp;1 &amp;nbsp; 64 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp;0.001 &amp;nbsp; &amp;nbsp;2.791 &amp;nbsp; 0.001&lt;br /&gt;
&amp;nbsp;127.127.1.0 &amp;nbsp; &amp;nbsp; .LOCL. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10 l &amp;nbsp; &amp;nbsp;- &amp;nbsp; 64 &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp;0.000 &amp;nbsp; &amp;nbsp;0.000 &amp;nbsp; 0.001&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;http://feeds.feedburner.com/ImBeginningToThinkLinuxReally&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://linkwithlinux.blogspot.com/feeds/8743513324664930316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6288032787085179957/8743513324664930316?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/8743513324664930316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6288032787085179957/posts/default/8743513324664930316'/><link rel='alternate' type='text/html' href='http://linkwithlinux.blogspot.com/2013/07/ntp-error.html' title='NTP error - ntpd dead but pid file exists'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/04741388442730017259</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>