<?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: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-4355373626380715957</id><updated>2011-07-29T00:15:33.380-07:00</updated><category term='PATH'/><category term='arguments'/><category term='for loop'/><category term='redirects'/><category term='mv'/><category term='foreground'/><category term='concatenate file'/><category term='command prompt'/><category term='deleting files and directories'/><category term='info'/><category term='process id'/><category term='aliases'/><category term='set'/><category term='relational operators'/><category term='Thompson'/><category term='expr'/><category term='searching'/><category term='current directory'/><category term='top'/><category term='piping'/><category term='vim'/><category term='bzip'/><category term='reading from keyboard'/><category term='.gz'/><category term='variables'/><category term='compress'/><category term='backup'/><category term='sort'/><category term='shell scripting'/><category term='Dennis Ritchie'/><category term='home directory'/><category term='appending file'/><category term='cd'/><category term='mkdir'/><category term='pwd'/><category term='output'/><category term='echo'/><category term='I/O'/><category term='ATT'/><category term='substring'/><category term='pid'/><category term='changing prompt'/><category term='prompt string'/><category term='.bashrc'/><category term='Bash'/><category term='cat'/><category term='table of contents'/><category term='tree'/><category term='nice'/><category term='ls'/><category term='.bash_profile'/><category term='?'/><category term='extract'/><category term='list'/><category term='Ken Thompson'/><category term='arithmetic operators'/><category term='shell example'/><category term='rm'/><category term='.bash'/><category term='bash shell scripting'/><category term='Linux table of contents'/><category term='gzip'/><category term='kill'/><category term='help'/><category term='input output'/><category term='editing files'/><category term='.bz2'/><category term='processes'/><category term='locate'/><category term='find'/><category term='commands'/><category term='*'/><category term='shell'/><category term='finding files'/><category term='background'/><category term='chmod'/><category term='linux'/><category term='man'/><category term='append'/><category term='PS1'/><category term='vi'/><category term='whereis'/><category term='tutorial'/><category term='files'/><category term='environmental variables'/><category term='file permissions'/><category term='create'/><category term='linux commands'/><category term='options'/><category term='tar'/><category term='file name globbing'/><category term='rmdir'/><category term='redirection'/><category term='unix'/><category term='nodes'/><category term='history'/><category term='command line arguments'/><category term='MYNAME'/><category term='less'/><category term='man pages'/><category term='if statements'/><title type='text'>Learning Linux</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>37</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-5382204568780400454</id><published>2009-10-16T10:56:00.001-07:00</published><updated>2010-09-06T01:01:22.102-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='cd'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><title type='text'>Linux - Changing Directories with the 'cd' Command</title><content type='html'>&lt;style&gt;&lt;!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}h1 {mso-style-link:"Heading 1 Char"; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:115%; page-break-after:avoid; font-size:10.0pt; font-family:"Cambria","serif"; color:#365F91;}a:link, span.MsoHyperlink {color:blue; text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-link:"Heading 1"; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst {mso-style-name:msolistparagraphcxspfirst; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle {mso-style-name:msolistparagraphcxspmiddle; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast {mso-style-name:msolistparagraphcxsplast; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1 {mso-style-name:webH1; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:18.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH2, li.webH2, div.webH2 {mso-style-name:webH2; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:15.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH3, li.webH3, div.webH3 {mso-style-name:webH3; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:13.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH4, li.webH4, div.webH4 {mso-style-name:webH4; margin:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:11.0pt; font-family:"Cambria","serif"; color:#048207; font-weight:bold; font-style:italic;}span.CodeingChar {mso-style-name:"Codeing Char"; mso-style-link:Codeing; font-family:"Courier New"; color:#C00000;}p.Codeing, li.Codeing, div.Codeing {mso-style-name:Codeing; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst {mso-style-name:CodeingCxSpFirst; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle {mso-style-name:CodeingCxSpMiddle; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast {mso-style-name:CodeingCxSpLast; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst {mso-style-name:CodeingCxSpFirst; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle {mso-style-name:CodeingCxSpMiddle; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast {mso-style-name:CodeingCxSpLast; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.Links, li.Links, div.Links {mso-style-name:Links; margin:0in; margin-bottom:.0001pt; text-align:center; font-size:11.0pt; font-family:"Calibri","sans-serif"; font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault {mso-style-name:msopapdefault; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:12.0pt; font-family:"Times New Roman","serif";}.MsoChpDefault {font-size:10.0pt;}.MsoPapDefault {margin-bottom:10.0pt; line-height:115%;}@page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;}div.Section1 {page:Section1;} /* List Definitions */ ol {margin-bottom:0in;}ul {margin-bottom:0in;}--&gt;&lt;/style&gt;&lt;br /&gt;&lt;div class="Section1"&gt;&lt;div class="webH1"&gt;Linux – Changing Directories with ‘cd’ Command&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Changing directories is likely the second most commoncommand in Linux aside from ‘ls’. Using the ‘cd’ command, you can change yourcurrent working directory.&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Recall the ‘pwd’ command prints your current workingdirectory.&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Also, it is important that you understand the use of thefollowing,&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraph" style="margin-bottom: 0.0001pt; text-indent: -0.25in;"&gt;&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;‘..’- Parent directory&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraph" style="margin-bottom: 0.0001pt; text-indent: -0.25in;"&gt;&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;‘.’- Current directory&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraph" style="margin-bottom: 0.0001pt; text-indent: -0.25in;"&gt;&lt;span style="font-family: Symbol;"&gt;·&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;; font-size-adjust: none; font-size: 7pt; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;‘~’- Home directory&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoListParagraph" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="webH4"&gt;Examples&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Change to your home directory using ‘cd’,&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpFirst"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;/home/fred/folder1&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;&lt;b&gt;$ cd&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpLast"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;You can also use ‘cd ~’ to change to your home directory,&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpFirst"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;/home/fred/folder1&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;&lt;b&gt;$ cd ~&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;/home/fred&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpLast"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Change to a subdirectory,&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpFirst"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;/home/fred&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;&lt;b&gt;$ cd folder1/myfiles&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpLast"&gt;/home/fred/folder1/myfiles&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;The above cd command is the same as ‘$ cd ./folder1/myfiles’, however the ‘./’ is notnecessary.&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Change to the parent directory using ‘cd ..’,&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpFirst"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;/home/fred/folder1/myfiles&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;&lt;b&gt;$ cd ..&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;/home/fred/folder1&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpLast"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Change to a directory in the parent directory,&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpFirst"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;/home/fred/folder1&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;&lt;b&gt;$ cd ../folder2&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;/home/fred/folder2&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;link href="file:///C:%5CUsers%5CJames%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml" rel="File-List"&gt;&lt;/link&gt;&lt;link href="file:///C:%5CUsers%5CJames%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx" rel="themeData"&gt;&lt;/link&gt;&lt;link href="file:///C:%5CUsers%5CJames%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml" rel="colorSchemeMapping"&gt;&lt;/link&gt;   &lt;m:smallfrac m:val="off"&gt;   &lt;m:dispdef&gt;   &lt;m:lmargin m:val="0"&gt;   &lt;m:rmargin m:val="0"&gt;   &lt;m:defjc m:val="centerGroup"&gt;   &lt;m:wrapindent m:val="1440"&gt;   &lt;m:intlim m:val="subSup"&gt;   &lt;m:narylim m:val="undOvr"&gt;  &lt;/m:narylim&gt;&lt;/m:intlim&gt;&lt;/m:wrapindent&gt;&lt;style&gt;&lt;!-- /* Font Definitions */ @font-face	{font-family:"Cambria Math";	panose-1:2 4 5 3 5 4 6 3 2 4;	mso-font-charset:1;	mso-generic-font-family:roman;	mso-font-format:other;	mso-font-pitch:variable;	mso-font-signature:0 0 0 0 0 0;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;	mso-font-charset:0;	mso-generic-font-family:swiss;	mso-font-pitch:variable;	mso-font-signature:-520092929 1073786111 9 0 415 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{mso-style-unhide:no;	mso-style-qformat:yes;	mso-style-parent:"";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	mso-pagination:widow-orphan;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	mso-fareast-font-family:"Times New Roman";	mso-fareast-theme-font:minor-fareast;}p.Links, li.Links, div.Links	{mso-style-name:Links;	mso-style-unhide:no;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	mso-pagination:widow-orphan;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	mso-fareast-font-family:"Times New Roman";	mso-fareast-theme-font:minor-fareast;	font-weight:bold;}.MsoChpDefault	{mso-style-type:export-only;	mso-default-props:yes;	font-size:10.0pt;	mso-ansi-font-size:10.0pt;	mso-bidi-font-size:10.0pt;}.MsoPapDefault	{mso-style-type:export-only;	margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;	mso-header-margin:.5in;	mso-footer-margin:.5in;	mso-paper-source:0;}div.Section1	{page:Section1;}--&gt;&lt;/style&gt;&lt;/m:defjc&gt;&lt;/m:rmargin&gt;&lt;/m:lmargin&gt;&lt;/m:dispdef&gt;&lt;/m:smallfrac&gt;&lt;br /&gt;&lt;div class="Links"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-1.html"&gt;&lt;span style="color: blue;"&gt;Linux Commands - Viewing the Current Directory 'pwd' and'ls'&lt;/span&gt;&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/finding-file-in-linux.html"&gt;&lt;span style="color: blue;"&gt;Linux - Finding A File&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpLast"&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-5382204568780400454?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/5382204568780400454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-changing-directories.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5382204568780400454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5382204568780400454'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-changing-directories.html' title='Linux - Changing Directories with the &apos;cd&apos; Command'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-7209914993999313407</id><published>2009-10-11T02:46:00.000-07:00</published><updated>2010-09-06T01:01:22.108-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='chmod'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='file permissions'/><title type='text'>Linux - File Permissions and the 'chmod' Command</title><content type='html'>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face	{font-family:"Cambria Math";	panose-1:0 0 0 0 0 0 0 0 0 0;}@font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;}--&gt;&lt;/style&gt; &lt;/head&gt; &lt;body lang=EN-US link=blue vlink=purple&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux – File Permissions and the ‘chmod’ Command&lt;/p&gt; &lt;p class=MsoNormal&gt;Linux was designed to be a multi-user operating system. Sothere must be a way to limit who has access to what files, and how much access.&lt;br&gt;&lt;br&gt;There are three sets of users in linux,&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;User&lt;/b&gt;-this is an individual, such as yourself, that has logincredentials to the system. Each user has their own home directory where theyhave full access to the files.&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Group&lt;/b&gt;-this is a set of multiple users. A group is typicallycreated by the system admin. For instance, at a university, there could be agroup setup for each course, where the professor is the group leader, andstudents are group members.&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Other&lt;/b&gt;-this refers to individuals that are not the user and not inthe group being discussed.&lt;/p&gt; &lt;p class=MsoNormal&gt;Linux uses file permission attributes to set who has accessto what files. Type in '&lt;span class=CodeingChar&gt;ls -l&lt;/span&gt;' in any directorywith at least one file in it. This will show you all the information about eachfile/directory.&lt;/p&gt; &lt;p class=Codeing&gt;&lt;b&gt;&lt;span style='font-family:"Times New Roman","serif"'&gt;$ &lt;/span&gt;ls-l&lt;/b&gt;&amp;nbsp;&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;drwxr-x--- 1 jdoe jane 4096 Dec 28 04:09 tmp&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;-rw-r--r-- 1 jdoe jdoe 969 Dec 21 02:32 foo&lt;span style='font-family:"Times New Roman","serif"'&gt; &lt;/span&gt;&lt;/p&gt; &lt;table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 style='margin-left:8.6pt;border-collapse:collapse'&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;Column&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;Value&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;Meaning&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;1&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;drwxr-x---&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;File Permissions&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;2&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;1&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Forget this one!&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;3&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Jdoe&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Owner&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;4&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Jane&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Group owner&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;5&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;4096&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Size in bytes&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;6&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Dec&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Last Modified Month&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;7&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;28&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Last Modified Day&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;8&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;04:09&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Last Modified Time&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=69 valign=top style='width:51.5pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;9&lt;/p&gt;  &lt;/td&gt;  &lt;td width=84 valign=top style='width:62.85pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;tmp&lt;/p&gt;  &lt;/td&gt;  &lt;td width=150 valign=top style='width:112.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;File Name&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt; &lt;p class=webH3&gt;File Permission Attribute&lt;/p&gt; &lt;p class=MsoNormal&gt;Let's break down the 10 character &lt;b&gt;file permissionattribute &lt;/b&gt;in Column 1:&lt;/p&gt; &lt;table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 style='margin-left:8.6pt;border-collapse:collapse'&gt; &lt;tr&gt;  &lt;td width=63 valign=top style='width:47.6pt;border:solid black 1.0pt;  background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;Special&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=49 valign=top style='width:36.95pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;User&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=59 valign=top style='width:44.45pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;Group&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=55 valign=top style='width:40.9pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;other&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=63 valign=top style='width:47.6pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;-&lt;/p&gt;  &lt;/td&gt;  &lt;td width=49 valign=top style='width:36.95pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;---&lt;/p&gt;  &lt;/td&gt;  &lt;td width=59 valign=top style='width:44.45pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;---&lt;/p&gt;  &lt;/td&gt;  &lt;td width=55 valign=top style='width:40.9pt;border-top:none;border-left:none;  border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;  text-align:center;line-height:normal'&gt;---&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Special attribute&lt;/b&gt;- This is blank(-) for normal files, but it isset to d for directories. This can be other letters for other devices etc, butdo not worry about that now.&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;'&lt;b&gt;user&lt;/b&gt;' &lt;b&gt;permission&lt;/b&gt;- The user refers to the person who ownsthe file. So if you own the file, these characters apply to you.&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;'&lt;b&gt;group&lt;/b&gt;' &lt;b&gt;permissions&lt;/b&gt;- These apply to any user who is in thegroup owned by the group owner.&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;'&lt;b&gt;other&lt;/b&gt;' &lt;b&gt;permissions&lt;/b&gt;- These apply to any one who is not theowner, and who is not in the group owned by the group owner.&lt;/p&gt; &lt;p class=webH3&gt;Read, Write and Execute&lt;/p&gt; &lt;p class=MsoNormal&gt;The user, group, and other permissions can have read(r),write(w), and or execute(x) permissions. The order of the permissions is 'rwx'for each permission set. Each permission attribute can either be on(r,w, or x)or off(-).&lt;br&gt;&lt;br&gt;What does read, write and execute mean?&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Read(r)&lt;/b&gt;-the contents of the file/directory can be viewed.&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Write(w)&lt;/b&gt;-the file can be modified or deleted.&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;Execute(x)&lt;/b&gt;-the file can be executed, or run. This only makes senseif the file is a program or script that does something. Also, having theexecute permission for a directory means the directory can be cd'd into(eg. cddirectoryName)&lt;/p&gt; &lt;p class=webH4&gt;Examples&lt;/p&gt; &lt;p class=Codeing&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=Codeing&gt;-rwxrwxrwx&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Allusers have full access to this file.&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;-rw-r--r--&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Ownerhas read, write access to the file. All other users have read access.&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;drwx------ &lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Thisis a directory that the user has full access, while all other users have noaccess.&lt;/span&gt;&lt;/p&gt; &lt;p class=webH2&gt;Changing the Permissions with 'chmod' Command&lt;/p&gt; &lt;p class=MsoNormal&gt;There are several ways to change the attributes with the &lt;b&gt;chmodcommand&lt;/b&gt;. In my opinion, the easiest way to use &lt;b&gt;chmod&lt;/b&gt; is as follows(you would insert file permissions after the equals sign, see examples below)&lt;b&gt;,&lt;/b&gt;&lt;/p&gt; &lt;p class=Codeing&gt;chmod u=,g=,o= fileName&lt;/p&gt; &lt;p class=MsoNormal&gt;Fittingly, u, g and o are as follows, &lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;u-&lt;/span&gt;&lt;/b&gt;&lt;spanstyle='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;user&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;g&lt;/span&gt;&lt;/b&gt;&lt;spanstyle='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;-group&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;o&lt;/span&gt;&lt;/b&gt;&lt;spanstyle='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;-other&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;If you leave out u,g or o, that attribute will not bemodified.&amp;nbsp;&lt;/p&gt; &lt;p class=Codeing&gt;chmod u=,g= fileName&lt;b&gt;&lt;span style='font-family:"Arial","sans-serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;b&gt;Note&lt;/b&gt;: An error will occur if you put spaces betweenu=,g=.&lt;/p&gt; &lt;p class=webH4&gt;Examples&lt;/p&gt; &lt;p class=Codeing&gt;$ chmod u=rwx,g=r,o=w foo&lt;br&gt;$ ls -l&lt;br&gt;-rwxr---w- jdoe jdoe 969 Dec 21 02:32 foo&lt;/p&gt; &lt;p class=MsoNormal&gt;Not including g will keep it the same as before,&lt;/p&gt; &lt;p class=Codeing&gt;$ chmod u=x,o=r foo&lt;br&gt;$ ls -l&lt;br&gt;---xr--r-- jdoe jdoe 969 Dec 21 02:32 foo&lt;/p&gt; &lt;p class=MsoNormal&gt;A blank after o will clear all attributes,&lt;/p&gt; &lt;p class=Codeing&gt;$ chmod u=rx,g=w,o= foo&lt;br&gt;$ ls -l&lt;br&gt;-r-x-w---- jdoe jdoe 969 Dec 21 02:32 foo&lt;/p&gt; &lt;p class=webH3&gt;Using + and – to add and remove attributes&lt;/p&gt; &lt;p class=MsoNormal&gt;You can also use + and – to add and subtract attributes.&lt;/p&gt; &lt;p class=webH4&gt;Examples&lt;/p&gt; &lt;p class=Codeing&gt;$ chmod u=wx,g=w,o= foo&lt;br&gt;$ ls -l&lt;br&gt;--wx-w---- jdoe jdoe 969 Dec 21 02:32 foo&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br&gt;&lt;b&gt;$ chmod u+r-w,g-w+r,o+r foo&lt;/b&gt;&lt;br&gt;$ ls -l&lt;br&gt;-r-xr--r-- jdoe jdoe 969 Dec 21 02:32 foo&amp;nbsp;&lt;/p&gt; &lt;p class=webH3&gt;Using 3-digit octal value to set attributes&lt;/p&gt; &lt;p class=MsoNormal&gt;Lastly, you can specify the attributes with a &lt;b&gt;3 digitoctal&lt;/b&gt;. Each of the user, group and other permissions have 3 attributes(rwx)that can be on or off, and as such can be thought of as a 3 bit word which iseasily converted to an octal digit(0-7),&lt;/p&gt; &lt;p class=Codeing&gt;chmod (u#)(g#)(o#) fileName&amp;nbsp; &lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;0='---'&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;1='--x'&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;2='-w-'&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;3='-wx'&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;4='r--'&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;5='r-x'&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;6='rw-'&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;/span&gt;&lt;span style='font-size:7.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;7='rwx'&lt;/p&gt; &lt;p class=webH4&gt;Example&lt;/p&gt; &lt;p class=Codeing&gt;$ chmod 764 foo&lt;br&gt;$ ls -l&lt;br&gt;-rwxrw-r-- jdoe jdoe 969 Dec 21 02:32 foo&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Arial","sans-serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/finding-file-in-linux.html"&gt;Previous- Finding A File&lt;/a&gt; | &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-basic-commands-part-2-creating.html"&gt;Next- Creating and Deleting Files and Directories&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt'&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-7209914993999313407?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/7209914993999313407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-file-permissions-and-chmod.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/7209914993999313407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/7209914993999313407'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-file-permissions-and-chmod.html' title='Linux - File Permissions and the &apos;chmod&apos; Command'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-7269297045182211443</id><published>2009-10-09T19:46:00.000-07:00</published><updated>2010-09-06T01:01:22.170-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='expr'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='substring'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - Expressions and Substrings</title><content type='html'>&lt;html&gt;&lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt;&lt;!-- /* Font Definitions */ @font-face	{font-family:"Cambria Math";	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:10.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p	{margin-right:0in;	margin-left:0in;	font-size:12.0pt;	font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}.MsoPapDefault	{margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;}--&gt;&lt;/style&gt;&lt;/head&gt;&lt;body lang=EN-US link=blue vlink=purple&gt;&lt;div class=Section1&gt;&lt;p class=webH1&gt;Linux - Bash Shell Scripting - Expressions and Substrings&lt;/p&gt;&lt;p class=webH2&gt;Expressions&lt;/p&gt;&lt;p class=MsoNormal&gt;Sometimes in a script, you would like to evaluate anexpression. For example, to find the sum of two variables. The expr command canbe used to do this,&lt;/p&gt;&lt;p class=CodeingCxSpFirst style='margin-bottom:0in;margin-bottom:.0001pt'&gt;$ cattestsum.sh&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;#!/bin/bash&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;v1=12&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;v2=39&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;v3=`expr$v1 + $v2`&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;echo$v3&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;$./testsum.sh&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;51&lt;/p&gt;&lt;p class=CodeingCxSpLast style='margin-bottom:0in;margin-bottom:.0001pt'&gt;&amp;nbsp;&lt;/p&gt;&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt'&gt;Note thatthe expr command must be enclosed in backquotes `…` for this to properly work.Typing ‘&lt;span class=CodeingChar&gt;man expr&lt;/span&gt;’ will display a help screenabout the expr command.&lt;/p&gt;&lt;p class=webH2&gt;Substrings &lt;/p&gt;&lt;p class=MsoNormal&gt;The expr substr command can be used to extract a substringfrom a string variable, e.g., this program prints the individual characters ofa string stored in a variable v,&lt;/p&gt;&lt;p class=CodeingCxSpFirst style='margin-bottom:0in;margin-bottom:.0001pt'&gt;v=&amp;quot;foobar&amp;quot;&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;len=`exprlength $v`&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;fori in `seq 1 1 $len`; do&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;&amp;nbsp;&amp;nbsp;echo -n `expr substr $v $i 1`&lt;/p&gt;&lt;p class=CodeingCxSpMiddle style='margin-bottom:0in;margin-bottom:.0001pt'&gt;done&lt;/p&gt;&lt;p class=CodeingCxSpLast style='margin-bottom:0in;margin-bottom:.0001pt'&gt;echo&lt;/p&gt;&lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt'&gt;&amp;nbsp;&lt;/p&gt;&lt;p class=MsoNormal&gt;The syntax of expr substr is, '&lt;span class=CodeingChar&gt;exprsubstr string pos len' &lt;/span&gt;which will extract len characters from the stringstring starting at position pos. Note that the first character of the stringstring is at position 1.&lt;/p&gt;&lt;p class=MsoNormal align=center style='text-align:center'&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-for-loops.html"&gt;Previous- For and While Loops &lt;/a&gt;&lt;/p&gt;&lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-7269297045182211443?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/7269297045182211443/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-expressions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/7269297045182211443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/7269297045182211443'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-expressions.html' title='Linux - Bash Shell Scripting - Expressions and Substrings'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-6892810295085579465</id><published>2009-10-09T19:26:00.000-07:00</published><updated>2010-09-06T01:01:22.265-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='for loop'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - For and While Loops</title><content type='html'>Bash implements for, while, and until loops(not discussed).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;For Loop &lt;/b&gt;&lt;br /&gt;The basic syntax of the for loop is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;for var in list; do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; some commands&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note the semicolon; it is important to not omit it. The commands are executed once for every item in the list. The current item is accessed through the variable $var, e.g.,&lt;br /&gt;Use VI to edit for.sh&lt;br /&gt;--------------------------------&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;for i in 1 2 3 4 5 6 7 8 9 10; do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo -n "$i "&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;echo&lt;/span&gt;&lt;br /&gt;--------------------------------&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ chmod 755 for.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ./for.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;1 2 3 4 5 6 7 8 9 10&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The option -n to echo means do not print a newline character after outputting the text.&lt;br /&gt;Another example,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;for i in $(ls); do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo $i&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This script display the name of each of the files in the current directory one per output line. Another example,&lt;br /&gt;Use VI to edit ls-dirs.sh&lt;br /&gt;--------------------------------&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;for i in *; do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; if [ -d "$i" ]; then&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo "$i [dir]"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo $i&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; fi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;done&lt;/span&gt;&lt;br /&gt;--------------------------------&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ mkdir foo1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ mkdir foo2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ chmod 755 ls-dirs.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ alias ls-dirs=./ls-dirs.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ls&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;foo1 foo2 for.sh if.sh ls-dirs.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ls-dirs&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;foo1 [dir]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;foo2 [dir]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The seq command (type man seq for help) can be used to generate an integer sequence. The syntax is, seq first increment last which will generate an integer sequence starting at first, incrementing by increment, and stopping at last. For example, Here is a loop which displays the first 100 odd integers,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;for i in `seq 1 2 100`; do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo -n $i " "&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note that the seq command must be enclosed in backquotes `seq…` so the shell will execute it to generate the desired output. This loop prints the first 100 odd integers in reverse order,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;for i in `seq 99 -2 1`; do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo -n $i " "&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;While Loops&lt;/b&gt;&lt;br /&gt;The basic syntax of the while loop is,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;while [ conditional-expression ]; do&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; statements&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I have ommitted examples as the while loop is used in a similar context to the for loop.&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-if.html" style="font-family: Verdana,sans-serif;"&gt;Previous - If Statements&lt;/a&gt;&lt;span style="font-family: Verdana,sans-serif;"&gt; | &lt;/span&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-expressions.html" style="font-family: Verdana,sans-serif;"&gt;Next - Shell Scripting Expressions/Substrings&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-6892810295085579465?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/6892810295085579465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-for-loops.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/6892810295085579465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/6892810295085579465'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-for-loops.html' title='Linux - Bash Shell Scripting - For and While Loops'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-2260084255382304345</id><published>2009-10-09T19:18:00.000-07:00</published><updated>2010-09-06T01:01:22.290-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='if statements'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - If Statements</title><content type='html'>The syntax of the if statement is,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;if [ conditional-expression ]&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;then&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; some commands&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;fi&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;or&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;if [ conditional-expression ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp; some commands&lt;br /&gt;else&lt;br /&gt;&amp;nbsp;&amp;nbsp; some other commands&lt;br /&gt;fi&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The character "[" actually refers to a built-in Bash command—it is a synonym for another command named test. The result of the conditional expression is 0 or nonzero with 0 being false and nonzero being true. Some examples,&lt;br /&gt;&lt;br /&gt;Use VI to edit if.sh&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;--------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;today=0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;if [ $today = 1 ]; then&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo "today = 1"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo "today &amp;lt;&amp;gt; 1"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;fi&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;--------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ chmod 755 if.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ./if.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;today &amp;lt;&amp;gt; 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since using [ ] is equivalent to using test,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;today=0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;if test $today = 1; then&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo "today = 1"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo "today &amp;lt;&amp;gt; 1"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;fi&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The test command has command line options for checking the status of files, e.g.,&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;test -d file&lt;br /&gt;&lt;/div&gt;True if file is a directory&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;test -e file&amp;nbsp;&lt;/span&gt;&lt;br /&gt;True if file exists&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;test -r file&lt;br /&gt;&lt;/div&gt;True if file exists and is readable&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;test -s file&lt;br /&gt;&lt;/div&gt;True if file exists and has size &amp;gt; 0&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;test -w file&lt;br /&gt;&lt;/div&gt;True if file exists and is writable.&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;test -x file&lt;br /&gt;&lt;/div&gt;True if file exists and is executable&lt;br /&gt;&lt;br /&gt;Multiple conditions can be checked using -a (and) and -o (or), e.g.,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;if test -e if.sh -a -x if.sh; then&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo "if.sh is an executable"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; echo "if.sh either does not exist or it is not an executable"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;fi&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In a schell script, the ! symbol is used as the NOT logical operator, e.g.,&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;if [ ! -d src ]; then&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo '"'src'"' does not exist, creating directory.&lt;br /&gt;&amp;nbsp;&amp;nbsp; mkdir src&lt;br /&gt;fi&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;To learn more about conditional expressions I suggest you try $ man test.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables-in.html"&gt;Previous - Variables in Output&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-for-loops.html"&gt;Next - For and While Loops &lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-2260084255382304345?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/2260084255382304345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-if.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/2260084255382304345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/2260084255382304345'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-if.html' title='Linux - Bash Shell Scripting - If Statements'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-6963946745913289145</id><published>2009-10-09T19:08:00.000-07:00</published><updated>2010-09-06T01:01:22.599-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='output'/><category scheme='http://www.blogger.com/atom/ns#' term='bash shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - Variables in Output</title><content type='html'>The output of a command can be assigned to a variable,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;VarName=$(command)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;LS_OUT=$(ls)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;echo $LS_OUT&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Or&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#the '&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;date&lt;/span&gt;' command retrieves the current date(many options)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;DOW=$(date +%a)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #get day of week&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;MONTH=$(date +%b)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;DAY=$(date +%d)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;YEAR=$(date +%Y)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;echo "Today is ${DOW} ${MONTH}-${DAY}-${YEAR}"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ alias today="./today.sh"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ today&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Today is Wed Oct-17-2007&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-reading-from.html" style="font-family: Verdana,sans-serif;"&gt;Previous - Reading From Keyboard&lt;/a&gt;&lt;span style="font-family: Verdana,sans-serif;"&gt; | &lt;/span&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-if.html" style="font-family: Verdana,sans-serif;"&gt;Next - If Statements &lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-6963946745913289145?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/6963946745913289145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/6963946745913289145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/6963946745913289145'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables-in.html' title='Linux - Bash Shell Scripting - Variables in Output'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-8501340675360092832</id><published>2009-10-09T19:04:00.001-07:00</published><updated>2010-09-06T01:01:23.012-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='reading from keyboard'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - Reading From the Keyboard</title><content type='html'>To read a string from the keyboard and store it in a shell variable use the &lt;b&gt;read &lt;/b&gt;command, e.g.,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;echo "Enter your name: "&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;read name&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;echo "Pleased to meet you $name."&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-simple.html" style="font-family: Verdana,sans-serif;"&gt;Previous - A Simple Backup Script&lt;/a&gt;&lt;span style="font-family: Verdana,sans-serif;"&gt; | &lt;/span&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables-in.html" style="font-family: Verdana,sans-serif;"&gt;Next - Variables in Output &lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-8501340675360092832?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/8501340675360092832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-reading-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8501340675360092832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8501340675360092832'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-reading-from.html' title='Linux - Bash Shell Scripting - Reading From the Keyboard'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-1258597962866034722</id><published>2009-10-09T19:03:00.000-07:00</published><updated>2010-09-06T01:01:23.045-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='backup'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - A Simple Backup Script</title><content type='html'>This script will tar and compress the files in the specified directory which is located beneath the current directory,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;# usage: bu dir&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;tar cvf $1.tar $1a&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;bzip2 $1.tar&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;mv $1.tar.bz2 mybackups&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;echo "$1 backed up."&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ bu src&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;src backed up.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ls mybackups&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;src.tar.bz2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-displaying.html" style="font-family: Verdana,sans-serif;"&gt;Previous - Displaying Text&lt;/a&gt;&lt;span style="font-family: Verdana,sans-serif;"&gt;  | &lt;/span&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-reading-from.html" style="font-family: Verdana,sans-serif;"&gt;Next - Reading From Keyboard&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-1258597962866034722?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/1258597962866034722/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-simple.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/1258597962866034722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/1258597962866034722'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-simple.html' title='Linux - Bash Shell Scripting - A Simple Backup Script'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-757185151785347490</id><published>2009-10-09T19:01:00.000-07:00</published><updated>2010-09-06T01:01:23.053-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='echo'/><category scheme='http://www.blogger.com/atom/ns#' term='shell example'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - Displaying Text from a Shell Script</title><content type='html'>An executing script can display text on the console window using the echo command. For example,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;# usage: rmwild dir pattern&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;dirname=$1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;pattern=$2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;echo "Removing all $2 files from $1..."&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cd $dirname&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;rm $pattern 2&amp;gt; /dev/null&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;echo "Done."&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ls tmp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;file1.c file1.o file2.c file2.o&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ rmwild tmp *.o&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Removing all *.o files from tmp...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Done.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ls tmp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;file1.c file2.c&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-aliases.html"&gt;Previous - Aliases&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-simple.html"&gt;Next - A Simple Backup Script&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-757185151785347490?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/757185151785347490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-displaying.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/757185151785347490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/757185151785347490'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-displaying.html' title='Linux - Bash Shell Scripting - Displaying Text from a Shell Script'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-8302442809073889404</id><published>2009-10-09T18:57:00.000-07:00</published><updated>2010-09-06T01:01:23.306-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='aliases'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='bash shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - Aliases</title><content type='html'>An alias is another name for something. In Bash, you can define aliases for commands using the syntax alias name=command. In this example, assume rmwild is a user-created program,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ alias rmwild="./rmwild"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ rmwild tmp *.o&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ alias gohome=cd ~&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ pwd&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/usr/bin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ gohome&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ pwd&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/home/fredf&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Aliases defined on the command line only exist for the current Bash session. If you want the alias name to be available every time you log in, define the alias in your .bashrc file. To delete an alias that was defined at the command prompt, use the unalias command, e.g., unalias rmwild. To delete all of your aliases, type unalias -a.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-command-line.html"&gt;Pre&lt;/a&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-command-line.html"&gt;vious - Command Line Arguments&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-displaying.html"&gt;Next - Displaying Text from Shell Script &lt;/a&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-8302442809073889404?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/8302442809073889404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-aliases.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8302442809073889404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8302442809073889404'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-aliases.html' title='Linux - Bash Shell Scripting - Aliases'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-1503518925641683870</id><published>2009-10-09T18:50:00.000-07:00</published><updated>2010-09-06T01:01:23.311-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='arguments'/><category scheme='http://www.blogger.com/atom/ns#' term='bash shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='command line arguments'/><title type='text'>Linux - Bash Shell Scripting - Command-Line Arguments</title><content type='html'>When a Bash shell script is launched, arguments may be passed to the script, e.g., as in $ ./mymake.sh foo bar install. Here mymake.sh is the name of the shell script file, and foo, bar, and install are arguments. Special shell variables, $0, $1, $2, …, are used to refer to the command line arguments. The variable $0 refers to the name of the shell script (./mymake.sh), $1 the first argument (foo), $2 the second argument (bar) and so on. $# is the number of command line arguments following the script filename. Our script above can be rewritten,&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#!/bin/bash&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;# usage: rmwild dir pattern&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;dirname=$1&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;pattern=$2&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cd $dirname&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;rm $pattern&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ./rmwild tmp *.o&lt;br /&gt;&lt;br /&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-example.html"&gt;Previous - An Example&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-aliases.html"&gt;Next - Aliases &lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-1503518925641683870?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/1503518925641683870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-command-line.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/1503518925641683870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/1503518925641683870'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-command-line.html' title='Linux - Bash Shell Scripting - Command-Line Arguments'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-570106495799984812</id><published>2009-10-09T18:44:00.000-07:00</published><updated>2010-09-06T01:01:23.315-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='shell example'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - An Example</title><content type='html'>A script file can contain regular Bash commands, e.g., rm, cp, mv, ls, etc. A script file can also define variables and assign them values. As we will see shortly, the Bash shell programming language is quite sophisticated and allows if statements, loops, and procedures. Here is a sample shell script which moves to directory tmp and deletes all of the .o files (the script file is named rmo.sh),&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;# usage: rmo&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;mv tmp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;rm *.o&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ./rmo.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;./rmo.sh: Permission denied&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The shell script failed to run because shell scripts are not executable files by default. To make the shell script file executable, you must change the permissions using the chmod command to add x,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ls -l rmo.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;-rw-r--r-- 1 jdoe jdoe 122 Oct 17 11:35 rmo.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ chmod 744 rmo.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ls -l rmo.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;-rwxr--r-- 1 jdoe jdoe 122 Oct 17 11:35 rmo.sh&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ ./rmo.sh&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: inherit;"&gt;&lt;span style="font-size: small;"&gt;A slightly more sophisticated program might use variables,&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;# usage: rmo&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;dirname=tmp&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;pattern=*.o&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cd $dirname&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;rm $pattern&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here dirname and pattern are variables. Note that when the variable is assigned to (using =), we do not put a $ in front of the variable name, but we do use a $ when referring to the variable later on. If you don't, the shell will think that the variable name is the filename of a program to be executed and it will probably fail with an error message.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-arithmetic.html"&gt;Previous - Arithmetic and Relational Operators&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-command-line.html"&gt;Next - Command Line Arguments&lt;/a&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-570106495799984812?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/570106495799984812/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/570106495799984812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/570106495799984812'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-example.html' title='Linux - Bash Shell Scripting - An Example'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-3600319101727375515</id><published>2009-10-09T18:38:00.000-07:00</published><updated>2010-09-06T01:01:23.321-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='relational operators'/><category scheme='http://www.blogger.com/atom/ns#' term='arithmetic operators'/><category scheme='http://www.blogger.com/atom/ns#' term='shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - Arithmetic and Relational Operators</title><content type='html'>The standard operators are available as shown in the table (note: there are more operators than those shown here; read the Bash man page for more information about the complete set of operators).&lt;br /&gt;&lt;br /&gt;Within an expression, the normal precedence rules are applied; in the table precedence is from highest (unary minus, plus) to lowest (logical or).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;- + &lt;/b&gt;&lt;br /&gt;Unary minus, plus&lt;br /&gt;&lt;br /&gt;&lt;b&gt;! ~ &lt;/b&gt;&lt;br /&gt;Logical negation, bitwise negation&lt;br /&gt;&lt;br /&gt;** &lt;br /&gt;Exponentiation&lt;br /&gt;&lt;br /&gt;* / % &lt;br /&gt;Multiplication, division, remainder&lt;br /&gt;&lt;br /&gt;+ - &lt;br /&gt;Addition, Subtraction&lt;br /&gt;&lt;br /&gt;&amp;lt;&amp;lt; &amp;gt;&amp;gt; &lt;br /&gt;Left and right bitwise shifts&lt;br /&gt;&lt;br /&gt;&amp;gt; &amp;lt; &amp;gt;= &amp;lt;= Greater than, less than, greater than or equal, less than or equal&lt;br /&gt;&lt;br /&gt;== != &lt;br /&gt;Equal, not equal&lt;br /&gt;&lt;br /&gt;&amp;amp; &lt;br /&gt;Bitwise and&lt;br /&gt;&lt;br /&gt;^ &lt;br /&gt;Bitwise exclusive or&lt;br /&gt;&lt;br /&gt;| &lt;br /&gt;Bitwise or&lt;br /&gt;&lt;br /&gt;&amp;amp;&amp;amp;&lt;br /&gt;Logical and&lt;br /&gt;&lt;br /&gt;|| &lt;br /&gt;Logical or&lt;br /&gt;&lt;br /&gt;Variables can be assigned integer values using normal assignment, or using let, e.g.,&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;x=33&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;let y=12&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;let z = 95 # error&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The last statement will cause the shell script to fail; there should be no spaces to&lt;br /&gt;the left and right of the = operator. Expressions are evaluated by enclosing them&lt;br /&gt;in $[ … ], e.g.,&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;x=33&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;let y=12&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;z=$[x/y]&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;echo $z&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The above displays 2 (note integer division is performed).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables.html"&gt;Previous - Variables&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-example.html"&gt;Next - An Example&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-3600319101727375515?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/3600319101727375515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-arithmetic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/3600319101727375515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/3600319101727375515'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-arithmetic.html' title='Linux - Bash Shell Scripting - Arithmetic and Relational Operators'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-4058174034334897072</id><published>2009-10-09T18:32:00.000-07:00</published><updated>2010-09-06T01:01:23.326-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='variables'/><category scheme='http://www.blogger.com/atom/ns#' term='Bash'/><title type='text'>Linux - Bash Shell Scripting - Variables</title><content type='html'>Shell variables are used to store values. A variable can be defined at the same time it is assigned by the = operator, e.g.,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;LONG_NAME="Flintstone Fred"&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;SHORTNAME=Fred&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note in the first case that quotation marks are required because the string contains spaces. The backquote operator will execute the enclosed command and assign the output to the designated variable, e.g.,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;LS_OUT=`ls`&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When referring to the variable, its name must be preceded by $, e.g.,&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;X1=$Y2&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;Here we are assigning the value of Y2 to X1. Note that Y2 is preceded by $ whereas X1 is not.&lt;br /&gt;&lt;br /&gt;You can declare numerical values too,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;intA=5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Summary&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Declare string&lt;/li&gt;&lt;br /&gt;&lt;ul style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;li&gt;string1="string text"&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;Declare command&lt;/li&gt;&lt;br /&gt;&lt;ul style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;li&gt;command1='ls'&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;Declare numerical value&lt;/li&gt;&lt;br /&gt;&lt;ul&gt;&lt;li style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;intA=5&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;floatB=.5&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-introduction.html"&gt;Previous - Introduction&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-arithmetic.html"&gt;Next - Arithmetic and Relational Operators &lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-4058174034334897072?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/4058174034334897072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/4058174034334897072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/4058174034334897072'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables.html' title='Linux - Bash Shell Scripting - Variables'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-23975301621079940</id><published>2009-10-09T18:29:00.000-07:00</published><updated>2010-09-06T01:01:23.433-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='.bash'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>Linux - Bash Shell Scripting - Introduction</title><content type='html'>One of the more powerful features of Unix systems and the shells is the ability to write shell programs, i.e., programs which are executed by the shell interpreter in order to perform useful commands or perform some task. These programs are called shell scripts, scripts, or script files. Shell scripts are a way of automating commonly performed commands or a complex set of commands.&lt;br /&gt;&lt;br /&gt;Complete books have been written about shell scripting, and it is not something we can cover in a few blog posts. This will be a basic introduction, and you are referred to the online guides and tutorials for more information.&lt;br /&gt;&lt;br /&gt;A script file is a text file, and the first line is usually supposed to be&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;b&gt;#!/usr/bin/env bash&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;if the shell script is designed to be executed by the Bash shell. If you are using a different shell to write your script (e.g., the Korn shell), then set the first line to point to the Korn shell's binary image (usually it is in the /bin directory; e.g., /bin/ksh). This will ensure that the correct shell is loaded and used to execute the shell script regardless of what particular shell the user may be running.&lt;br /&gt;&lt;br /&gt;Note that in shell scripts, # lines are comments, just as // are comments in C++. Any character from the # symbol to the end of the line is ignored by the shell interpreter. Typically shell scripts are given a .sh extension to let the user know it is a shell script, but this is not necessary for it to run.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Summary &lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Shell scripts are text files that automate tasks. You can put any command in it that you can type in the shell prompt.&lt;/li&gt;&lt;li&gt;The commands will execute sequentially, just as in most programming languages.&lt;/li&gt;&lt;li&gt;All shell scripts must start with&lt;b&gt;&amp;nbsp;&lt;/b&gt;the location of the bash install, "#!/usr/bin/env bash, &amp;nbsp;as the first line.&lt;/li&gt;&lt;li&gt;Lines beginning with &lt;b&gt;#&lt;/b&gt; are comments.&lt;/li&gt;&lt;li&gt;Typically shell scripts are given a .sh extension to let the user know it is a shell script, but this is not necessary for it to run.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables.html"&gt;Next - Variables &lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-23975301621079940?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/23975301621079940/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-introduction.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/23975301621079940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/23975301621079940'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-introduction.html' title='Linux - Bash Shell Scripting - Introduction'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-5257650141757848336</id><published>2009-10-08T22:26:00.000-07:00</published><updated>2010-09-06T01:01:23.447-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='vi'/><category scheme='http://www.blogger.com/atom/ns#' term='editing files'/><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>Linux - Editing Files - Painless Introduction to VIM (vi)</title><content type='html'>The VI editor60 is the standard editor available on most *nix systems. Some people who know it very well, love it. I don't know it very well; I don't love it. I've never taken the time to learn it very well because I would rather gouge my eyes out with infected hypodermic syringes found in the dumpster behind the plasma donation center until bloody pus oozes out of them than learn VI61; I simply do not have the time for it. Nonetheless, learning a bit of VI can be useful, if for nothing else, you may find yourself in a situation where it is the only editor that is available on the system you are on. At the least, knowing how to load a file, make some simple changes to it, and save it can be useful. The version of VI found on most GNU/Linux systems is Vim (VI Improved).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Starting VI&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;At the Bash command prompt, type vim or vim some-filename. VI is a modal editor in which you are either in editing mode(--insert--) or command mode().&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: x-small;"&gt;$ vi filename&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt; Getting out of VI&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This is the most important thing you need to know about VI: how to get out of it. If you are in editing mode, hit ESC to enter command mode. Enter :wq to write your file and quit. To quit without writing the file, hit :q. If you really want to quit without saving the file you have made changes to hit :q!. To save the file under a different name, try :wq new-filename. You can also press ctrl-z to suspend the process&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Switching Between Editing Mode and Command Mode&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;If you are in editing mode, hit ESC to enter command mode. If you are in command mode hit i to enter insert (editing) mode. If you cannot tell which mode you are in, trying hitting ESC several times to make sure you are in command mode, then type :set showmode. This may tell VI to let you know when you are in insert&lt;br /&gt;mode (it depends on the version of VI you are using).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Other Useful Settings&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;All of these are recommended in addition to :set showmode. In command mode, type :set nocompatible to enable advanced VIM features. Type :set ruler to tell VI to display your current cursor position. Type :set number to display line numbers. It would be preferable if I were also on fire and being eaten alive by rabid hyenas at the same time. That would still be more pleasurable than using VI.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Moving Around a Character at a Time&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The original VI was written by Bill Joy (at UC Berkeley) using a computer system and keyboard that lacked arrow, page up, and page down keys. This is the reason for the stupid assignment of the keys for moving around: h (move left one character), j (move down one line), k (move up one line), and l (move right one character). On Joy's terminal, these four keys also had arrow keys on them and that is the historical reason they are still mapped that way today.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Moving Around a Word at a Time&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Forget about your Del and Backspace keys. They may or may not work. Switch to command mode. Press w to move forward one word. Press b to move backward one word. Press nw to move forward n words, e.g., 3w to move forward three words. Press nw to move backward n words.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Moving Around the File&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Switch to command mode. To move to the end of the line, hit $. To move to the beginning, hit 0. Hit 1G to go the first line of text. hit nG to go line number n. Hit G to go to the end of file. To display line numbers, in command mode type :set number. Note that :13 is equivalent to, e.g., 13G. To page down, hit Ctrl+F. To&lt;br /&gt;page up hit Ctrl+B.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Deleting Characters&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Switch to command mode, move to the character you want to delete, and hit x to delete that character. To delete n characters hit nx, e.g., 17x to delete 17 characters. To delete all the characters from the cursor position to the end of the line hit D.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Copying a Line of Text&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To copy a line of text from one place in the file to another, switch to command mode. Move to the line you want to copy. Hit yy (yank something or other, I dunno). Move the cursor to the location where you want to make the copy. Hit p (lowercase p) to put the copied line after the current line. Hit P (uppercase P) to put&lt;br /&gt;the copied line before the current line.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Moving a Line of Text&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To move a line of text from one place in the file to another, switch to commandmode. Move to the line you want to copy. Hit dd. Move the cursor to the location where you want to make the move. Hit p (lowercase p) to move the line after the current line. Hit P (uppercase P) to move the line before the current line.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Deleting a Line of Text&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Switch to command mode. Move to the line you want to delete. Hit dd.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Cutting, Copying, Pasting Multiple Lines of Text&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Use nyy to copy n lines of text to the copy buffer. Move to where you want the lines to be and hit p or P to copy them. Use ndd to move n lines of text somewhere. Hit ndd to delete n lines of text, e.g., 3dd will delete the line of text the cursor is on and the next two lines.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Moving and Copying Text in Visual Mode&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;To cut, copy, and paste text that is not an entire line, enter visual mode by hitting v in command mode. Use the h, j, k, l keys to move around and select the text you want to copy or move. Once selected, hit y to copy the text to a buffer or d to delete the text to the buffer. Once copied (with y) or deleted with (with d) move to&lt;br /&gt;where you want the text to be. Hit p to paste the text.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Finding Text&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Switch to command mode. Hit / (forward slash) and enter the string you are searching for, e.g., /cookies. The cursor will be placed on the first occurrence of cookies following the current location. Hitting n over-and-over will continue searching.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Find and Replace&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Switch to command mode. To replace all occurrences of homer by bart, try something like :1,100 s/homer/bart/g. The 1,100 part means search from line 1 to line 100 inclusive (I think 1,$ will search the entire file). The s stands for search. We are searching for homer and replacing all occurrences by bart. The g stands for global which means it will replace all occurrences without prompting you for each one. If you want to be prompted for each one, use c instead (for confirmation).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Undo and Redo&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Since you will use it the most because of VI's horrible user interface the most useful command in VI (other than :q!) is the undo command. Hitting u will undo your last change. Hitting u multiple times will undo all of your changes back to the last time you saved the file (only if you are in :set nocompatible mode). Redo&lt;br /&gt;is Ctrl+R.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;More Help&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Let's say you're either insane or a masochist and want to learn more about VI. In command mode, hit :h to bring up help. The most useful thing you need to know here is how to get out of help, hit :q (like in less).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-5257650141757848336?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/5257650141757848336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-editing-files-painless.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5257650141757848336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5257650141757848336'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-editing-files-painless.html' title='Linux - Editing Files - Painless Introduction to VIM (vi)'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-8751652883720860380</id><published>2009-10-08T22:16:00.000-07:00</published><updated>2010-09-06T01:01:23.456-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pid'/><category scheme='http://www.blogger.com/atom/ns#' term='processes'/><category scheme='http://www.blogger.com/atom/ns#' term='top'/><category scheme='http://www.blogger.com/atom/ns#' term='foreground'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='process id'/><category scheme='http://www.blogger.com/atom/ns#' term='kill'/><category scheme='http://www.blogger.com/atom/ns#' term='background'/><category scheme='http://www.blogger.com/atom/ns#' term='nice'/><title type='text'>Linux - Processes</title><content type='html'>When you run a program in *nix, the OS loads it into memory and sets up some other information concerning your program. The loaded and running program is called a process. When the program terminates, so does the process.&lt;br /&gt;&lt;br /&gt;Every process has a system-wide unique identifier called the process id, or pid; it is just an integer. The process is owned by the user who launched it. The ps command will show you a list of the running processes of which you are the owner.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: x-small;"&gt;$ ps&lt;br /&gt;PID TTY TIME CMD&lt;br /&gt;17776 pts/18 00:00:00 bash&lt;br /&gt;19041 pts/18 00:00:00 ps&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I am running two programs right now: bash and the ps program itself. The PID of each process is shown. The time column is the cumulative amount of CPU time the process has consumed—this is not the same as wall time, i.e., how many seconds it has been since you ran the program. To see all of the processes running on the system, type ps -A or ps -e. The command ps -f will display full process information including the user id of the process owner. It can be combined with -A or -e. To sort this list by user id and view it in less, use&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: x-small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: x-small;"&gt;$ ps -ef | sort | less.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When you run a program (i.e., a process) you can ask the OS to run it in the background. Do this by putting a &amp;amp; on the end of the command line,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ some-program &amp;amp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ now-you-can-type-another-command&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now some-program will run in the background and you can get back to work typing commands. To bring a running program back into the foreground, type the fg command,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ fg&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now some-program would be running and if it is displaying output, the output would be going to the console window. To put the program back into the background, hit Ctrl+Z to pause it, and then type bg to send it back to the background.&lt;br /&gt;&lt;br /&gt;To see a list of your processes running in the background use the jobs command. If you have more than one background job they will be numbered with a job number 1, 2, 3, .... To bring job number 3 to the&amp;nbsp; foreground, type fg %3. To send this job back to the background, hit Ctrl+Z, and type bg.&lt;br /&gt;To terminate a runaway process, use the kill command. The syntax is kill pidnumber. You cannot kill processes that you do not own. To kill a process running in the background, issue a jobs command to see your running processes and the determine the job number. Then use kill job number to kill the job; e.g., kill %3 to kill job number 3.&lt;br /&gt;&lt;br /&gt;The top command will display a table of the processes which are currently using the most CPU time. It is a highly configurable program; try man top. (Be aware that top is a fairly resource-intensive program; it's not cool or nice to run top alot).&lt;br /&gt;&lt;br /&gt;The nice command was designed to allow a user to run a program with lower than normal priority, so it will not hog the CPU as much. The idea is that other people may be peeved if you're sucking up too much CPU time, so you can be nice about it and still run your program. The syntax is nice -n adjust command where command is the program you want to run (e.g., it could be a big make process). Adjust is an integer which determines the adjusted process priority: -20 is highest, to 19 lowest. No one ever uses nice.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-8751652883720860380?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/8751652883720860380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-processes.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8751652883720860380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8751652883720860380'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-processes.html' title='Linux - Processes'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-8619053015915531654</id><published>2009-10-08T21:59:00.000-07:00</published><updated>2010-09-06T01:01:23.514-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='piping'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><category scheme='http://www.blogger.com/atom/ns#' term='sort'/><category scheme='http://www.blogger.com/atom/ns#' term='ls'/><title type='text'>Linux - Piping</title><content type='html'>&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}h1 {mso-style-link:"Heading 1 Char"; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:115%; page-break-after:avoid; font-size:10.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}a:link, span.MsoHyperlink {color:blue; text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;}p {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-link:"Heading 1"; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst {mso-style-name:msolistparagraphcxspfirst; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle {mso-style-name:msolistparagraphcxspmiddle; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast {mso-style-name:msolistparagraphcxsplast; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1 {mso-style-name:webH1; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:18.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH2, li.webH2, div.webH2 {mso-style-name:webH2; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:15.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH3, li.webH3, div.webH3 {mso-style-name:webH3; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:13.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH4, li.webH4, div.webH4 {mso-style-name:webH4; margin:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:11.0pt; font-family:"Cambria","serif"; color:#048207; font-weight:bold; font-style:italic;}span.CodeingChar {mso-style-name:"Codeing Char"; mso-style-link:Codeing; font-family:"Courier New"; color:#C00000;}p.Codeing, li.Codeing, div.Codeing {mso-style-name:Codeing; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst {mso-style-name:CodeingCxSpFirst; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle {mso-style-name:CodeingCxSpMiddle; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast {mso-style-name:CodeingCxSpLast; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.Links, li.Links, div.Links {mso-style-name:Links; margin:0in; margin-bottom:.0001pt; text-align:center; font-size:11.0pt; font-family:"Calibri","sans-serif"; font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault {mso-style-name:msopapdefault; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:12.0pt; font-family:"Times New Roman","serif";}.MsoChpDefault {font-size:10.0pt;}.MsoPapDefault {margin-bottom:10.0pt; line-height:115%;}@page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;}div.Section1 {page:Section1;}--&gt;&lt;/style&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - Piping&lt;/p&gt; &lt;p class=MsoNormal&gt;To connect the stdout of one program to the stdin of anotherprogram, in *nix we use a pipe (the output flows out one program through the pipeto the input of the other program). The &lt;b&gt;pipe symbol is |&lt;/b&gt; and the way tosend the output of one program to the input of another program is program1 |program2. For example, to display a long listing of the files in a directoryand sort them based on the time the file was last modified,&lt;/p&gt; &lt;p class=Codeing&gt;$ ls -l | sort +7&lt;/p&gt; &lt;p class=MsoNormal&gt;The program sort sorts its input  and sends the sortedoutput to stdout. The option +7 tells sort to sort the input file based on thedata in field 7 which in the ls -l output is the column which contains thetimestamp. To sort on size try ls -l | sort + 4. To display the contents of adirectory and display the output using less,&lt;/p&gt; &lt;p class=Codeing&gt;$ ls -l | less&lt;/p&gt; &lt;p class=MsoNormal&gt;As you can see, this is similar to &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-io-and-redirection.html"&gt;I/Oredirection&lt;/a&gt;, but we are not dealing with reading and writing to files, butrather with programs that interact in some way. IO redirects and piping can beused in conjunction in the same command as well.&lt;/p&gt; &lt;p class=Codeing&gt;$ func1 &amp;lt; file1.txt | less&lt;/p&gt; &lt;p class=MsoNormal&gt;The above command will take file1.txt as input to func1 andthen pipe the output of func1 to less to display to the screen.&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-concatenating-and-appending-files.html"&gt;Previous- Concatenating and Appending Files&lt;/a&gt; | &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-info-command.html"&gt;Next- Info Command&lt;/a&gt; &lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;span style='font-size:10.0pt;line-height:115%'&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-8619053015915531654?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/8619053015915531654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-piping.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8619053015915531654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8619053015915531654'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-piping.html' title='Linux - Piping'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-3555398914179907142</id><published>2009-10-08T21:55:00.000-07:00</published><updated>2010-09-06T01:01:23.556-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='prompt string'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='PS1'/><category scheme='http://www.blogger.com/atom/ns#' term='changing prompt'/><category scheme='http://www.blogger.com/atom/ns#' term='.bash_profile'/><category scheme='http://www.blogger.com/atom/ns#' term='.bashrc'/><title type='text'>Linux - Changing Your Prompt String</title><content type='html'>&lt;b&gt;&lt;/b&gt;The prompt is the string that is displayed by Bash when it is waiting for your input. By default your prompt may be some string ending with a $. You can change the prompt. The file .bash_profile contains commands that are executed when you log in to the *nix system. It differs from .bashrc in that the commands in .bash_profile are only executed once, during log in. On the other hand the commands in .bashrc are executed by the shell every time a new shell is started.&lt;br /&gt;&lt;br /&gt;Personally, my prompt string is defined in my .bashrc file as PS1='\[\033[1;32m\]\w $\[\033 [0m\] '. The environment variable PS1 is your main prompt string. This funky-looking command sets my prompt to display the current directory (the \w part) followed by a $ in bright green.&lt;br /&gt;&lt;br /&gt;Here is a list of all the escape characters you can use: &lt;br /&gt;&lt;pre class="SCREEN"&gt;&lt;span style="color: black;"&gt;              \a     ASCII bell character (07)&lt;br /&gt;              \d     Day Month Year&lt;br /&gt;              \e     ASCII escape character (033)&lt;br /&gt;              \h     host base name&lt;br /&gt;              \H     hostname&lt;br /&gt;              \j     # of jobs&lt;br /&gt;              \l     shell terminal device base name&lt;br /&gt;              \n     newline&lt;br /&gt;              \r     carriage return&lt;br /&gt;              \s     shell name&lt;br /&gt;              \t     24 hour HH:MM:SS &lt;br /&gt;              \T     12 hour HH:MM:SS&lt;br /&gt;              \@     12 hour am/pm time&lt;br /&gt;              \u     current user&lt;br /&gt;              \v     bash version&lt;br /&gt;              \V     bash version + patch&lt;br /&gt;              \w     current directory&lt;br /&gt;              \W     current directory base name&lt;br /&gt;              \!     command history #&lt;br /&gt;              \#     command #&lt;br /&gt;              \$     #(UID 0) or $(UID not 0)&lt;br /&gt;              \nnn   octal nnn(ex \854)&lt;br /&gt;              \\     backslash&lt;br /&gt;              \[     begin of embedded control sequence&lt;br /&gt;              \]     end sequence&lt;/span&gt;&lt;/pre&gt;&lt;pre class="SCREEN"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="SCREEN" style="font-family: inherit;"&gt;&lt;span style="color: black;"&gt;Example&lt;/span&gt;&lt;/pre&gt;&lt;pre class="SCREEN"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="SCREEN"&gt;&lt;span style="color: black;"&gt;$PS1="[\T][\u][\w]$ "&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="SCREEN"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="SCREEN" style="font-family: inherit;"&gt;The prompt string may look like this,&lt;/pre&gt;&lt;pre class="SCREEN"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="SCREEN"&gt;[5:45:45][username][~/documents]$ &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To permanently change your prompt in Bash, edit .bashrc and enter a line such as,&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;PS1=desired-prompt-string; export PS1&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;You may need to create the .bashrc file in your home directory if it does not exist. After you add that line, your prompt string should permanently be set.&lt;/span&gt; If this does not work, try adding the above in your .bash_profile in you home directory(once again, if it does not exit, create it).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-3555398914179907142?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/3555398914179907142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-changing-your-prompt-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/3555398914179907142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/3555398914179907142'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-changing-your-prompt-string.html' title='Linux - Changing Your Prompt String'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-7561548107136860803</id><published>2009-10-07T15:23:00.000-07:00</published><updated>2010-09-06T01:01:23.565-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='cat'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='linux commands'/><category scheme='http://www.blogger.com/atom/ns#' term='concatenate file'/><category scheme='http://www.blogger.com/atom/ns#' term='appending file'/><category scheme='http://www.blogger.com/atom/ns#' term='append'/><title type='text'>Linux - Concatenating and Appending Files</title><content type='html'>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face	{font-family:"Cambria Math";	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:10.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p	{margin:0in;	margin-bottom:.0001pt;	font-size:12.0pt;	font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}.MsoPapDefault	{margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;}--&gt;&lt;/style&gt; &lt;/head&gt; &lt;body lang=EN-US link=blue vlink=purple&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - Concatenating and Appending Files&lt;/p&gt; &lt;p class=webH3&gt;Concatenating Files&lt;/p&gt; &lt;p class=MsoNormal&gt;Cat can read input from multiple input files and it willsend its output to stdout,&lt;/p&gt; &lt;p class=Codeing&gt;$ cat file1&lt;br&gt;cookies&lt;br&gt;pizza&lt;br&gt;$ cat file2&lt;br&gt;dogs&lt;br&gt;cats&lt;br&gt;$ cat file3&lt;br&gt;red blue&lt;br&gt;$ cat file1 file2 file3 &amp;gt; file4&lt;br&gt;$ cat file4&lt;br&gt;cookies&lt;br&gt;pizza&lt;br&gt;dogs&lt;br&gt;cats&lt;br&gt;red blue&lt;/p&gt; &lt;p class=MsoNormal&gt;Here, the contents of the files file1, file2, and file3 havebeen concatenated together when creating the new file file4. Now you can seewhere the name cat came from (it is short for concatenate)&lt;/p&gt; &lt;p class=webH3&gt;Appending to a File&lt;/p&gt; &lt;p class=MsoNormal&gt;To append a file to another file use the &amp;gt;&amp;gt; symbol,&lt;/p&gt; &lt;p class=Codeing&gt;$ cat file1&lt;br&gt;cookies&lt;br&gt;pizza&lt;br&gt;$ cat file2&lt;br&gt;dogs&lt;br&gt;cats&lt;br&gt;$ cat file1 file2 &amp;gt;&amp;gt; file1&lt;br&gt;$ cat file1&lt;br&gt;cookies&lt;br&gt;pizza&lt;br&gt;cookies&lt;br&gt;pizza&lt;br&gt;dogs&lt;br&gt;cats&lt;/p&gt; &lt;p class=MsoNormal&gt;The above program is adding the contents of file1 and file2to the end of file1.&lt;/p&gt; &lt;p class=MsoNormal&gt;The notation &amp;gt;&amp;gt; is equivalent to 1&amp;gt;&amp;gt; and thenotation 2&amp;gt;&amp;gt; can be used to concatenate to stderr.&amp;nbsp;&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-io-and-redirection.html"&gt;Previous- I/O and Redirection&lt;/a&gt; | &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-piping.html"&gt;Next- Piping&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-7561548107136860803?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/7561548107136860803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-concatenating-and-appending-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/7561548107136860803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/7561548107136860803'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-concatenating-and-appending-files.html' title='Linux - Concatenating and Appending Files'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-5528450485491135351</id><published>2009-10-05T20:14:00.000-07:00</published><updated>2010-09-06T01:01:23.592-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Ken Thompson'/><category scheme='http://www.blogger.com/atom/ns#' term='history'/><category scheme='http://www.blogger.com/atom/ns#' term='ATT'/><category scheme='http://www.blogger.com/atom/ns#' term='Dennis Ritchie'/><title type='text'>Linux - A Brief History</title><content type='html'>A good history of the Unix operating system is available at Wikipedia1. UNIX wasan operating system originally written at AT&amp;amp;T Bell Labs in the late 1960's by Ken Thompson, Dennis Ritchie, and others. Thompson had been working on an earlier operating system project named Multics (Multiplexed Information and Computing Service) in conjunction with MIT and General Electric. While working on the project, Thompson had written a game called Space Travel for the GE mainframe being used for Multics development.&lt;br /&gt;&lt;br /&gt;After AT&amp;amp;T Bell Labs withdrew from the Multics project, Thompson began porting his Space Travel game to a DEC PDP-7 minicomputer at Bell Labs, and in the process began work on a new&lt;br /&gt;operating system he named Unics (for Uniplexed Information and Computing Service); the spelling was later changed to Unix and when it was owned by AT&amp;amp;T was written in all capitals as UNIX.&lt;br /&gt;&lt;br /&gt;Over time, Thompson, Ritchie, and others at Bell Labs continued developing UNIX. In 1973 the entire operating system was rewritten in Ritchie's new C programming language, and during this time AT&amp;amp;T began giving the operating system to universities, research institutions, and the US government under licenses, which included all source code. In 1982, when AT&amp;amp;T realized that they had an OS on their hands that was worth something, they changed their licensing model and began selling UNIX as a commercial product without source code.&lt;br /&gt;&lt;br /&gt;Meanwhile, at the University of California, Berkeley, Bill Joy and others had begun to develop BSD5 Unix as an alternative to the now-commercialized AT&amp;amp;T Unix. BSD Unix went on to become immensely popular, especially in the academic world, and Bill Joy eventually left Berkeley to go to work for a small startup named Sun Microsystems where he created the SunOS version of Unix which eventually became Sun Solaris.&lt;br /&gt;&lt;br /&gt;Throughout the next two decades, many companies and organizations produced their own versions of Unix, usually under license from AT&amp;amp;T or from the Berkeley branch. This led to a proliferation of differing operating systems that were called Unix. For example, at one time, one could acquire "Unix" from various entities such as: AT&amp;amp;T (System V), UC-Berkeley (BSD Unix), IBM (AIX), SGI (IRIX), Microsoft (Xenix), SCO, HP (HP-UX), and others. During the late 1980's, it was thought that Unix would become the dominant operating system among PC users, but the divisions among the participants and the wrangling for control of Unix created an opportunity for Microsoft Windows NT to fill the gap in the market, and for Microsoft Windows to, instead, dominate the industry.&lt;br /&gt;&lt;br /&gt;Eventually, while getting out of the computer business, AT&amp;amp;T washed their hands of Unix and sold all rights to Novell, which eventually transferred control to the Open Group. The Open Group is not a company, but rather is an industry consortium which sets standards for Unix. The Open Group published the Single Unix Specification (SUS) in 2002 which is a family of standards that defines what Unix is, is not, and what OS's qualify for the name. The SUS is now maintained by the Austin Group for the Open Group.&lt;br /&gt;&amp;nbsp;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;div style="font-family: Verdana,sans-serif; text-align: center;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/nix-file-system-and-common-commands.html"&gt;Next - The Linux/Unix File System&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-5528450485491135351?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/5528450485491135351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-brief-history.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5528450485491135351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5528450485491135351'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-brief-history.html' title='Linux - A Brief History'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-8160390972814808997</id><published>2009-10-05T19:10:00.000-07:00</published><updated>2010-09-06T01:01:23.616-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux table of contents'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><title type='text'>Learning Linux -- Article Directory</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;Introduction&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-brief-history.html"&gt;Linux - A Brief History&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/nix-file-system-and-common-commands.html"&gt;The Linux/Unix File System&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-shells-specifically-bash-shell.html"&gt;Linux  Shells - Specifically the BASH Shell&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;Linux Commands&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-commands-arguments-and-options.html"&gt;Linux - Commands, Arguments, and Options&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/man-pages.html"&gt;Linux - Man Pages&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-1.html"&gt;Linux  Commands - Viewing the Current Directory 'pwd' and 'ls'&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-changing-directories.html"&gt;Linux - Changing Directories with the 'cd' Command&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/finding-file-in-linux.html"&gt;Linux - Finding A File&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-file-permissions-and-chmod.html"&gt;Linux - Changing File Permissions with 'chmod' Command&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-basic-commands-part-2-creating.html"&gt;Linux Commands - Creating and Deleting Files and Directories&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-file-name-globbing.html"&gt;Linux File Name Globbing with *, ?, [ ]&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-3-more-on.html"&gt;Linux Commands - Deleting Files and Directories (part 2)&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-displaying-file-at-terminal-cat.html"&gt;Linux - Viewing Files with Cat and Less&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linus-archiving-files-tar-command.html"&gt;Linux - Tar Command Archiving Files&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/compressing-files.html"&gt;Linux - Compressing Files With gzip and bzip2&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-io-and-redirection.html"&gt;Linux - I/O and Redirection&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-concatenating-and-appending-files.html"&gt;Linux - Concatenating and Appending Files&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-piping.html"&gt;Linux - Piping&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-info-command.html"&gt;Linux - Info Command&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;Shell Scripting&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-introduction.html"&gt;Introduction&lt;/a&gt;&lt;br /&gt;&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables.html"&gt;Variables&lt;/a&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-arithmetic.html"&gt;Arithmetic and Relational Operators&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-example.html"&gt;An Example&lt;/a&gt;&amp;nbsp;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-command-line.html"&gt;Command Line Arguments&lt;/a&gt;&amp;nbsp;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-aliases.html"&gt;Aliases&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-displaying.html"&gt;Displaying Text from Shell Script &lt;/a&gt;&amp;nbsp;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-simple.html"&gt;A Simple Backup Script&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-reading-from.html"&gt;Reading From Keyboard&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-variables-in.html"&gt;Variables in Output&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-if.html"&gt;If Statements&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-for-loops.html"&gt;For and While Loops &lt;/a&gt;&amp;nbsp;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-bash-shell-scripting-expressions.html"&gt;Shell Scripting Expressions/Substrings&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;  &lt;/li&gt;&lt;/ul&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;Handy Things to Know&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-environment-variables.html"&gt;Linux - Environment Variables&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-changing-your-prompt-string.html"&gt;Linux - Changing Your Prompt String&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learningl...inuxcommands.blogspot.com/2009/10/li...nux-processes.html"&gt;Linux - Processes&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt; &lt;/li&gt;&lt;li&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-editing-files-painless.html"&gt;Linux - Editing Files With Vim (vi)&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt; &lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-8160390972814808997?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/8160390972814808997/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/learning-linux-article-directory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8160390972814808997'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8160390972814808997'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/learning-linux-article-directory.html' title='Learning Linux -- Article Directory'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-2745046471755924278</id><published>2009-10-05T13:07:00.000-07:00</published><updated>2010-09-06T01:01:23.679-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='redirection'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='I/O'/><category scheme='http://www.blogger.com/atom/ns#' term='redirects'/><category scheme='http://www.blogger.com/atom/ns#' term='input output'/><title type='text'>Linux - I/O and Redirection</title><content type='html'>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face	{font-family:Wingdings;	panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face	{font-family:"Cambria Math";	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:10.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p	{margin:0in;	margin-bottom:.0001pt;	font-size:12.0pt;	font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}.MsoPapDefault	{margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;} /* List Definitions */ ol	{margin-bottom:0in;}ul	{margin-bottom:0in;}--&gt;&lt;/style&gt; &lt;/head&gt; &lt;body lang=EN-US link=blue vlink=purple&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - I/O and Redirection&lt;/p&gt; &lt;p class=MsoNormal&gt;Unix was created in the days of text-based computing beforegraphical user interfaces were common. One of the design philosophies was thatusers would interact with the system through small programs which performedsome simple command or purpose. Dennis Ritchie and Ken Thompson designed thesesimple programs so they would accept input from the keyboard, a file, or as theoutput of another program. Thus, there was a need to be able to direct theoutput of a program to either a file or some other program and to also specifywhere a program was to get its input.&lt;/p&gt; &lt;p class=MsoNormal&gt;In *nix, the kernel opens and makes available three filesfor every program that is executed. These three files are called standardinput, standard output, and standard error, usually abbreviated to &lt;b&gt;stdin&lt;/b&gt;,&lt;b&gt;stdout&lt;/b&gt;, and &lt;b&gt;stderr&lt;/b&gt;. By default, &lt;b&gt;stdin&lt;/b&gt; is attached to thekeyboard, and &lt;b&gt;stdout&lt;/b&gt; and &lt;b&gt;stderr&lt;/b&gt; to the console window. If aprogram prints something to stdout, then it will be displayed on the consolewindow. If it reads something from stdin, the program will wait for input fromthe keyboard.&lt;/p&gt; &lt;p class=MsoNormal&gt;Stdin and stdout can be changed so that rather than readinginput from the keyboard, the program will read input from a file. Traditionallyin other operating systems of that era, this was done by changing the sourcecode to read the data from a file rather than from the keyboard. One of themost beautiful things about Unix was that this could be accomplished withoutchanging the source code. Rather, the user would redirect stdin from thekeyboard to a data file when invoking the program and the source code wouldremain unchanged. The same could be done for stdout: rather than sending theoutput of a program to the console window it could be &lt;b&gt;redirected to a file&lt;/b&gt;.&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;stdin&lt;/b&gt;-'&amp;lt;' OR '0&amp;lt;'&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;stdout&lt;/b&gt;-'&amp;gt;' OR '1&amp;gt;'&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;stderr&lt;/b&gt;-'2&amp;gt;'&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt'&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=webH4&gt;Redirection Example 1&lt;/p&gt; &lt;p class=MsoNormal&gt;An example may be helpful. The program &lt;b&gt;cat&lt;/b&gt; normallyreads a file and sends the output to the console window. When invoking cat wecan redirect its output to a file rather than the console window,&lt;/p&gt; &lt;p class=MsoNormal&gt;$ cat file01.c &amp;gt; fooie&lt;/p&gt; &lt;p class=MsoNormal&gt;The &amp;gt; symbol is used to send cat's output to the file &lt;b&gt;fooie&lt;/b&gt;rather than to the console window. Note that we have just made a copy offile01.c. &lt;/p&gt; &lt;p class=MsoNormal&gt;The following c program reads two integers from stdin andoutputs the larger of the two to stdout,&lt;/p&gt; &lt;p class=Codeing&gt;/* larger.c */&lt;/p&gt; &lt;p class=Codeing&gt;#include &amp;lt;stdio.h&amp;gt;;&lt;/p&gt; &lt;p class=Codeing&gt;int main() {&lt;/p&gt; &lt;p class=Codeing style='margin-left:1.0in'&gt;int n1, n2;&lt;br&gt;fprintf(stdout,&amp;quot;Enter an integer: &amp;quot;);fscanf(stdin,&amp;quot;%d&amp;quot;,&amp;amp;n1);&lt;br&gt;fprintf(stdout,&amp;quot;Enter an integer: &amp;quot;);fscanf(stdin,&amp;quot;%d&amp;quot;,&amp;amp;n2);&lt;br&gt;fprintf(&amp;quot;The largest integer was the &amp;quot;);&lt;br&gt;if (n1 &amp;gt; n2) fprintf(stdout,&amp;quot;first one: %d\n&amp;quot;,n1);&lt;br&gt;else fprintf(stdout,&amp;quot;second one: %d\n&amp;quot;,n2);&lt;br&gt;return 0;&lt;/p&gt; &lt;p class=Codeing&gt;}&lt;/p&gt; &lt;p class=MsoNormal&gt;Since this program reads its input from stdin and writes itsoutput to stdout, we can redirect its input and output so it reads its inputfrom a file and sends its output to a file. For example, suppose we create atext file named larger.in which has two lines, the first with a 2 and thesecond with a 4. The following command will execute our program and send itsoutput to larger.out.&lt;/p&gt; &lt;p class=Codeing&gt;$ cat larger.in&lt;br&gt;2&lt;br&gt;4&lt;br&gt;$ larger &amp;lt; larger.in &amp;gt; larger.out&lt;br&gt;$ cat larger.out&lt;br&gt;Enter an integer: Enter an integer: The largest integer was the second&lt;br&gt;one: 4&lt;/p&gt; &lt;p class=webH4&gt;Redirection Example 2&lt;/p&gt; &lt;p class=MsoNormal&gt;For a different example, consider that cat normally sendsits output to the console window. We can redirect cat's output to a file,&lt;/p&gt; &lt;p class=Codeing&gt;$ cat &amp;gt; larger.in&lt;br&gt;2&lt;br&gt;4&lt;br&gt;(^+D)-ctrl + d&lt;br&gt;$ cat larger.in&lt;br&gt;2&lt;br&gt;4&lt;/p&gt; &lt;p class=MsoNormal&gt;This is a commonly used quick-and-dirty way to create asmall, simple text file without invoking a text editor.&lt;/p&gt; &lt;p class=webH3&gt;Redirecting Stderr&lt;/p&gt; &lt;p class=MsoNormal&gt;Stderr can be redirected as well,&lt;br&gt;&lt;br&gt;$ larger &amp;lt; larger.in &amp;gt; larger.out 2&amp;gt; larger.err&lt;br&gt;&lt;br&gt;Note that &amp;gt; is really 1&amp;gt;, so the above command is equivalent to,&lt;br&gt;&lt;br&gt;$ larger 0&amp;lt; larger.in 1&amp;gt; larger.out 2&amp;gt; larger.err&lt;br&gt;ctrl+d &lt;br&gt;&lt;br&gt;Stderr is not used in C and C++ programs as much as stdout is. The idea withstderr is that error messages—which are special in that they are not part ofthe normal program output—can be sent to a different location than the normaloutput. For example, when running a program, you might send stdout to an outputfile and stderr to the console window,&lt;/p&gt; &lt;p class=Codeing&gt;$ blobx 2&amp;gt; data.out&lt;/p&gt; &lt;p class=MsoNormal&gt;Since the normal connection for stderr is to the consolewindow, we only need to redirect stdout to the output data file. Any errormessages printed to stderr will appear on the console window.&lt;/p&gt; &lt;p class=webH3&gt;Sending Output to /dev/null&lt;/p&gt; &lt;p class=MsoNormal&gt;*nix interfaces to &amp;quot;devices&amp;quot; through files, e.g.,the CD-ROM drive, the mouse, etc.&lt;/p&gt; &lt;p class=MsoNormal&gt;A special device named /dev/null is created at startup.Anything written to /dev/null simply &amp;quot;goes away&amp;quot;. So, we can use/dev/null and redirect stdout when, for example, we don't want to see theoutput of a program on the terminal window,&lt;/p&gt; &lt;p class=Codeing&gt;$ prog&lt;br&gt;output is displayed on the terminal&lt;br&gt;$ prog &amp;gt; /dev/null&lt;/p&gt; &lt;p class=MsoNormal&gt;No output to the console.&lt;/p&gt; &lt;p class=MsoNormal&gt;Anything written to stdout within the program will beredirected to /dev/null and will not be displayed. Stderr can also beredirected to /dev/null. You can think of /dev/null as a black hole, anythingthat goes in is never seen again.&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/compressing-files.html"&gt;Previous- Compressing Files With gzip and bzip2&lt;/a&gt; | &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-concatenating-and-appending-files.html"&gt;Next- Concatenating and Appending Files&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-2745046471755924278?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/2745046471755924278/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-io-and-redirection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/2745046471755924278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/2745046471755924278'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-io-and-redirection.html' title='Linux - I/O and Redirection'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-5129554737369584550</id><published>2009-10-05T10:57:00.000-07:00</published><updated>2010-09-06T01:01:23.711-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MYNAME'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='set'/><category scheme='http://www.blogger.com/atom/ns#' term='PATH'/><category scheme='http://www.blogger.com/atom/ns#' term='.bashrc'/><category scheme='http://www.blogger.com/atom/ns#' term='environmental variables'/><title type='text'>Linux - Environment Variables</title><content type='html'>The shell maintains several environment variables which are used to store information used by the shell. The PATH environment variable lists the directories in the order that the shell will search when trying to locate an executable file. You can display the environment variables with the set command (the env and printenv commands do the same thing),&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;br /&gt;$ set&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;a lot of stuff scrolls by&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ set | less&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the second set command, the output is being piped through the less program.  To change the value of an environment variable, use varname=value,&lt;br /&gt;&lt;br /&gt;The following example changes MYNAME variable as well as the PATH variable. The PATH variable designates where BASH looks when it runs commands. For instance, the /bin directory is in the PATH variable, so when commands are run, it will look in that directory for the command. If you are creating executables and would like bash to look in the current directory for commands you type, you can add '.' to the PATH (remember '.' represents the current directory).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-size:85%;" &gt;$ MYNAME=Kevin&lt;br /&gt;$ set | grep MYNAME&lt;br /&gt;MYNAME=Kevin&lt;br /&gt;To add . and sbin to your path,&lt;br /&gt;$ PATH=/sbin:$PATH:.&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;$ set | grep PATH&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;PATH='/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:.'&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Setting an environment variable at the Bash command prompt only changes the value of the environment variable for this session. To make the change permanent (so the variable will be defined when you log in again), edit your .bashrc file in your home directory, and add the lines,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;font-size:85%;" &gt;MYNAME=Kevin; export MYNAME&lt;br /&gt;PATH=/sbin:$PATH:.; export PATH&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The special file .bashrc contains commands that are executed whenever a "new environment" is created, i.e., whenever a new shell is started. The next time you log in the environment  variables will be updated. To delete an environment variable, use the unset command, e.g., unset MYNAME.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-5129554737369584550?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/5129554737369584550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-environment-variables.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5129554737369584550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5129554737369584550'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-environment-variables.html' title='Linux - Environment Variables'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-5751012681960028505</id><published>2009-10-05T10:46:00.000-07:00</published><updated>2010-09-06T01:01:23.723-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='info'/><category scheme='http://www.blogger.com/atom/ns#' term='nodes'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='unix'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><title type='text'>Linux - Info Command</title><content type='html'>&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}h1 {mso-style-link:"Heading 1 Char"; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:115%; page-break-after:avoid; font-size:10.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}a:link, span.MsoHyperlink {color:blue; text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;}p {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-link:"Heading 1"; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst {mso-style-name:msolistparagraphcxspfirst; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle {mso-style-name:msolistparagraphcxspmiddle; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast {mso-style-name:msolistparagraphcxsplast; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1 {mso-style-name:webH1; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:18.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH2, li.webH2, div.webH2 {mso-style-name:webH2; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:15.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH3, li.webH3, div.webH3 {mso-style-name:webH3; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:13.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH4, li.webH4, div.webH4 {mso-style-name:webH4; margin:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:11.0pt; font-family:"Cambria","serif"; color:#048207; font-weight:bold; font-style:italic;}span.CodeingChar {mso-style-name:"Codeing Char"; mso-style-link:Codeing; font-family:"Courier New"; color:#C00000;}p.Codeing, li.Codeing, div.Codeing {mso-style-name:Codeing; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst {mso-style-name:CodeingCxSpFirst; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle {mso-style-name:CodeingCxSpMiddle; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast {mso-style-name:CodeingCxSpLast; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.Links, li.Links, div.Links {mso-style-name:Links; margin:0in; margin-bottom:.0001pt; text-align:center; font-size:11.0pt; font-family:"Calibri","sans-serif"; font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault {mso-style-name:msopapdefault; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:12.0pt; font-family:"Times New Roman","serif";}.MsoChpDefault {font-size:10.0pt;}.MsoPapDefault {margin-bottom:10.0pt; line-height:115%;}@page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;}div.Section1 {page:Section1;}--&gt;&lt;/style&gt;  &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - Info Command&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Info&lt;/span&gt;&lt;/b&gt;&lt;spanstyle='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt; is an onlinehelp system, separate from the *nix manual, that is used to document GNUutilities. To get help on the bzip2 command you would type info bzip2. Whereinfo differs from man is that info documentation is organized into ahierarchical document of nodes (it's a tree structure) and the user useskeypresses to navigate around the document. Info is, like the Emacs editor,incredibly complicated to use at first. Important info commands are summarizedbelow.&lt;/span&gt;&lt;/p&gt; &lt;p class=webH3&gt;General Commands&lt;/p&gt; &lt;table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 style='border-collapse:collapse;border:none'&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Command&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=182 valign=top style='width:136.25pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Function&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;q&lt;/p&gt;  &lt;/td&gt;  &lt;td width=182 valign=top style='width:136.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Quit&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;z&lt;/p&gt;  &lt;/td&gt;  &lt;td width=182 valign=top style='width:136.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Start help tutorial&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;?&lt;/p&gt;  &lt;/td&gt;  &lt;td width=182 valign=top style='width:136.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Display command summary&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;^0&lt;/p&gt;  &lt;/td&gt;  &lt;td width=182 valign=top style='width:136.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Exit command summary&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt; &lt;p class=webH3&gt;Reading a Node&lt;/p&gt; &lt;table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 style='border-collapse:collapse;border:none'&gt; &lt;tr&gt;  &lt;td width=92 valign=top style='width:68.75pt;border:solid black 1.0pt;  background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Command&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=235 valign=top style='width:176.0pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Function&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=92 valign=top style='width:68.75pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Pg Dn&lt;/p&gt;  &lt;/td&gt;  &lt;td width=235 valign=top style='width:176.0pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Display next screen of text&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=92 valign=top style='width:68.75pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Pg Up&lt;/p&gt;  &lt;/td&gt;  &lt;td width=235 valign=top style='width:176.0pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Display previous screen of text&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=92 valign=top style='width:68.75pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;b&lt;/p&gt;  &lt;/td&gt;  &lt;td width=235 valign=top style='width:176.0pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Jump to first line of text in node&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=92 valign=top style='width:68.75pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Up Arrow&lt;/p&gt;  &lt;/td&gt;  &lt;td width=235 valign=top style='width:176.0pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;move  cursor up one line of text&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=92 valign=top style='width:68.75pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Down Arrow&lt;/p&gt;  &lt;/td&gt;  &lt;td width=235 valign=top style='width:176.0pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;move  cursor down one line of text&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=92 valign=top style='width:68.75pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Left Arrow&lt;/p&gt;  &lt;/td&gt;  &lt;td width=235 valign=top style='width:176.0pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;move  cursor one char to the left&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=92 valign=top style='width:68.75pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Right Arrow&lt;/p&gt;  &lt;/td&gt;  &lt;td width=235 valign=top style='width:176.0pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;move  cursor one char to the right&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt; &lt;p class=webH3&gt;Moving Around Nodes&lt;/p&gt; &lt;table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 style='border-collapse:collapse;border:none'&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Command&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=289 valign=top style='width:216.5pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Function&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;n&lt;/p&gt;  &lt;/td&gt;  &lt;td width=289 valign=top style='width:216.5pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;jump  to next node in document&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;p&lt;/p&gt;  &lt;/td&gt;  &lt;td width=289 valign=top style='width:216.5pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;jump  to previous node in document&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;t&lt;/p&gt;  &lt;/td&gt;  &lt;td width=289 valign=top style='width:216.5pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;jump  to the top node in the document&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;u&lt;/p&gt;  &lt;/td&gt;  &lt;td width=289 valign=top style='width:216.5pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;move  up from this node to the parent node&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Home&lt;/p&gt;  &lt;/td&gt;  &lt;td width=289 valign=top style='width:216.5pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;move  to top line of node&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;End&lt;/p&gt;  &lt;/td&gt;  &lt;td width=289 valign=top style='width:216.5pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;move  to bottom line of node&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt; &lt;p class=webH3&gt;Jumping From Node File to Another&lt;/p&gt; &lt;table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 style='border-collapse:collapse;border:none'&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Command&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=310 valign=top style='width:232.25pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Function&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Tab&lt;/p&gt;  &lt;/td&gt;  &lt;td width=310 valign=top style='width:232.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;move  cursor to next hyperlink in current node&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Return&lt;/p&gt;  &lt;/td&gt;  &lt;td width=310 valign=top style='width:232.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;follow  hyperlink to a new node&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;I&lt;/p&gt;  &lt;/td&gt;  &lt;td width=310 valign=top style='width:232.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;jump  to previously displayed node&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=87 valign=top style='width:65.0pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;d&lt;/p&gt;  &lt;/td&gt;  &lt;td width=310 valign=top style='width:232.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;jump  to directory node (the root node of info)&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;b&gt;&lt;span style='font-size:13.0pt;font-family:"Cambria","serif";color:#365F91'&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-piping.html"&gt;Previous- Piping&lt;/a&gt;&lt;/p&gt; &lt;p class=Links&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-5751012681960028505?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/5751012681960028505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-info-command.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5751012681960028505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5751012681960028505'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-info-command.html' title='Linux - Info Command'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-4631799168147883622</id><published>2009-10-05T09:28:00.000-07:00</published><updated>2010-09-06T01:01:23.750-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='man'/><category scheme='http://www.blogger.com/atom/ns#' term='help'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='man pages'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><title type='text'>Linux - Man Pages</title><content type='html'>&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}h1 {mso-style-link:"Heading 1 Char"; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:115%; page-break-after:avoid; font-size:10.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}a:link, span.MsoHyperlink {color:blue; text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;}p {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-link:"Heading 1"; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst {mso-style-name:msolistparagraphcxspfirst; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle {mso-style-name:msolistparagraphcxspmiddle; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast {mso-style-name:msolistparagraphcxsplast; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1 {mso-style-name:webH1; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:18.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH2, li.webH2, div.webH2 {mso-style-name:webH2; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:15.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH3, li.webH3, div.webH3 {mso-style-name:webH3; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:13.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH4, li.webH4, div.webH4 {mso-style-name:webH4; margin:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:11.0pt; font-family:"Cambria","serif"; color:#048207; font-weight:bold; font-style:italic;}span.CodeingChar {mso-style-name:"Codeing Char"; mso-style-link:Codeing; font-family:"Courier New"; color:#C00000;}p.Codeing, li.Codeing, div.Codeing {mso-style-name:Codeing; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst {mso-style-name:CodeingCxSpFirst; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle {mso-style-name:CodeingCxSpMiddle; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast {mso-style-name:CodeingCxSpLast; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.Links, li.Links, div.Links {mso-style-name:Links; margin:0in; margin-bottom:.0001pt; text-align:center; font-size:11.0pt; font-family:"Calibri","sans-serif"; font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault {mso-style-name:msopapdefault; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:12.0pt; font-family:"Times New Roman","serif";}.MsoChpDefault {font-size:10.0pt;}.MsoPapDefault {margin-bottom:10.0pt; line-height:115%;}@page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;}div.Section1 {page:Section1;} /* List Definitions */ ol {margin-bottom:0in;}ul {margin-bottom:0in;}--&gt;&lt;/style&gt;  &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - Man Pages&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Historicallythe online Unix manual was divided into eight sections:&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;1.&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Commands&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;2.&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;SystemCalls&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;3.&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;LibraryFunctions&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;4.&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;SpecialFiles&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;5.&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;FileFormats&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;6.&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Games&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;7.&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;MiscellaneousInformation&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;8.&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;SystemAdministration&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Theman (manual) command can be used in *nix to get help on many commands. Forexample, type man cd to display the &amp;quot;man page&amp;quot; for the cd command.Typing man kill would display information on the kill command from section 1 ofthe manual. However, if there is also information about &amp;quot;kill&amp;quot; insection 2, one could type man 2 kill to display that entry (on some systems youmay have to enter man -s 2 kill instead).&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Whenreading man pages you may see a command or phrase followed by a number inparentheses, such as chmod(2). This tells you that man information about chmodcan be found in section 2. Man output is displayed with less so you can use thePage Up and Page Down keys to scroll through the manual page (or use the b andf keys; b for backward; f for forward). Hit q to get out of less.&lt;/span&gt;&lt;/p&gt; &lt;p class=webH3&gt;Reading a Man Page&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Manpages can be difficult to read sometimes because of the complexity of thecommands and the various options and arguments. Nonetheless, if you really wantto become a proficient *nix user, you will have to learn how to read them.There is no standard format for a man page, but many of them are organized in aa similar format:&lt;/span&gt;&lt;/p&gt; &lt;table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 style='border-collapse:collapse;border:none'&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Section&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;b&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Description&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Name&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;name  and purpose of the command&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Synopsis&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;syntax  of the command; shows whether it accepts options or args&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Description&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;full  description of the command; may be quite lengthy (e.g., bash)&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Environment&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;environment  variables used by the command&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Author&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;the  person or persons who wrote the program&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Files&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;list  of important files to this command&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Copyright&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;who  holds the copyright to the program&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;See  Also&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;where  to look for related information&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Diagnostics&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;possible  errors and warnings&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=98 valign=top style='width:73.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Bugs&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt;  &lt;td width=437 valign=top style='width:327.75pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;known  mistakes or shortcomings&lt;/span&gt;&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt;text-align:center;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-commands-arguments-and-options.html"&gt;Previous- Commands, Arguments, and Options&lt;/a&gt; | &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-1.html"&gt;Next- Viewing the Current Directory 'pwd' and 'ls'&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-4631799168147883622?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/4631799168147883622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/man-pages.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/4631799168147883622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/4631799168147883622'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/man-pages.html' title='Linux - Man Pages'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-2654908508454442146</id><published>2009-10-04T13:28:00.000-07:00</published><updated>2010-09-06T01:01:23.762-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bzip'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='gzip'/><category scheme='http://www.blogger.com/atom/ns#' term='.gz'/><category scheme='http://www.blogger.com/atom/ns#' term='compress'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><category scheme='http://www.blogger.com/atom/ns#' term='.bz2'/><title type='text'>Linux - Compressing Files With gzip and bzip2</title><content type='html'>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face	{font-family:"Cambria Math";	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:10.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p	{margin:0in;	margin-bottom:.0001pt;	font-size:12.0pt;	font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}.MsoPapDefault	{margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;}--&gt;&lt;/style&gt; &lt;/head&gt; &lt;body lang=EN-US link=blue vlink=purple&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - Compressing Files With gzip and bzip2&lt;/p&gt; &lt;p class=MsoNormal&gt;Compressing files is a mean of reducing the size of a file. Themost common file compression programs in *nix are gzip and bzip2.&lt;/p&gt; &lt;p class=MsoNormal&gt;'bzip2' usually compresses files a bit better than 'gzip'due to a different algorithm, but they are used in exactly the same manner.&lt;/p&gt; &lt;p class=webH3&gt;Compress a File&lt;/p&gt; &lt;p class=MsoNormal&gt;Using gzip,&lt;/p&gt; &lt;p class=Codeing&gt;$ gzip file1.c&lt;br&gt;$ ls&lt;br&gt;a.out file1.c.gz file3 src&lt;/p&gt; &lt;p class=MsoNormal&gt;This &lt;b&gt;compresses&lt;/b&gt; the file and leaves file1.c.gz in thecurrent directory; the original file file1.c is &lt;b&gt;replaced&lt;/b&gt; by the .gzfile. &lt;/p&gt; &lt;p class=MsoNormal&gt;Using bzip2,&lt;/p&gt; &lt;p class=CodeingCxSpFirst&gt;$ bzip2 file2.c&lt;/p&gt; &lt;p class=CodeingCxSpMiddle&gt;$ ls &lt;/p&gt; &lt;p class=CodeingCxSpLast&gt;a.out file1.c.gz file3 src&lt;/p&gt; &lt;p class=webH3&gt;Decompress a File&lt;/p&gt; &lt;p class=MsoNormal&gt;Using gzip, the &lt;b&gt;-d option&lt;/b&gt; decompresses a .gz file,&lt;/p&gt; &lt;p class=Codeing&gt;$ gzip -d file1.c.gz&lt;br&gt;$ ls&lt;br&gt;a.out file1.c file3 src&lt;/p&gt; &lt;p class=MsoNormal&gt;This &lt;b&gt;decompresses&lt;/b&gt; the file and leaves file1.c in thecurrent directory; the .gz file is removed.&lt;/p&gt; &lt;p class=MsoNormal&gt;Using bzip2, which also uses the &lt;b&gt;-d option&lt;/b&gt;,&lt;/p&gt; &lt;p class=Codeing&gt;$ bzip2 -d file1.c.gz&lt;br&gt;$ ls&lt;br&gt;a.out file1.c file3 src&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=webH4&gt;Examples&lt;/p&gt; &lt;p class=MsoNormal&gt;To compress every .c file in a directory,&lt;/p&gt; &lt;p class=CodeingCxSpFirst&gt;$ cd&lt;br&gt;$ ls src&lt;br&gt;file01.c file02.c file03.c file01.o file02.o file03.o&lt;br&gt;$ cd src&lt;br&gt;$ gzip *.c&lt;br&gt;$ ls&lt;/p&gt; &lt;p class=CodeingCxSpLast&gt;&lt;span style='font-family:"Calibri","sans-serif"'&gt;file01.c.gzfile02.c.gz file03.c.gz file01.o file02.o file03.o &lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;To decompress every gzipped .c file in a directory,&lt;/p&gt; &lt;p class=Codeing&gt;$ gzip -d *.c.gz&lt;br&gt;$ ls&lt;br&gt;file01.c file02.c file03.c file01.o file02.o file03.o&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;To compress a tar file, just gzip or bzip2 it like a normalfile,&lt;/p&gt; &lt;p class=CodeingCxSpFirst&gt;$ ls src&lt;/p&gt; &lt;p class=CodeingCxSpLast&gt;file01.c file02.c file03.c file01.o file02.o file03.o&lt;br&gt;$ tar cf src.tar src&lt;br&gt;$ ls&lt;br&gt;a.out file1.c file3 src src.tar&lt;br&gt;$ bzip2 src.tar&lt;br&gt;$ ls&lt;br&gt;a.out file1.c file3 src src.tar.bz2&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linus-archiving-files-tar-command.html"&gt;Previous- Tar Command Archiving Files&lt;/a&gt; |&amp;nbsp; &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-io-and-redirection.html"&gt;Next- I/O and Redirection&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-2654908508454442146?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/2654908508454442146/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/compressing-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/2654908508454442146'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/2654908508454442146'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/compressing-files.html' title='Linux - Compressing Files With gzip and bzip2'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-7032703081612497355</id><published>2009-10-04T13:14:00.000-07:00</published><updated>2010-09-06T01:01:23.774-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tar'/><category scheme='http://www.blogger.com/atom/ns#' term='extract'/><category scheme='http://www.blogger.com/atom/ns#' term='table of contents'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='create'/><category scheme='http://www.blogger.com/atom/ns#' term='unix'/><category scheme='http://www.blogger.com/atom/ns#' term='list'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><title type='text'>Linux - Tar Command Archiving Files</title><content type='html'>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face	{font-family:"Cambria Math";	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:10.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p	{margin:0in;	margin-bottom:.0001pt;	font-size:12.0pt;	font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}.MsoPapDefault	{margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;}--&gt;&lt;/style&gt; &lt;/head&gt; &lt;body lang=EN-US link=blue vlink=purple&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - Tar Command Archiving Files&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;An archive is a collection of one or more filesgrouped together into a single file. The program tar (tape archive) is used in*nix to form an archive. This archive file is commonly called a tar file. Notethat the tar file is not compressed. A compressed or uncompressed tar file isalso commonly called a tarball. This is similar to the .iso files you see withthe Windows operating system. We will see in the next section how to compress atar file. &lt;/span&gt;&lt;/p&gt; &lt;p class=webH3&gt;Create a Tar&lt;/p&gt; &lt;p class=MsoNormal&gt;Use the &lt;b&gt;cvf&lt;/b&gt; option to create a tar (c stands forcreate),&lt;/p&gt; &lt;p class=Codeing&gt;$ cd&lt;br&gt;$ ls&lt;br&gt;a.out file1.c file3 src&lt;br&gt;&lt;b&gt;$ tar cvf archive.tar file1.c file3&lt;/b&gt;&lt;br&gt;file1.c&lt;br&gt;file3&lt;br&gt;$ ls&lt;br&gt;a.out archive.tar file1.c file3 src&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;Note that the &amp;quot;tarred&amp;quot; files are notremoved. This tar command would create an archive file named archive.tar whichcontains the files file1.c and file3. The &lt;b&gt;v option&lt;/b&gt; to tar specifies thatthe program be verbose and display the files it is archiving as they are beingarchived. The &lt;b&gt;c option&lt;/b&gt; means create an archive file. The &lt;b&gt;f option&lt;/b&gt;means that what follows the options (the word &amp;quot;archive.tar&amp;quot;) is to bethe name of the archive file. It is common to give this file a .tar extension.Following the name of the archive file is a list of one or more filenames (ordirectories) to be archived. &lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;To tar all of the .c files in a directory,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ ls src&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.c file02.c file03.c file01.o file02.o file03.o&lt;spanstyle='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ cd src&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ tar cvf archive-c.tar *.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file02.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file03.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ ls&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;archive-c.tar file01.c file02.c file03.c file01.o file02.o file03.o&lt;/p&gt; &lt;p class=webH3&gt;Display Tar Contents&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;To list the contents of a tar archive to the screen,i.e., to see what is in the archive, use the t option (t stands for table ofcontents),&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ tar tf archive-c.tar&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file02.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file03.c&lt;/p&gt; &lt;p class=webH3&gt;Extract Files&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;To extract the files from a tar archive use the x(extract) option,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ cd&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ mkdir gromulate&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ mv src/archive-c.tar gromulate&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ cd gromulate&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ tar xvf archive-c.tar&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file02.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file03.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ ls&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.c file02.c file03.c&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;The file names will be displayed as each of them isextracted (because of the v option). &lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;To extract the tar directly to a different directory thanthe current directory, use the &lt;b&gt;-C option.&lt;/b&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ tar xvf archive-c.tar -C fred/backup&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;Tar is often use to archive an entire directory andits subdirectories. In the example below, &lt;/span&gt;&lt;span class=CodeingChar&gt;'src'&lt;/span&gt;&lt;spanstyle='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;is a directory,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ cd&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ ls src&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.c file02.c file03.c file01.o file02.o file03.o&lt;spanstyle='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;&lt;b&gt;$ tar cvf src.tar src&lt;/b&gt;&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file02.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file03.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.o&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file02.o&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file03.o&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ ls&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;a.out file1.c file3 src src.tar&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;$ tar tf src.tar&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file02.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file03.c&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file01.o&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file02.o&lt;span style='font-family:"Times New Roman","serif"'&gt;&lt;br&gt;&lt;/span&gt;file03.o&lt;/p&gt; &lt;p class=webH3&gt;Summary&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;Create a tar,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ tar cvf name.tar fileSrc&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;View contents of a tar,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ tar tf src.tar&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;Extract contents of a tar,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ tar xvf archive-c.tar&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='font-size:12.0pt;line-height:115%;font-family:"Times New Roman","serif"'&gt;Extract contents of a tar to a different directory,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ tar xvf archive-c.tar -C filepath&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-displaying-file-at-terminal-cat.html"&gt;Previous- Viewing Files with Cat and Less&lt;/a&gt; |&amp;nbsp; &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/compressing-files.html"&gt;Next- Compressing Files With gzip and bzip2&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-7032703081612497355?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/7032703081612497355/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linus-archiving-files-tar-command.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/7032703081612497355'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/7032703081612497355'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linus-archiving-files-tar-command.html' title='Linux - Tar Command Archiving Files'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-5571263619256342849</id><published>2009-10-04T13:06:00.000-07:00</published><updated>2010-09-06T01:01:23.791-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vi'/><category scheme='http://www.blogger.com/atom/ns#' term='cat'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><category scheme='http://www.blogger.com/atom/ns#' term='command prompt'/><category scheme='http://www.blogger.com/atom/ns#' term='less'/><title type='text'>Linux - Viewing Files with Cat and Less</title><content type='html'>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:10.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p	{margin:0in;	margin-bottom:.0001pt;	font-size:12.0pt;	font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}.MsoPapDefault	{margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;}--&gt;&lt;/style&gt; &lt;/head&gt; &lt;body lang=EN-US link=blue vlink=purple&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - Viewing Files with Cat and Less&lt;/p&gt; &lt;p class=webH2&gt;Cat Command&lt;/p&gt; &lt;p class=MsoNormal&gt;To displays the contents of a file at the terminal window,use the cat (&lt;b&gt;concatenate&lt;/b&gt;) command,&lt;/p&gt; &lt;p class=Codeing&gt;$ cat file1.c&lt;br&gt;#include &lt;br&gt;int main() {&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&amp;quot;Hello world.\n&amp;quot;);&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br&gt;}&lt;/p&gt; &lt;p class=MsoNormal&gt;With cat, the contents of the file will scroll right off thetop of the window if the file is too large.&lt;/p&gt; &lt;p class=webH2&gt;Less Command&lt;/p&gt; &lt;p class=MsoNormal&gt;You can use the &lt;b&gt;less&lt;/b&gt; command to display a file on thewindow and then use the &lt;b&gt;Page Up&lt;/b&gt; (or b for backwards) and &lt;b&gt;Page Down&lt;/b&gt;(or f for forwards) keys to scroll through the file.&lt;/p&gt; &lt;p class=Codeing style='margin-bottom:0in;margin-bottom:.0001pt'&gt;$ less file1.c&lt;/p&gt; &lt;p class=Codeing style='margin-bottom:0in;margin-bottom:.0001pt'&gt;file1.c isdisplayed on window&lt;/p&gt; &lt;p class=webH3&gt;Other Frequently-Used Less Commands&lt;/p&gt; &lt;p class=MsoNormal&gt;After you have a file opened in less, simply type a commandto do something.&lt;/p&gt; &lt;table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 style='border-collapse:collapse;border:none'&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Command&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border:solid black 1.0pt;  border-left:none;background:#8DB3E2;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Function&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;h&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Display Help&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;q&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Quit less&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;g&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Go to 1st line&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;G&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Go to last line&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;=&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Display file name and current line&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;#g&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Go to line #(ex: 5g)&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;/&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Search forward for pattern(ex: /fred)&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;?&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Search backward for pattern&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;n&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Repeat search in same direction&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;N&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Repeat search in opposite direction&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;!cmd&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Run shell and execute cmd(ex: !ls)&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td width=78 valign=top style='width:58.25pt;border:solid black 1.0pt;  border-top:none;padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;v&lt;/p&gt;  &lt;/td&gt;  &lt;td width=242 valign=top style='width:181.25pt;border-top:none;border-left:  none;border-bottom:solid black 1.0pt;border-right:solid black 1.0pt;  padding:0in 5.4pt 0in 5.4pt'&gt;  &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:  normal'&gt;Load current file in VI editor&lt;/p&gt;  &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-3-more-on.html"&gt;Previous- Deleting Files and Directories (part 2)&lt;/a&gt; | &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linus-archiving-files-tar-command.html"&gt;Next- Tar Command Archiving Files&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-5571263619256342849?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/5571263619256342849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-displaying-file-at-terminal-cat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5571263619256342849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5571263619256342849'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-displaying-file-at-terminal-cat.html' title='Linux - Viewing Files with Cat and Less'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-9043580004115771178</id><published>2009-10-04T12:56:00.000-07:00</published><updated>2010-09-06T01:01:23.816-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='finding files'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='find'/><category scheme='http://www.blogger.com/atom/ns#' term='locate'/><category scheme='http://www.blogger.com/atom/ns#' term='whereis'/><category scheme='http://www.blogger.com/atom/ns#' term='searching'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><title type='text'>Linux - Finding A File</title><content type='html'>&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}h1 {mso-style-link:"Heading 1 Char"; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:115%; page-break-after:avoid; font-size:10.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}a:link, span.MsoHyperlink {color:blue; text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;}p {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-link:"Heading 1"; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst {mso-style-name:msolistparagraphcxspfirst; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle {mso-style-name:msolistparagraphcxspmiddle; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast {mso-style-name:msolistparagraphcxsplast; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1 {mso-style-name:webH1; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:18.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH2, li.webH2, div.webH2 {mso-style-name:webH2; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:15.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH3, li.webH3, div.webH3 {mso-style-name:webH3; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:13.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH4, li.webH4, div.webH4 {mso-style-name:webH4; margin:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:11.0pt; font-family:"Cambria","serif"; color:#048207; font-weight:bold; font-style:italic;}span.CodeingChar {mso-style-name:"Codeing Char"; mso-style-link:Codeing; font-family:"Courier New"; color:#C00000;}p.Codeing, li.Codeing, div.Codeing {mso-style-name:Codeing; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst {mso-style-name:CodeingCxSpFirst; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle {mso-style-name:CodeingCxSpMiddle; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast {mso-style-name:CodeingCxSpLast; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.Links, li.Links, div.Links {mso-style-name:Links; margin:0in; margin-bottom:.0001pt; text-align:center; font-size:11.0pt; font-family:"Calibri","sans-serif"; font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault {mso-style-name:msopapdefault; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:12.0pt; font-family:"Times New Roman","serif";}.MsoChpDefault {font-size:10.0pt;}.MsoPapDefault {margin-bottom:10.0pt; line-height:115%;}@page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;}div.Section1 {page:Section1;}--&gt;&lt;/style&gt;  &lt;br /&gt;&lt;div class="Section1"&gt;&lt;div class="webH1"&gt;Linux - Finding A File&lt;br /&gt;&lt;/div&gt;&lt;div class="webH3"&gt;Find Command&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;The find command can be used to find a file that is storedsomewhere in the file system. It is a very complicated command with lots ofoptions, so I will only show you the most basic command. Suppose you know thereis a file named mlocate.db somewhere in the file system but you don't knowwhere. The command to type would be,&lt;br /&gt;&lt;/div&gt;&lt;div class="Codeing"&gt;$ find / -name mlocate.db&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;This command tells the find program to start at the rootdirectory (the / part) and search for a file a filed named (-name) mlocate.db.It should be noted that a *nix installation might have 10,000 or more files inthe file system, so this command could run for quite a long time before itfinds the file. If you have a hunch that the file you are looking for is in asubdirectory below root, say /usr, then you could narrow down your search bytyping,&lt;br /&gt;&lt;/div&gt;&lt;div class="Codeing"&gt;$ find /usr –name mlocate.db&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Now, only the directory /usr and its subdirectories will besearched. To perform a case-insensitive search on the file use &lt;b&gt;-iname option&lt;/b&gt;rather than -name.&lt;br /&gt;&lt;/div&gt;&lt;div class="webH3"&gt;Locate Command&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;You can also try the locate command,&lt;br /&gt;&lt;/div&gt;&lt;div class="Codeing"&gt;$ locate whereis&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;If this does not work, you must first build the databasewith the command,&lt;br /&gt;&lt;/div&gt;&lt;div class="Codeing"&gt;$ slocate -u&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;This will create a file that indexes all the files for fastlookup (may take several minutes)&lt;br /&gt;&lt;/div&gt;&lt;div class="webH3"&gt;Whereis Command&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;You can also try the whereis command to locatebinary(executable files/commands) and their man pages,&lt;br /&gt;&lt;/div&gt;&lt;div class="Codeing"&gt;$ whereis ls&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;This will locate the command ls and the respective man pages.&lt;br /&gt;&lt;/div&gt;&lt;div class="Links"&gt;&amp;nbsp;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-1.html"&gt;Previous- Changing Directories&lt;/a&gt; |&amp;nbsp;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-file-permissions-and-chmod.html"&gt;Next- Changing File Permissions with 'chmod' Command&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-9043580004115771178?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/9043580004115771178/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/finding-file-in-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/9043580004115771178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/9043580004115771178'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/finding-file-in-linux.html' title='Linux - Finding A File'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-826198745349328315</id><published>2009-10-03T23:16:00.002-07:00</published><updated>2010-09-06T01:01:23.829-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='home directory'/><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='cd'/><category scheme='http://www.blogger.com/atom/ns#' term='tree'/><title type='text'>The Linux/Unix File System</title><content type='html'>The *nix file system is the part of the OS that manages the files and directories stored on secondary storage devices such as tape, optical and hard disks. Files and directories in the file system are stored in a hierarchical fashion&lt;span style="font-weight: bold;"&gt;(ie, a tree)&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;At the top level is the root directory indicated by a forward slash symbol /. "Root" is at the top of the file system hierarchy. Every file and directory on the system is stored under root and there is nothing above it in the directory tree.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Your Home Directory&lt;/span&gt;&lt;br /&gt;Your home directory is where you have your personal files. Each user has their own home directory. You and you alone have complete control of all the files in your personal home directory.&lt;br /&gt;The home directory is referenced by the '~' character. That character points to the current user's home directory. For instance, the command "cd ~" will change directory to you home directory(cd command discussed more &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-basic-commands-part-2-creating.html"&gt;here&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Common Directories in *nix &lt;/b&gt;&lt;br /&gt;On a typical *nix system you will find several common directories directly under root. Some of these common directories are discussed below.&lt;br /&gt;&lt;b&gt;/bin &lt;/b&gt;&lt;br /&gt;Binary images (executables) for various *nix commands used by users. These would include programs for commands such as &lt;b&gt;ls&lt;/b&gt;, &lt;b&gt;cp&lt;/b&gt;, &lt;b&gt;mkdir &lt;/b&gt;and so on. In a typical distribution there will be a large number of commands files located in this directory, but only a small subset of them are technically required to be installed there.&lt;br /&gt;&lt;b&gt;/boot &lt;/b&gt;&lt;br /&gt;Contains the files necessary to boot the *nix operating system. This includes the binary image of the kernel (i.e., the compiled kernel source code). In GNU/Linux The kernel file is commonly named &lt;b&gt;vmlinux &lt;/b&gt;(uncompressed) or &lt;b&gt;vmlinuz &lt;/b&gt;(compressed) followed by the &lt;b&gt;version &lt;/b&gt;and &lt;b&gt;release &lt;/b&gt;numbers. If you want to know which version of the kernel you are using, type &lt;b&gt;uname -r &lt;/b&gt;at the shell prompt.&lt;br /&gt;&lt;b&gt;/dev &lt;/b&gt;&lt;br /&gt;The &lt;b&gt;device &lt;/b&gt;directory contains files corresponding to different I/O devices connected to the system. These would include tape drives, cdrom drives, hard disks, terminals, printers, etc. A special device is&lt;br /&gt;&lt;b&gt;/dev/null&lt;/b&gt;.&lt;br /&gt;Anything written to /dev/null disappears into the ether. One of the features that made Unix popular in the early days was that all devices are treated as files, and could be accessed using file I/O commands.&lt;br /&gt;&lt;b&gt;/etc &lt;/b&gt;&lt;br /&gt;This directory contains host-specific files and directories which are used primarily for system configuration purposes. Executable programs are not located here. If the X window system is installed, the files for it will be installed in a subdirectory of /etc, e.g., /etc/X11.&lt;br /&gt;&lt;b&gt;/home &lt;/b&gt;&lt;br /&gt;Users' personal directories are located here. Normally each user is given a home directory where he/she may store his/her files. This is the directory where, as a user, you would spend most of your time. A typical home directory for user &lt;b&gt;fredf &lt;/b&gt;would be &lt;b&gt;/home/fredf&lt;/b&gt;. Note that the special symbol &lt;b&gt;~ &lt;/b&gt;is used to refer to the home directory in the shell.&lt;br /&gt;&lt;b&gt;/lib &lt;/b&gt;&lt;br /&gt;Contains shared library images needed to boot the system and to run the commands in &lt;i&gt;bin &lt;/i&gt;and &lt;i&gt;sbin&lt;/i&gt;.&lt;br /&gt;&lt;b&gt;/mnt &lt;/b&gt;&lt;br /&gt;Used to temporarily &lt;b&gt;mount &lt;/b&gt;another file system under the current file system, e.g., to connect the file system for a floppy disk or a cdrom to the current file system. How these devices are mounted is not something ordinary users care about.&lt;br /&gt;&lt;b&gt;/opt &lt;/b&gt;&lt;br /&gt;Third-party application programs can be installed here, each within its own subdirectory. &lt;b&gt;/root &lt;/b&gt;This is &lt;b&gt;root's &lt;/b&gt;home directory. The special login identifier &lt;b&gt;root &lt;/b&gt;is the master login for the entire system. Root has privileges that other users do not have, and he or she is typically the system administrator who is responsible for administering the system, installing programs, adding users, mounting file systems, etc.&lt;br /&gt;&lt;b&gt;/sbin &lt;/b&gt;&lt;br /&gt;This directory contains system binary files, i.e., executables that are normally used only by root in administering the system. Other system binaries may be found in /usr/sbin and /usr/local/sbin.&lt;br /&gt;&lt;b&gt;/tmp &lt;/b&gt;&lt;br /&gt;Temporary files are often placed here.&lt;br /&gt;&lt;b&gt;/usr &lt;/b&gt;&lt;br /&gt;The files and directories under &lt;b&gt;usr &lt;/b&gt;are mounted read-only (except to root). Underneath &lt;b&gt;usr &lt;/b&gt;are several important subdirectories.&lt;br /&gt;&lt;b&gt;/usr/bin &lt;/b&gt;&lt;br /&gt;Other user-specific binaries. For example, the &lt;b&gt;gcc &lt;/b&gt;program might be installed here.&lt;br /&gt;&lt;b&gt;/usr/include &lt;/b&gt;&lt;br /&gt;Include header files for the C compiler are placed here.&lt;br /&gt;&lt;b&gt;/usr/lib &lt;/b&gt;&lt;br /&gt;Contains object files and library files used in software development.&lt;br /&gt;&lt;b&gt;/usr/local &lt;/b&gt;&lt;br /&gt;Another place where root can install user programs. For example, if you install the Firefox web browser, you may install it under /usr/local/firefox 20 for example. Multiple networked host systems may access the files in /usr/local.&lt;br /&gt;&lt;b&gt;/usr/share &lt;/b&gt;&lt;br /&gt;Shared data files, e.g., font files, man pages, other documentation, icon images files, etc.&lt;br /&gt;&lt;b&gt;/usr/src &lt;/b&gt;&lt;br /&gt;Source code, generally for reference only (i.e., not for development purposes). On many GNU/Linux systems, the Linux source code will be installed in /usr/src/linux (during installation, you usually have the choice to download and install the Linux source code).&lt;b&gt; &lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;/usr/X11 &lt;/b&gt;&lt;br /&gt;Files used by X Window (X is part of the graphical system of your Linux installation).&lt;br /&gt;&lt;b&gt;/var &lt;/b&gt;&lt;br /&gt;Variable data files (i.e., data files that contain data that are changing) are stored here. These would include temporary files and log files.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&amp;nbsp;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-brief-history.html"&gt;Previous - Linux - A Brief History&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-shells-specifically-bash-shell.html"&gt;Next - Linux  Shells - Specifically the BASH Shell&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-826198745349328315?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/826198745349328315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/nix-file-system-and-common-commands.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/826198745349328315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/826198745349328315'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/nix-file-system-and-common-commands.html' title='The Linux/Unix File System'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-8738027126475605553</id><published>2009-10-03T23:16:00.001-07:00</published><updated>2010-09-06T01:01:23.841-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='options'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='linux commands'/><category scheme='http://www.blogger.com/atom/ns#' term='command line arguments'/><title type='text'>Linux - Commands, Arguments, and Options</title><content type='html'>&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}h1 {mso-style-link:"Heading 1 Char"; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:115%; page-break-after:avoid; font-size:10.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}a:link, span.MsoHyperlink {color:blue; text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;}p {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-link:"Heading 1"; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst {mso-style-name:msolistparagraphcxspfirst; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle {mso-style-name:msolistparagraphcxspmiddle; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast {mso-style-name:msolistparagraphcxsplast; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1 {mso-style-name:webH1; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:18.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH2, li.webH2, div.webH2 {mso-style-name:webH2; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:15.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH3, li.webH3, div.webH3 {mso-style-name:webH3; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:13.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH4, li.webH4, div.webH4 {mso-style-name:webH4; margin:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:11.0pt; font-family:"Cambria","serif"; color:#048207; font-weight:bold; font-style:italic;}span.CodeingChar {mso-style-name:"Codeing Char"; mso-style-link:Codeing; font-family:"Courier New"; color:#C00000;}p.Codeing, li.Codeing, div.Codeing {mso-style-name:Codeing; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst {mso-style-name:CodeingCxSpFirst; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle {mso-style-name:CodeingCxSpMiddle; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast {mso-style-name:CodeingCxSpLast; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.Links, li.Links, div.Links {mso-style-name:Links; margin:0in; margin-bottom:.0001pt; text-align:center; font-size:11.0pt; font-family:"Calibri","sans-serif"; font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault {mso-style-name:msopapdefault; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:12.0pt; font-family:"Times New Roman","serif";}.MsoChpDefault {font-size:10.0pt;}.MsoPapDefault {margin-bottom:10.0pt; line-height:115%;}@page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;}div.Section1 {page:Section1;}--&gt;&lt;/style&gt;  &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - Commands, Arguments, and Options&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;A &lt;b&gt;command&lt;/b&gt;is a word that is typed at the terminal window prompt in order to performsome action. For example, the &lt;b&gt;ls &lt;/b&gt;command is used to list the contents ofa directory (specifically, the &lt;b&gt;current directory&lt;/b&gt;). If you would like toview the contents of a different directory, then you can supply an &lt;b&gt;argument &lt;/b&gt;tothe ls command which is the location of the desired directory, e.g., &lt;b&gt;ls /bin&lt;/b&gt;would display the contents of the /bin directory where &lt;b&gt;/bin &lt;/b&gt;is the argument to the ls command.&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Inaddition to arguments, many (most) *nix commands accept command &lt;b&gt;options &lt;/b&gt;aswell. Options are specified either with a hyphen followed by a letter, e.g., &lt;b&gt;-l&lt;/b&gt;,or a pair of hyphens followed by a word, e.g., &lt;b&gt;--help&lt;/b&gt;. For example, &lt;b&gt;ls-l /usr/bin &lt;/b&gt;is a command (&lt;b&gt;ls&lt;/b&gt;) with the option &lt;b&gt;-l &lt;/b&gt;and theargument &lt;b&gt;/usr/bin&lt;/b&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Optionsmodify the way commands work. When no options are specified we would say thatis the &lt;b&gt;default behavior &lt;/b&gt;of the command. Options can be used to alter thedefault behavior. Note that like everything else in *nix, options are case sensitive.There is a difference between &lt;b&gt;ls -l &lt;/b&gt;and &lt;b&gt;ls –L &lt;/b&gt;as there is between&lt;b&gt;ls &lt;/b&gt;and &lt;b&gt;LS&lt;/b&gt;. A command can have multiple options, e.g., the lscommand supports two options -l and -a that alter it in different ways. A legalls command using these two options would be &lt;b&gt;ls -a -l&lt;/b&gt;. But often times,options can be combined so this same command could be typed as &lt;b&gt;ls -al &lt;/b&gt;andit would perform the same action.&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;Auseful option you should know is &lt;b&gt;--help&lt;/b&gt;. Many commands will display ascreen of text describing the commands, its action, and its options andarguments in response to the --help option. Whitespace surrounding options isimportant. The command &lt;b&gt;ls -a-l &lt;/b&gt;is erroneous because there is no space inbetween the -a and -l options. The correct command is &lt;b&gt;ls-a-l&lt;/b&gt;. Inconclusion, know that the general format of a *nix command is &lt;b&gt;&lt;i&gt;commandoptions arguments&lt;/i&gt;&lt;/b&gt;—in that order.&lt;/span&gt;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height:normal'&gt;&lt;span style='font-size:12.0pt;font-family:"Times New Roman","serif"'&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/man-pages.html"&gt;Next -Man Pages&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-8738027126475605553?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/8738027126475605553/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-commands-arguments-and-options.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8738027126475605553'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/8738027126475605553'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-commands-arguments-and-options.html' title='Linux - Commands, Arguments, and Options'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-5871231232064925369</id><published>2009-10-03T23:08:00.000-07:00</published><updated>2010-09-06T01:01:23.851-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Thompson'/><category scheme='http://www.blogger.com/atom/ns#' term='unix'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><category scheme='http://www.blogger.com/atom/ns#' term='shell'/><category scheme='http://www.blogger.com/atom/ns#' term='Bash'/><title type='text'>Linux  Shells - Specifically the BASH Shell</title><content type='html'>&lt;h2&gt;Shells&lt;/h2&gt;In *nix(Unix/Linux) the shell is a text-based interface to the operating system. The kernel is the lowest-level innermost part of the operating system, so the shell is so named because it surrounds the kernel. Over the years, various shell programs have been written. The first was the Thompson shell (commonly referred to as simply sh) written by Ken Thompson at Bell Labs. Other popular shells have that have been written over the years include the Berkeley Unix C shell (csh), the TC shell (tcsh; the T comes from the TENEX operating system), the Korn shell (ksh), the Z shell (zsh), the Bourne shell (bsh), and the Bourne-again shell (Bash). Bash was the shell originally developed by GNU for the GNU operating system. It is commonly available in most GNU/Linux distributions and this manual is written assuming you are using Bash.&lt;br /&gt;You can see which shells are installed on your system by typing cat /etc/shells (the chsh -l command simply displays this file). Most likely if you are using Linux, your default shell is bash. An easy way to tell what shell you are running is to type less /etc/passwd and look for the line containing your username. The last entry on the line will be your default login shell. If you wish to change your default login shell you can use the chsh -s shell command. This will modify the shell entry for your username in /etc/passwd so the next time you login you will be running the new shell.&lt;br /&gt;&lt;h2&gt;The Bash Shell&lt;/h2&gt;Once logged in to linux, you will see a window with some text, awiting your input. This is called a terminal window or just terminal; you may also hear the term console window or just console.&lt;br /&gt;&lt;br /&gt;The $ prompt is the Bash shell prompt. It is Bash's way of letting you know that it is waiting for you to type a command. The ~ symbol in Bash always refers to a user's home directory. Your home directory is where you are placed when you first log in and it is the area in the file system where you can store your files. The prompt string can be changed(discussed in later article).&lt;br /&gt;&lt;br /&gt;When you type commands at the prompt and press the Enter key, Bash will read the command string you typed in, parse it to break it into words and operators, perform some post-processing, and will then execute the the command. Unless you tell it otherwise, Bash will wait for the command to finish executing before displaying the $ prompt again. Some of the commands that you may use are built-in to Bash, i.e., the code that gets executed is inside the Bash program itself. However, most *nix commands are standalone programs that are found in the directories /bin, /usr/bin, and /sbin directories. For example, we can determine where the ls command is located&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: courier new;"&gt;&lt;span style="font-size: 85%;"&gt;$ whereis ls &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: courier new;"&gt;&lt;span style="font-size: 85%;"&gt;ls: /bin/ls&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;whereis is a command which will search for the program file given to it. In this case we are searching for the program file named gcc. whereis tells us that a file named "ls" can be found in a directories. In fact, the first one  /bin/ls is the actual executable file which is the ls command. For fun, try to determine where the whereis program is installed,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new; font-size: small;"&gt;$ whereis whereis&lt;br /&gt;whereis: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We can see that it is installed in /usr/bin. In fact, most of the basic *nix commands (i.e. executable programs) are located in this directory. Bash will also execute special programs called scripts written in the Bash shell scripting language. See Chapter 11 for a basic introduction to Bash shell scripting. Overall, Bash is a very complex program, and we will only learn a small part of it in this course. However, what we learn in this course is supposed to provide you a solid foundation on which you can learn and obtain more knowledge of *nix and Bash.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;b&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/nix-file-system-and-common-commands.html"&gt;Previous - The Linux/Unix File System&lt;/a&gt;&lt;/b&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; | &lt;/span&gt;&lt;b style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-commands-arguments-and-options.html"&gt;Next - Linux - Commands, Arguments, and Options&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-5871231232064925369?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/5871231232064925369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-shells-specifically-bash-shell.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5871231232064925369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/5871231232064925369'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-shells-specifically-bash-shell.html' title='Linux  Shells - Specifically the BASH Shell'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-1181469456739552466</id><published>2009-10-03T23:07:00.000-07:00</published><updated>2010-09-06T01:01:23.870-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pwd'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='current directory'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><category scheme='http://www.blogger.com/atom/ns#' term='ls'/><title type='text'>Linux  Commands - Viewing the Current Directory - 'pwd' and 'ls'</title><content type='html'>&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Cambria; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}h1 {mso-style-link:"Heading 1 Char"; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:115%; page-break-after:avoid; font-size:10.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}a:link, span.MsoHyperlink {color:blue; text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;}p {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing {margin:0in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}span.Heading1Char {mso-style-name:"Heading 1 Char"; mso-style-link:"Heading 1"; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst {mso-style-name:msolistparagraphcxspfirst; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle {mso-style-name:msolistparagraphcxspmiddle; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast {mso-style-name:msolistparagraphcxsplast; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; line-height:115%; font-size:11.0pt; font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1 {mso-style-name:webH1; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:18.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH2, li.webH2, div.webH2 {mso-style-name:webH2; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:15.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH3, li.webH3, div.webH3 {mso-style-name:webH3; margin-top:24.0pt; margin-right:0in; margin-bottom:0in; margin-left:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:13.0pt; font-family:"Cambria","serif"; color:#365F91; font-weight:bold;}p.webH4, li.webH4, div.webH4 {mso-style-name:webH4; margin:0in; margin-bottom:.0001pt; line-height:150%; page-break-after:avoid; font-size:11.0pt; font-family:"Cambria","serif"; color:#048207; font-weight:bold; font-style:italic;}span.CodeingChar {mso-style-name:"Codeing Char"; mso-style-link:Codeing; font-family:"Courier New"; color:#C00000;}p.Codeing, li.Codeing, div.Codeing {mso-style-name:Codeing; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst {mso-style-name:CodeingCxSpFirst; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle {mso-style-name:CodeingCxSpMiddle; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast {mso-style-name:CodeingCxSpLast; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst {mso-style-name:CodeingCxSpFirst; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle {mso-style-name:CodeingCxSpMiddle; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:0in; margin-left:.5in; margin-bottom:.0001pt; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast {mso-style-name:CodeingCxSpLast; mso-style-link:"Codeing Char"; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:.5in; font-size:11.0pt; font-family:"Courier New"; color:#C00000;}p.Links, li.Links, div.Links {mso-style-name:Links; margin:0in; margin-bottom:.0001pt; text-align:center; font-size:11.0pt; font-family:"Calibri","sans-serif"; font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault {mso-style-name:msopapdefault; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; font-size:12.0pt; font-family:"Times New Roman","serif";}.MsoChpDefault {font-size:10.0pt;}.MsoPapDefault {margin-bottom:10.0pt; line-height:115%;}@page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;}div.Section1 {page:Section1;}--&gt;&lt;/style&gt;  &lt;br /&gt;&lt;div class="Section1"&gt;&lt;div class="webH1"&gt;Linux  Commands - Viewing the Current Directory - 'pwd' and 'ls'&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;If you are not familiar with the Linux file system, pleaseread &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/nix-file-system-and-common-commands.html"&gt;TheLinux/Unix File System&lt;/a&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="webH3"&gt;How Do I Know Which Directory I Am In? &lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Use the command &lt;b&gt;pwd &lt;/b&gt;(print working directory),&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpFirst" style="margin-bottom: 0.0001pt;"&gt;$ pwd&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpLast" style="margin-bottom: 0.0001pt;"&gt;/home/fredf&lt;br /&gt;&lt;/div&gt;&lt;div class="webH3"&gt;List Files, File Permissions, The Chmod Command&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;To list the files in a directory type &lt;b&gt;ls&lt;/b&gt;,&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpFirst" style="margin-bottom: 0.0001pt;"&gt;$ ls&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle" style="margin-bottom: 0.0001pt;"&gt;a.outfile1.c file3 src&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpLast" style="margin-bottom: 0.0001pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;The option &lt;b&gt;-a &lt;/b&gt;will show &lt;b&gt;all &lt;/b&gt;the files in thedirectory,&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpFirst"&gt;$ ls -a&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpLast"&gt;.bash_profile a.out file1.c file3 src&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;The special file &lt;b&gt;.bash_profile &lt;/b&gt;is a configurationfile which is used to configure the Bash shell when a user logs in.&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Note that files starting with a dot are &lt;b&gt;hidden &lt;/b&gt;filesand are not displayed during a normal &lt;b&gt;ls &lt;/b&gt;command. Hidden files areusually used to store configuration information for various programs.&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;The option &lt;b&gt;-l &lt;/b&gt;will display a &lt;b&gt;long listing&lt;/b&gt;,&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpFirst"&gt;$ ls -l&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;-rwxr-xr-x 1 fredf fredf 20987 Oct 10 10:04 a.out&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;-rwxr-xr-x 1 fredf fredf 1098 Mar 7 2005 file1.c&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpMiddle"&gt;-rwxr-xr-x 1 fredf fredf 654 Jun 12 18:44 file3&lt;br /&gt;&lt;/div&gt;&lt;div class="CodeingCxSpLast"&gt;drwxr-xr-x+ 1 fredf fredf 0 Jan 01 2005 src&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;The first column displays the &lt;b&gt;permissions &lt;/b&gt;for thefiles. Permission attributes are changed with the &lt;b&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-file-permissions-and-chmod.html"&gt;chmod&lt;span style="font-weight: normal;"&gt;command&lt;/span&gt;&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="Links"&gt;&lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/man-pages.html"&gt;Previous- Man Pages&lt;/a&gt; | &lt;a href="http://learninglinuxcommands.blogspot.com/2009/10/linux-changing-directories.html"&gt;Next - Changing Directories&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-1181469456739552466?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/1181469456739552466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/1181469456739552466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/1181469456739552466'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-1.html' title='Linux  Commands - Viewing the Current Directory - &apos;pwd&apos; and &apos;ls&apos;'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-4185204640568560764</id><published>2009-10-03T23:04:00.000-07:00</published><updated>2010-09-06T01:01:23.884-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rm'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='rmdir'/><category scheme='http://www.blogger.com/atom/ns#' term='deleting files and directories'/><category scheme='http://www.blogger.com/atom/ns#' term='cd'/><category scheme='http://www.blogger.com/atom/ns#' term='mkdir'/><category scheme='http://www.blogger.com/atom/ns#' term='commands'/><title type='text'>Linux Commands - Creating and Deleting Files and Directories</title><content type='html'>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face	{font-family:"Cambria Math";	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:10.0pt;	font-family:"Cambria","serif";	color:#365F91;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}.MsoPapDefault	{margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;}--&gt;&lt;/style&gt; &lt;/head&gt; &lt;body lang=EN-US link=blue vlink=purple&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - Creating and Deleting Files and Directories (cd, mkdir,rmdir, rm)&lt;/p&gt; &lt;p class=webH2&gt;*Review - Changing Directories&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='color:#333333'&gt;To change your working (current)directory, use the &lt;b&gt;cd &lt;/b&gt;(change dir) command,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ cd cse220&lt;br&gt;$ pwd&lt;br&gt;/home/fredf/cse220&lt;br&gt;$ ls&lt;br&gt;assgn02&lt;br&gt;$ cd ..&lt;br&gt;$ pwd&lt;br&gt;/home/fredf&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;b&gt;&lt;span style='color:#333333'&gt;Note&lt;/span&gt;&lt;/b&gt;&lt;spanstyle='color:#333333'&gt;: the &lt;/span&gt;'&lt;span class=CodeingChar&gt;cd ..&lt;/span&gt;&lt;spanstyle='color:#333333'&gt;' command changes the directory to the parent directory.In linux, '&lt;/span&gt;&lt;span class=CodeingChar&gt;..&lt;/span&gt;&lt;span style='color:#333333'&gt;'refers to the parent directory, while '&lt;/span&gt;&lt;span class=CodeingChar&gt;.&lt;/span&gt;&lt;spanstyle='color:#333333'&gt;' refers to the current directory and finally '&lt;/span&gt;&lt;spanclass=CodeingChar&gt;~&lt;/span&gt;&lt;span style='color:#333333'&gt;' refers to your homedirectory. As you progress, you will see these are very useful.&lt;/span&gt;&lt;/p&gt; &lt;p class=webH2&gt;Deleting Files&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='color:#333333'&gt;To delete a file use the &lt;b&gt;rm &lt;/b&gt;(remove)command,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ rm a.out&lt;br&gt;$ ls&lt;br&gt;file1.c file3 src&lt;br&gt;$ rm file3&lt;br&gt;$ ls -al&lt;br&gt;-rwxrwxrwx 1 fredf fredf 36 Sep 23 7:53 .bash_profile&lt;br&gt;-rwxr-xr-x 1 fredf fredf 1098 Mar 7 2005 file1.c&lt;br&gt;drwxr-xr-x+ 1 fredf fredf 0 Jan 01 2005 src&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;b&gt;&lt;span style='color:#333333'&gt;Note:&lt;/span&gt;&lt;/b&gt;&lt;spanstyle='color:#333333'&gt; You can only delete files that you own or have writeprivilege.&lt;/span&gt;&lt;/p&gt; &lt;p class=webH2&gt;Creating and Removing Directories&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='color:#333333'&gt;To create a new directory usethe &lt;b&gt;mkdir &lt;/b&gt;(make directory) command and to remove it use the &lt;b&gt;rmdir &lt;/b&gt;(removedirectory) command,&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ mkdir cse220 &lt;br&gt;$ ls &lt;br&gt;a.out cse220 file1.c file3 src &lt;br&gt;$ rmdir cse220 &lt;br&gt;$ ls&lt;br&gt;a.out file1.c file3 src &lt;br&gt;$ mkdir cse220 &lt;br&gt;$ mkdir cse220/assgn02 &lt;br&gt;$ ls &lt;br&gt;a.out cse220 file1.c file3 src &lt;br&gt;$ ls cse220 assgn02&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='color:#333333'&gt;Suppose we have createddirectories cse220 and cse220/assgn02 and that Cse220/assgn02 has the files &lt;b&gt;file1.c,file2.c, file1.o, file2.o, &lt;/b&gt;and &lt;b&gt;a.out &lt;/b&gt;in it.&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ cd assgn02 &lt;br&gt;$ pwd &lt;br&gt;/home/fredf/cse220/assgn02 &lt;br&gt;$ ls &lt;br&gt;a.out file1.c file1.o file2.c file2.o &lt;br&gt;$ cd . &lt;br&gt;$ pwd /home/fredf/cse220/assgn02 &lt;br&gt;$ cd .. $ pwd /home/fredf/cse220 &lt;br&gt;$ cd .. &lt;br&gt;$ pwd &lt;br&gt;/home/fredf&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='color:#333333'&gt;Before deleting a directory, itmust be &lt;b&gt;empty &lt;/b&gt;(&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-3-more-on.html"&gt;&lt;spanstyle='color:#336699'&gt;Learn how to delete non-empty directories&lt;/span&gt;&lt;/a&gt;),&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ rmdir cse220&lt;br&gt;rmdir: `cse220': Directory not empty &lt;br&gt;$ cd cse220 &lt;br&gt;$ rmdir assgn02 &lt;br&gt;rmdir: `assgn02': Directory not empty &lt;br&gt;$ cd assgn02 &lt;br&gt;$ rm file1.c &lt;br&gt;$ rm file2.c &lt;br&gt;$ rm file1.o &lt;br&gt;$ rm file2.o &lt;br&gt;$ rm a.out&lt;br&gt;$ ls &lt;br&gt;$ cd .. &lt;br&gt;$ rmdir assgn02 &lt;br&gt;$ cd .. &lt;br&gt;$ rmdir cse220 &lt;br&gt;$ ls a.out file1.c file3 src&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='color:#333333'&gt;The command &lt;b&gt;cd &lt;/b&gt;by itselfwill always change you back to your home directory. Remember, the symbol &lt;b&gt;~ &lt;/b&gt;alsoalways refers to your home directory as well.&lt;/span&gt;&lt;/p&gt; &lt;p class=Codeing&gt;$ cd /usr/local/bin&lt;br&gt;$ pwd /usr/local/bin&lt;br&gt;$ cd&lt;br&gt;$ pwd&lt;br&gt;/home/fredf&lt;br&gt;$ cd /usr/local/bin&lt;br&gt;$ pwd /usr/local/bin&lt;br&gt;$ cd ~&lt;br&gt;$ pwd /home/fredf&lt;br&gt;$ cd cse220&lt;br&gt;$ cd assgn02&lt;br&gt;$ pwd /home/fredf/cse220/assgn02&lt;br&gt;$ rm ~/file1.c&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;span style='color:#333333'&gt;The last command would removethe file &lt;b&gt;/home/fredf/file1.c&lt;/b&gt;.&lt;br&gt;Remember, however, that you can only delete a file if you have write privilege.&lt;/span&gt;&lt;/p&gt; &lt;p class=Links&gt;&amp;nbsp;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-file-permissions-and-chmod.html"&gt;&lt;spanstyle='color:#336699'&gt;Previous - Changing File Permissions with 'chmod' Command&lt;/span&gt;&lt;/a&gt;|&amp;nbsp; &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-file-name-globbing.html"&gt;&lt;spanstyle='color:#336699'&gt;Next - File Name Globbing with *, ?, [ ]&lt;/span&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-4185204640568560764?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/4185204640568560764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-basic-commands-part-2-creating.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/4185204640568560764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/4185204640568560764'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-basic-commands-part-2-creating.html' title='Linux Commands - Creating and Deleting Files and Directories'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-1644346860537044650</id><published>2009-10-03T23:03:00.001-07:00</published><updated>2010-09-06T01:01:23.926-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='file name globbing'/><category scheme='http://www.blogger.com/atom/ns#' term='?'/><category scheme='http://www.blogger.com/atom/ns#' term='*'/><title type='text'>Linux - File Name Globbing with *, ?, [ ]</title><content type='html'>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face	{font-family:Wingdings;	panose-1:5 0 0 0 0 0 0 0 0 0;}@font-face	{font-family:"Cambria Math";	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:10.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p	{margin:0in;	margin-bottom:.0001pt;	font-size:12.0pt;	font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}.MsoPapDefault	{margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;} /* List Definitions */ ol	{margin-bottom:0in;}ul	{margin-bottom:0in;}--&gt;&lt;/style&gt; &lt;/head&gt; &lt;body lang=EN-US link=blue vlink=purple&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux - File Name Globbing with *, ?, [ ]&lt;/p&gt; &lt;p class=MsoNormal&gt;Sometimes you want to do something to a group of files,e.g., delete all of them, without having to perform the command on each fileindividually. For example, suppose we want to delete all of the &lt;b&gt;.c &lt;/b&gt;filesin a directory. A &lt;b&gt;wildcard &lt;/b&gt;is a pattern which &lt;b&gt;matches &lt;/b&gt;somethingelse. Two commonly used *nix wildcards are &lt;b&gt;* &lt;/b&gt;(called star) and &lt;b&gt;? &lt;/b&gt;(questionmark).&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;Star(*) means 0 or more characters&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;Question Mark(?) means exactly one character&lt;/p&gt; &lt;p class=MsoListParagraph style='text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;Brackets([]) represents a set of characters&lt;/p&gt; &lt;p class=MsoNormal&gt;Commands involving filenames specified with wildcards areexpanded by the shell (this is called &lt;b&gt;globbing &lt;/b&gt;after the name of aformer program called &lt;b&gt;glob &lt;/b&gt;which used to do this outside the shell). &lt;/p&gt; &lt;p class=webH2&gt;The '*' &lt;/p&gt; &lt;p class=MsoNormal&gt;' &lt;b&gt;file*' &lt;/b&gt;will match any filename which starts withthe characters &amp;quot;file&amp;quot;, and then is followed by zero or moreoccurrences of any character.&lt;/p&gt; &lt;p class=webH4&gt;Examples&lt;/p&gt; &lt;p class=MsoNormal&gt;Suppose&lt;b&gt; Fred's&lt;/b&gt; home directory contains the files,&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;file01.cpp&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;file02.cpp&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;file03.cpp&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;file1.cpp&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;file01.o&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;file02.o&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;file03.o&lt;/p&gt; &lt;p class=MsoListParagraph style='margin-bottom:0in;margin-bottom:.0001pt;text-indent:-.25in'&gt;&lt;span style='font-family:Symbol'&gt;·&lt;span style='font:7.0pt "Times New Roman"'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;file1.o&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt'&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt'&gt;To deleteall of the &lt;b&gt;.c &lt;/b&gt;files, type,&lt;/p&gt; &lt;p class=Codeing&gt;$ rm *.c&lt;/p&gt; &lt;p class=Codeing&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;To delete file01.cpp and file01.o,&lt;/p&gt; &lt;p class=Codeing&gt;$ rm file01.*&lt;/p&gt; &lt;p class=webH2&gt;The '?'&lt;/p&gt; &lt;p class=MsoNormal&gt;The '?' represents exactly one character.&lt;/p&gt; &lt;p class=webH4&gt;Examples&lt;/p&gt; &lt;p class=MsoNormal&gt;Consider again Fred's home directory from the previousexample.&lt;/p&gt; &lt;p class=MsoNormal&gt;Delete file01.o, file02.o and file03.o, but not file1.o,&lt;/p&gt; &lt;p class=Codeing&gt;$ rm file??.o&lt;/p&gt; &lt;p class=Codeing&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;Delete file01.o, but not file01.cpp,&lt;/p&gt; &lt;p class=Codeing&gt;$ rm file01.?&lt;/p&gt; &lt;p class=webH2&gt;The '[ ]' Glob&lt;/p&gt; &lt;p class=MsoNormal&gt;A set of characters can be specified with brackets [ ]. '&lt;spanclass=CodeingChar&gt;[ab]&lt;/span&gt;' means the &lt;b&gt;single &lt;/b&gt;character can be a OR b. Rangescan also be specified (ex: '&lt;span class=CodeingChar&gt;[1-57-9]&lt;/span&gt;' represents1-5 OR 7-9).&lt;/p&gt; &lt;p class=webH4&gt;Examples &lt;/p&gt; &lt;p class=MsoNormal&gt;Delete file02.cpp and file03.cpp from Fred's directory,&lt;/p&gt; &lt;p class=Codeing&gt;$ rm file0[23].cpp&lt;/p&gt; &lt;p class=Codeing&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;This will delete any files that start with f or F (rememberlinux is case sensitive),&lt;/p&gt; &lt;p class=Codeing&gt;$rm [fF]*&lt;/p&gt; &lt;p class=Codeing&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;To delete all files which start with the string &amp;quot;&lt;b&gt;file&amp;quot;&lt;/b&gt;followed by a single letter type,&lt;/p&gt; &lt;p class=Codeing&gt;$  rm file[a-zA-Z]&lt;/p&gt; &lt;p class=MsoNormal&gt;The a-z and A-Z in the last example means all the letters inthe range lowercase a-z or uppercase A-Z. &lt;/p&gt; &lt;p class=MsoNormal&gt;There's more to wildcard matching than this, but this is enoughto get you started.&lt;/p&gt; &lt;p class=webH4&gt;More Examples&lt;/p&gt; &lt;p class=MsoNormal&gt;Remove all files that are exactly 1 character,&lt;/p&gt; &lt;p class=Codeing&gt;$rm ?&lt;/p&gt; &lt;p class=Codeing&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;Let's say you have a directory named '9-15-2007-Backup-Really-Long-Name-blah...'Rather than typing the whole name, you could just type a subset of the stringand use it with the cd command(change directory),&lt;/p&gt; &lt;p class=Codeing&gt;$ cd 9-15-2007*&lt;/p&gt; &lt;p class=MsoNormal&gt;If you have multiple folders that start with 9-15-2007, yourdirectory will be changed to the first one alphabetically.&lt;/p&gt; &lt;p class=MsoNormal&gt;You can use file name globbing on most commands that acceptfiles as arguments.&lt;/p&gt; &lt;p class=MsoNormal align=center style='text-align:center'&gt;&lt;b&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-basic-commands-part-2-creating.html"&gt;Previous- Creating and Deleting Files and Directories&lt;/a&gt; |&amp;nbsp; &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-3-more-on.html"&gt;Next- Deleting Files and Directories (part 2)&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-1644346860537044650?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/1644346860537044650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-file-name-globbing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/1644346860537044650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/1644346860537044650'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/linux-file-name-globbing.html' title='Linux - File Name Globbing with *, ?, [ ]'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4355373626380715957.post-660934262118503971</id><published>2009-10-03T22:33:00.000-07:00</published><updated>2010-09-06T01:01:23.950-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rm'/><category scheme='http://www.blogger.com/atom/ns#' term='mv'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='deleting files and directories'/><category scheme='http://www.blogger.com/atom/ns#' term='unix'/><category scheme='http://www.blogger.com/atom/ns#' term='shell'/><category scheme='http://www.blogger.com/atom/ns#' term='ls'/><category scheme='http://www.blogger.com/atom/ns#' term='command prompt'/><title type='text'>Linux Commands - Deleting Files and Directories (part 2)</title><content type='html'>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv=Content-Type content="text/html; charset=windows-1252"&gt;&lt;meta name=Generator content="Microsoft Word 12 (filtered)"&gt;&lt;style&gt; &lt;!-- /* Font Definitions */ @font-face	{font-family:"Cambria Math";	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Cambria;	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face	{font-family:Calibri;	panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}h1	{mso-style-link:"Heading 1 Char";	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:115%;	page-break-after:avoid;	font-size:10.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}a:link, span.MsoHyperlink	{color:blue;	text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed	{color:purple;	text-decoration:underline;}p	{margin:0in;	margin-bottom:.0001pt;	font-size:12.0pt;	font-family:"Times New Roman","serif";}p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing	{margin:0in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph	{margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}span.Heading1Char	{mso-style-name:"Heading 1 Char";	mso-style-link:"Heading 1";	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.msolistparagraphcxspfirst, li.msolistparagraphcxspfirst, div.msolistparagraphcxspfirst	{mso-style-name:msolistparagraphcxspfirst;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxspmiddle, li.msolistparagraphcxspmiddle, div.msolistparagraphcxspmiddle	{mso-style-name:msolistparagraphcxspmiddle;	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.msolistparagraphcxsplast, li.msolistparagraphcxsplast, div.msolistparagraphcxsplast	{mso-style-name:msolistparagraphcxsplast;	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	line-height:115%;	font-size:11.0pt;	font-family:"Calibri","sans-serif";}p.webH1, li.webH1, div.webH1	{mso-style-name:webH1;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:18.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH2, li.webH2, div.webH2	{mso-style-name:webH2;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:15.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH3, li.webH3, div.webH3	{mso-style-name:webH3;	margin-top:24.0pt;	margin-right:0in;	margin-bottom:0in;	margin-left:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:13.0pt;	font-family:"Cambria","serif";	color:#365F91;	font-weight:bold;}p.webH4, li.webH4, div.webH4	{mso-style-name:webH4;	margin:0in;	margin-bottom:.0001pt;	line-height:150%;	page-break-after:avoid;	font-size:11.0pt;	font-family:"Cambria","serif";	color:#048207;	font-weight:bold;	font-style:italic;}span.CodeingChar	{mso-style-name:"Codeing Char";	mso-style-link:Codeing;	font-family:"Courier New";	color:#C00000;}p.Codeing, li.Codeing, div.Codeing	{mso-style-name:Codeing;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpFirst, li.CodeingCxSpFirst, div.CodeingCxSpFirst	{mso-style-name:CodeingCxSpFirst;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpMiddle, li.CodeingCxSpMiddle, div.CodeingCxSpMiddle	{mso-style-name:CodeingCxSpMiddle;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:0in;	margin-left:.5in;	margin-bottom:.0001pt;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.CodeingCxSpLast, li.CodeingCxSpLast, div.CodeingCxSpLast	{mso-style-name:CodeingCxSpLast;	mso-style-link:"Codeing Char";	margin-top:0in;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:.5in;	font-size:11.0pt;	font-family:"Courier New";	color:#C00000;}p.Links, li.Links, div.Links	{mso-style-name:Links;	margin:0in;	margin-bottom:.0001pt;	text-align:center;	font-size:11.0pt;	font-family:"Calibri","sans-serif";	font-weight:bold;}p.msopapdefault, li.msopapdefault, div.msopapdefault	{mso-style-name:msopapdefault;	margin-right:0in;	margin-bottom:10.0pt;	margin-left:0in;	line-height:115%;	font-size:12.0pt;	font-family:"Times New Roman","serif";}.MsoChpDefault	{font-size:10.0pt;}.MsoPapDefault	{margin-bottom:10.0pt;	line-height:115%;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.0in 1.0in 1.0in;}div.Section1	{page:Section1;}--&gt;&lt;/style&gt; &lt;/head&gt; &lt;body lang=EN-US link=blue vlink=purple&gt; &lt;div class=Section1&gt; &lt;p class=webH1&gt;Linux Commands - Deleting Files and Directories (part 2)&lt;/p&gt; &lt;p class=webH2&gt;More on Deleting Subdirectories&lt;/p&gt; &lt;p class=MsoNormal&gt;Recall you can only delete a directory if it is empty,&lt;/p&gt; &lt;p class=Codeing&gt;$ rmdir cse220&lt;br&gt;rmdir: `cse220': Directory not empty&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;To delete all the files in a subdirectory and all of itssubdirectories and then delete the subdirectory itself, use the -r (recursive)command option with the rm command,&lt;/p&gt; &lt;p class=CodeingCxSpFirst&gt;$ rm -r cse220 &lt;br&gt;$ ls cse220&lt;br&gt;ls: cannot access cse220: No such file or directory&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;br&gt;This deletes the cse220 directory and all its contents.&lt;/p&gt; &lt;p class=MsoNormal&gt;The following is a very dangerous command(recall * is awildcard, referring to 0 or more characters),&lt;/p&gt; &lt;p class=Codeing&gt;$ cd&lt;br&gt;$ pwd&lt;br&gt;/home/fredf&lt;br&gt;$ rm -rf *&lt;br&gt;$ ls&lt;/p&gt; &lt;p class=MsoNormal&gt;Remember, the * in the &lt;b&gt;rm&lt;/b&gt; command refers to allfiles/directories in the current directory. So this command deletes everythingin your home directory (all files, all directories, all subdirectories, and allfiles in all subdirectories). The option &lt;b&gt;–f&lt;/b&gt; means force and will causeeven files marked as read-only to be deleted(if you own them).&lt;/p&gt; &lt;p class=webH2&gt;Copying Files and Directories&lt;/p&gt; &lt;p class=MsoNormal&gt;To copy a file use the cp command&lt;/p&gt; &lt;p class=Codeing&gt;cp fileSRC fileDest&lt;/p&gt; &lt;p class=webH4&gt;Examples&lt;/p&gt; &lt;p class=MsoNormal&gt;To create a copy of file1.c, named file1.c.backup,&lt;/p&gt; &lt;p class=Codeing&gt;$ cd&lt;br&gt;$ cp file1.c file1.c.backup&lt;br&gt;$ ls&lt;br&gt;a.out file1.c file1.c.backup file3 src&lt;/p&gt; &lt;p class=MsoNormal&gt;Copy a file to another directory&lt;/p&gt; &lt;p class=CodeingCxSpFirst style='margin-bottom:0in;margin-bottom:.0001pt'&gt;$mkdir cse220&lt;br&gt;$ cp file3 cse220&lt;/p&gt; &lt;p class=CodeingCxSpMiddle&gt;$ ls cse220&lt;br&gt;file3&lt;/p&gt; &lt;p class=CodeingCxSpLast&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;Copy a file to the parent directory,&lt;/p&gt; &lt;p class=CodeingCxSpFirst&gt;$cp file3 ..&lt;/p&gt; &lt;p class=CodeingCxSpMiddle&gt;$ls ..&lt;/p&gt; &lt;p class=CodeingCxSpMiddle&gt;file3&lt;/p&gt; &lt;p class=CodeingCxSpLast&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;To copy all the .c files from one directory to another,&lt;/p&gt; &lt;p class=Codeing&gt;$ mkdir src-backup&lt;br&gt;$ cp *.c src-backup&lt;br&gt;$ ls src-backup&lt;br&gt;file01.c file02.c file03.c file01.o file02.o file03.o&lt;/p&gt; &lt;p class=webH3&gt;Recursive Option (-r)&lt;/p&gt; &lt;p class=MsoNormal&gt;To copy all the files in a directory (and itssubdirectories) to another directory, use the &lt;b&gt;-r&lt;/b&gt; command line optionwith cp (-r stands for recursive),&lt;/p&gt; &lt;p class=Codeing&gt;$ cd&lt;br&gt;$ cp -r src src-backup&lt;br&gt;$ ls src-backup&lt;br&gt;file01.c file02.c file03.c file01.o file02.o file03.o&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;To copy a file from another directory to the currentdirectory, &lt;/p&gt; &lt;p class=Codeing&gt;$ cp ../dir/file .&lt;/p&gt; &lt;p class=MsoNormal&gt;&lt;b&gt;Note:&lt;/b&gt; The . is necessary in the command to specifythe destination for the file that is being copied. Without it you will get anerror message,&lt;/p&gt; &lt;p class=Codeing&gt;$ cp ../dir/file&lt;br&gt;cp: missing destination file operand after `/dir/file'&lt;br&gt;Try `cp --help' for more information.&lt;/p&gt; &lt;p class=webH2&gt;Moving and Renaming Files&lt;/p&gt; &lt;p class=MsoNormal&gt;To &lt;b&gt;move&lt;/b&gt; a file from one location to another use the &lt;b&gt;mv&lt;/b&gt;(move) command. Note that move is different from copy in that copy &amp;quot;makesa copy&amp;quot; so the original file remains where it was at. Move actually &amp;quot;&lt;b&gt;movesthe file&lt;/b&gt;&amp;quot; from one place to another, so the original is removed.  'mv'can also be used with the recursive option &lt;b&gt;-r&lt;/b&gt;.&lt;/p&gt; &lt;p class=Codeing&gt;mv fileSRC fileDest&lt;/p&gt; &lt;p class=webH4&gt;Examples&lt;/p&gt; &lt;p class=Codeing&gt;$ cd&lt;br&gt;$ ls&lt;br&gt;a.out file1.c file3 src&lt;br&gt;$ mv file1.c src&lt;br&gt;$ ls&lt;br&gt;a.out file3 src&lt;br&gt;$ ls src&lt;br&gt;file01.c file02.c file03.c file01.o file02.o file03.o file1.c&lt;br&gt;$ mv src/file1.c ../../tmp&lt;br&gt;$ ls src&lt;br&gt;file01.c file02.c file03.c file01.o file02.o file03.o&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;p class=MsoNormal&gt;To &lt;b&gt;rename&lt;/b&gt; a file in *nix you move it to a new file,e.g., to rename file1.c to file01.c,&lt;/p&gt; &lt;p class=Codeing&gt;$ mv file1.c file01.c&lt;/p&gt; &lt;p class=Links&gt;&lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-file-name-globbing.html"&gt;Previous- File Name Globbing with *, ?, [ ]&lt;/a&gt; |&amp;nbsp; &lt;ahref="http://learninglinuxcommands.blogspot.com/2009/10/linux-displaying-file-at-terminal-cat.html"&gt;Previous- Viewing Files with Cat and Less&lt;/a&gt;&lt;/p&gt; &lt;p class=MsoNormal&gt;&amp;nbsp;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4355373626380715957-660934262118503971?l=learninglinuxcommands.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://learninglinuxcommands.blogspot.com/feeds/660934262118503971/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-3-more-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/660934262118503971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4355373626380715957/posts/default/660934262118503971'/><link rel='alternate' type='text/html' href='http://learninglinuxcommands.blogspot.com/2009/10/basic-linux-commands-part-3-more-on.html' title='Linux Commands - Deleting Files and Directories (part 2)'/><author><name>Ashley Berron</name><uri>http://www.blogger.com/profile/07245493464698648861</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='29' src='http://2.bp.blogspot.com/_Wc63Ey2XsL4/Ssf78Ei8exI/AAAAAAAAAAM/sRDoP89nO8Y/S220/200474341-001.jpg'/></author><thr:total>0</thr:total></entry></feed>
