tag:blogger.com,1999:blog-3452013922201293512024-03-08T10:32:34.645-08:00Unix FAQ'ssandyhttp://www.blogger.com/profile/02503582209971047801noreply@blogger.comBlogger29125tag:blogger.com,1999:blog-345201392220129351.post-3034627100087773702009-02-24T23:29:00.000-08:002009-02-24T23:30:02.637-08:00Fundamental Unix Commands<p align="center"> </p> <p align="center"><b><span style="font-size:180%;"><br /></span></b></p> <p>So now you're logged in. Great. Now what? Unix does not present itself to you through an interface that is graphical (GUI). You know, the screen full of icons and pictorial symbols and menus for you to interact with using your mouse. While using linux on the remote server, you won't even touch your mouse. I'm not bragging, mind you, I'm not saying that's good. Just pointing it out. What the operating system <i>does </i>present is merely a prompt. A symbol that mutely stares at you waiting. For anything to happen, you're supposed to type in a command. In <i>its </i>language, not yours. So you have to know one. That requires you to learn the commands that Unix has. As opposed to a graphical interface, this style of interaction is called a command-driven or character-based interface.</p> <p>By the way, note I didn't say that Unix does not have a graphical user interface (because it does). I only said it doesn't <i>present itself </i>to you that way. Unix has an optional GUI, called the X windowing system, that can be started by issuing a certain command while in the character-based interface. But not while using telnet or ssh. So in this course, primary focus is on Unix used through its command-driven interface.</p> <p>The point is that to get beyond the prompt, you have to start learning some commands. Right now. So you won't be stuck. Using Unix effectively in command mode means mastering the use of certain commands. </p> <p>There are a whole lot of commands. Every beginning Unix tutorial seems to pick its own shortlist. The ones it thinks are the top priority. A kind of "top 10." While no particular pick is sacrosanct, it's not too hard for experienced Unix users to agree on certain high-frequency commands you should know.</p> <p>What does "know" mean? How deeply? Commands generally have a lot of formal "options." These appear in their documentation. As an example, the ls command is for the purpose of listing the contents of a directory. At its simplest people use it by typing "ls, " nothing more, and pressing the enter key. A list of filenames typically appears (try it). However, ls has an option called -l (the letter ell) which prints out a little more information about each file, in a different format. And another, the -t option, that sorts the file list into chronological order. And forty-eight other options that appear in the documentation for the ls command. You don't need to know them all. But among them there are just a few that make life easier if you know them (or harder if you don't). And it's the same for the other commands.</p> <p><a name="list"></a>I want to call to your attention a list of arguably "most important" commands. And for each, to its "most important" options. And I want you to familiarize yourself with each command option through actual use. Here's my list:</p> <p>ls - list directory contents (like MS-DOS dir)<br />cat - send file content to screen (like MS-DOS type)<br />cd - change current directory (like MS-DOS cd)<br />chmod - change file permissions<br />cp - copy files and directories (like MS-DOS copy)<br />echo - write characters to the screen<br />find - find files (slow but fresh)<br />locate - find files (faster but stale)<br />grep - print lines matching a pattern<br />less - file filter for viewing<br />man - display on-line manual pages for individual commands<br />mkdir - make directories (like MS-DOS md)<br />mv - rename/move files (like MS-DOS ren or move)<br />ps - give a process status report<br />pwd - print name of the current, working directory<br />rm - remove files and directories (like MS-DOS del)<br />rmdir - remove empty directories (like MS-DOS rd)<br /><br /><br />Here are the several variations of each command you should become familiar with:</p> <p>ls<br />list directory contents</p> <span style="font-family:Times New Roman;font-size:85%;"> <p><span style="color:#0000ff;">[david@EMACH2 fish]$ ls<br />salmon trout</span></p> </span><p>ls -l<br />long listing</p> <span style="font-family:Times New Roman;font-size:85%;"> <p><span style="color:#0000ff;">[david@EMACH2 fish]$ ls -l<br />total 8<br />-rw-r--r-- 1 david david 7 Jan 9 2000 salmon<br />-rw-r--r-- 1 david david 6 Jan 9 2000 trout</span></p> </span><p>ls -F<br />displays a slash after each directory, asterisk after each executable file, at sign after symbolic links</p> <p>ls -a<br />displays all files, including invisible ones (those whose filenames begin with a period)</p> <p>ls -t<br />displays files in order by the time of last modification</p> <p>ls -R<br />recursively lists subdirectories</p> <span style="font-family:Times New Roman;font-size:85%;"> </span><p><span style="font-family:Times New Roman;font-size:85%;"><span style="color:#0000ff;">[david@EMACH2 animal]$ ls -R<br />.:<br />amphibian bird fish insect mammal reptile</span></span></p> <p><span style="font-family:Times New Roman;font-size:85%;"><span style="color:#0000ff;">amphibian:<br />frog newt</span></span></p> <p><span style="font-family:Times New Roman;font-size:85%;"><span style="color:#0000ff;">bird:<br />crow robin</span></span></p> <p><span style="font-family:Times New Roman;font-size:85%;"><span style="color:#0000ff;">fish:<br />salmon trout</span></span></p> <p><span style="font-family:Times New Roman;font-size:85%;"><span style="color:#0000ff;">insect:<br />ant mosquito</span></span></p> <p><span style="font-family:Times New Roman;font-size:85%;"><span style="color:#0000ff;">mammal:<br />cat horse</span></span></p> <p><span style="font-family:Times New Roman;font-size:85%;"><span style="color:#0000ff;">reptile:<br />lizard turtle</span></span></p> <p>cd<br />makes your home directory the current, working directory (see pwd)</p> <span style="font-family:Times New Roman;font-size:85%;"> <p><span style="color:#0000ff;">[david@EMACH2 log]$ pwd<br />/var/log<br />[david@EMACH2 log]$ cd<br />[david@EMACH2 david]$ pwd<br />/home/david</span></p> </span><p>cd <fully><br />makes the specified directory the current, working directory</p> <span style="font-family:Times New Roman;font-size:85%;"> <p><span style="color:#0000ff;">[david@EMACH2 david]$ cd /usr/src/linux<br />[david@EMACH2 linux]$ pwd<br />/usr/src/linux</span></p> </span><p>cd <relative><br />makes the specified directory, which must be under the initial working directory, the new working directory</p> <span style="font-family:Times New Roman;font-size:85%;"> </span><p><span style="font-family:Times New Roman;font-size:85%;"><span style="color:#0000ff;">[david@EMACH2 taxonomy]$ pwd<br />/home/david/taxonomy<br />david@EMACH2 taxonomy]$ ls -F<br />animal/ mineral/ vegetable/<br />[david@EMACH2 taxonomy]$ cd mineral/<br />[david@EMACH2 mineral]$ pwd<br />/home/david/taxonomy/mineral</span></span></p> <p>cp <source> <destination><br />creates a copy of the source file, applying the given destination file name to it</p> <p>cp <source> <destination><br />creates a copy of the source file, without changing its name, in the given destination directory</p> <p>cp -r <source> <destination><br />recursive. If any of the source files is a directory, all its contents plus those of any of its subdirectories are copied into the given destination directory</p> <p>cp -p<br />preserves each file's characteristics when copying it (owner, group, permissions, modifications times)</p> <p>mv Afile B<br />renames a file (Afile is an existing file, B is a new name for it)</p> <p>mv Xdir Y<br />renames a directory (Xdir is an existing directory, Y is a new name for it)</p> <p>mv Afile Xdir<br />moves a file into a specified directory (Afile is an existing file, Xdir is an existing directory)</p> <p>rm -i <file-list><br />removes files, interactively (asks before removing each file)</p> <p>rm -f <file-list><br />removes files with "force" (doesn't ask)</p> <p>rm -r <file-list><br />removes files recursively, including those found in all subdirectories of the one specified (or current working directory if none specified) </p> <p>rm -rf *<br />removes all files in the current and subordinate directories, and also those directories. Potentially dangerous if executed from within the wrong directory.</p> <p>cat Afile Bfile > Cfile<br />concatenate (paste together end to end) contents of two files, send result (>) to a new file (result: C = A + B)</p> <p>cat /etc/lilo.conf<br />extract contents of the file, send result to the terminal</p> <p>cat -n<br />number the lines as they are output</p> <p>cat --show-all<br />show non-printing as well as printing characters (e.g., tabs, linefeeds)</p> <p>man <command><br />display documentation for the named command, explaining all its options just as we're doing here</p> <p>less<br />prints contents of a file (or other input) one screenful at a time to prevent scrolling out of sight. Press enter to advance a line, spacebar to advance a full screen, : q to exit.</p> <p>grep <target> <files><br />searches for a pattern in files. Frequently used to print all lines in file containing a certain word or phrase</p> <p><command> | grep <target><br />searches the output produced by a command (in place of the contents of a file) for a pattern</p> <p>grep -v <target><br />reverses search outcome, searching for lines the do NOT contain the target pattern</p> <p>ps<br />process status. Displays status information about active processes that your terminal controls including PID (process id) numbers</p> <p><span style="font-family:Times New Roman;font-size:85%;color:#0000ff;">[david@EMACH2 david]$ ps<br />PID TTY TIME CMD<br />1235 pts/0 00:00:00 bash<br />1820 pts/0 00:00:00 ps</span></p> <p>ps ax<br />displays status information about all processes</p> <p>chmod u+r <file-list><br />add to or remove from (+ or -) a file(s) any of 3 different kinds of permission (r or w or x) for any of 3 different user constituencies (u or g or o)<br />used to restrict/extend access to others, and to enable script execution</p> <p>chmod 777<br />same, simultaneously setting multiple permissions using a numeric notation</p> <p>locate <filename><br />search for files on the computer (fast and stale)</p> <p>find / -name <targetfile> -print<br />search for files on the computer (slow and fresh)</p> <p>Note that there are a number of different kinds of "Unix." And there are some command differences among them. They have the great majority of the commands in common, but sometimes a command with which you are familiar in one version of Unix isn't included in another one. One of the kinds of Unix that is widely popular is called FreeBSD. The one used on the remote server is Linux. Are such different versions the same?? They are like <i>different</i> dialects of the <i>same</i> language (English in New Zealand, Canada, Scotland, South Africa, ...). There is both a little difference and a lot of similarity. But a lot more same than different.</p> <p>Below are some links to other peoples' "top 10" command sets, and a linux command "cheatsheet" you might print out. Spend some time exploring them.</p> <p><a href="http://www.justlinux.com/nhf/Command_Reference">One</a></p> <p><a href="http://www.control-escape.com/lx-translate.html">... and another</a></p> <p>Linux command cheatsheet:<br /> <a href="http://homepage.smc.edu/morgan%5Fdavid/cs40/images/command-cheatsheet1.jpg">page1</a> <a href="http://homepage.smc.edu/morgan%5Fdavid/cs40/images/command-cheatsheet2.jpg">page 2</a></p>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-36522327630732478252008-10-15T04:35:00.000-07:002008-12-23T00:12:05.690-08:00 An Overview of the UNIX* Operating System<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>X-NONE</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="0" name="header"> <w:lsdexception locked="false" priority="0" name="footer"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="0" name="page number"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="0" name="Body Text"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Cite"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="HTML Typewriter"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink {mso-style-noshow:yes; mso-style-unhide:no; color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {mso-style-noshow:yes; mso-style-priority:99; color:purple; mso-themecolor:followedhyperlink; text-decoration:underline; text-underline:single;} strong {mso-style-unhide:no; mso-style-qformat:yes; mso-bidi-font-weight:normal;} p.H2, li.H2, div.H2 {mso-style-name:H2; mso-style-unhide:no; mso-style-next:Normal; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:3; font-size:18.0pt; mso-bidi-font-size:10.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; layout-grid-mode:line; font-weight:bold; mso-bidi-font-weight:normal;} p.H3, li.H3, div.H3 {mso-style-name:H3; mso-style-unhide:no; mso-style-next:Normal; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:4; font-size:14.0pt; mso-bidi-font-size:10.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; layout-grid-mode:line; font-weight:bold; mso-bidi-font-weight:normal;} p.H4, li.H4, div.H4 {mso-style-name:H4; mso-style-unhide:no; mso-style-next:Normal; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt; margin-left:0in; mso-pagination:widow-orphan; page-break-after:avoid; mso-outline-level:5; font-size:12.0pt; mso-bidi-font-size:10.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman"; layout-grid-mode:line; font-weight:bold; mso-bidi-font-weight:normal;} .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;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:1.0in; mso-footer-margin:1.0in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:-2; mso-list-type:simple; mso-list-template-ids:-1;} @list l0:level1 {mso-level-start-at:0; mso-level-text:*; mso-level-tab-stop:none; mso-level-number-position:left; margin-left:0in; text-indent:0in;} @list l0:level1 lfo1 {mso-level-number-format:bullet; mso-level-numbering:continue; mso-level-text:; mso-level-tab-stop:none; mso-level-number-position:left; mso-level-legacy:yes; mso-level-legacy-indent:.25in; mso-level-legacy-space:0in; text-indent:-.25in; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]-->
<br /><p class="MsoNormal">The UNIX<span style=""><b style="">Error! Hyperlink reference not valid.</b></span> operating system was designed to let a number of programmers access the computer at the same time and share its resources.</p> <p class="MsoNormal">The operating system coordinates the use of the computer's resources, allowing one person, for example, to run a spell check program while another creates a document, lets another edit a document while another creates graphics, and lets another user format a document -- all at the same time, with each user oblivious to the activities of the others.</p> <p class="MsoNormal">The operating system controls all of the commands from all of the keyboards and all of the data being generated, and permits each user to believe he or she is the only person working on the computer.</p> <p class="MsoNormal">This real-time sharing of resources make UNIX one of the most powerful operating systems ever.</p> <p class="MsoNormal">Although UNIX was developed by programmers for programmers, it provides an environment so powerful and flexible that it is found in businesses, sciences, academia, and industry. Many telecommunications switches and transmission systems also are controlled by administration and maintenance systems based on UNIX.</p> <p class="MsoNormal">While initially designed for medium-sized minicomputers, the operating system was soon moved to larger, more powerful mainframe computers. As personal computers grew in popularity, versions of UNIX found their way into these boxes, and a number of companies produce UNIX-based machines for the scientific and programming communities.</p> <p class="H3">The uniqueness of UNIX</p> <p class="MsoNormal">The features that made UNIX a hit from the start are:</p> <ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">Multitasking capability </li><li class="MsoNormal" style="">Multiuser capability </li><li class="MsoNormal" style="">Portability </li><li class="MsoNormal" style="">UNIX programs </li><li class="MsoNormal" style="">Library of application software </li></ul> <p class="H4">Multitasking</p> <p class="MsoNormal">Many computers do just one thing at a time, as anyone who uses a PC or laptop can attest. Try logging onto your company's network while opening your browser while opening a word processing program. Chances are the processor will freeze for a few seconds while it sorts out the multiple instructions.</p> <p class="MsoNormal">UNIX, on the other hand, lets a computer do several things at once, such as printing out one file while the user edits another file. This is a major feature for users, since users don't have to wait for one application to end before starting another one.</p> <p class="H4">Multiusers</p> <p class="MsoNormal">The same design that permits multitasking permits multiple users to use the computer. The computer can take the commands of a number of users -- determined by the design of the computer -- to run programs, access files, and print documents at the same time.</p> <p class="MsoNormal">The computer can't tell the printer to print all the requests at once, but it does prioritize the requests to keep everything orderly. It also lets several users access the same document by compartmentalizing the document so that the changes of one user don't override the changes of another user.</p> <p class="H4">System portability</p> <p class="MsoNormal">A major contribution of the UNIX system was its portability, permitting it to move from one brand of computer to another with a minimum of code changes. At a time when different computer lines of the same vendor didn't talk to each other -- yet alone machines of multiple vendors -- that meant a great savings in both hardware and software upgrades.</p> <p class="MsoNormal">It also meant that the operating system could be upgraded without having all the customer's data inputted again. And new versions of UNIX were backward compatible with older versions, making it easier for companies to upgrade in an orderly manner.</p> <p class="H4">UNIX tools</p> <p class="MsoNormal">UNIX comes with hundreds of programs that can divided into two classes:</p> <ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style=""><strong>Integral utilities</strong> that are absolutely necessary for the operation of the computer, such as the command interpreter, and </li><li class="MsoNormal" style=""><strong>Tools</strong> that aren't necessary for the operation of UNIX but provide the user with additional capabilities, such as typesetting capabilities and e-mail. </li></ul> <p class="MsoNormal" style="text-align: center;" align="center"><strong>Tools can be added or removed from a UNIX system, depending upon the applications required.</strong></p> <p class="H4">UNIX Communications</p> <p class="MsoNormal">E-mail is commonplace today, but it has only come into its own in the business community within the last 10 years. Not so with UNIX users, who have been enjoying e-mail for several decades.</p> <p class="MsoNormal">UNIX e-mail at first permitted users on the same computer to communicate with each other via their terminals. Then users on different machines, even made by different vendors, were connected to support e-mail. And finally, UNIX systems around the world were linked into a world wide web decades before the development of today's World Wide Web.</p> <p class="H4">Applications libraries</p> <p class="MsoNormal">UNIX as it is known today didn't just develop overnight. Nor were just a few people responsible for it's growth. As soon as it moved from Bell Labs into the universities, every computer programmer worth his or her own salt started developing programs for UNIX.</p> <p class="MsoNormal">Today there are hundreds of UNIX applications that can be purchased from third-party vendors, in addition to the applications that come with UNIX.</p> <p class="H3">How UNIX is organized</p> <p class="MsoNormal">The UNIX system is functionally organized at three levels:</p> <ul style="margin-top: 0in;" type="disc"><li class="MsoNormal" style="">The kernel, which schedules tasks and manages storage; </li><li class="MsoNormal" style="">The shell, which connects and interprets users' commands, calls programs from memory, and executes them; and </li><li class="MsoNormal" style="">The tools and applications that offer additional functionality to the operating system </li></ul> <p class="MsoNormal" style="text-align: center;" align="center"><strong>The three levels of the UNIX system: kernel, shell, and tools and applications.</strong></p> <p class="H4">The kernel</p> <p class="MsoNormal">The heart of the operating system, the kernel controls the hardware and turns part of the system on and off at the programer's command. If you ask the computer to list (<i style="">ls</i>) all the files in a directory, the kernel tells the computer to read all the files in that directory from the disk and display them on your screen.</p> <p class="H4">The shell</p> <p class="MsoNormal">There are several types of shell, most notably the command driven Bourne Shell and the C Shell (no pun intended), and menu-driven shells that make it easier for beginners to use. Whatever shell is used, its purpose remains the same -- to act as an interpreter between the user and the computer.</p> <p class="MsoNormal">The shell also provides the functionality of "pipes," whereby a number of commands can be linked together by a user, permitting the output of one program to become the input to another program.</p> <p class="H4">Tools and applications</p> <p class="MsoNormal">There are hundreds of tools available to UNIX users, although some have been written by third party vendors for specific applications. Typically, tools are grouped into categories for certain functions, such as word processing, business applications, or programming.</p> <p class="H3">References</p> <p class="MsoNormal">Want to know <a href="file:///D:/My%20Docs%20From%20Cell/moreinfo.html">more about UNIX</a>?</p> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com1tag:blogger.com,1999:blog-345201392220129351.post-81728368551449986102008-10-15T04:30:00.000-07:002008-12-23T00:12:05.690-08:00Unix File System<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///D:%5CUSERPR%7E1%5Csshende%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>X-NONE</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="0" name="header"> <w:lsdexception locked="false" priority="0" name="footer"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="0" name="page number"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="0" name="Body Text"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="0" name="Hyperlink"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="0" name="Normal (Web)"> <w:lsdexception locked="false" priority="0" name="HTML Cite"> <w:lsdexception locked="false" priority="0" name="HTML Preformatted"> <w:lsdexception locked="false" priority="0" name="HTML Typewriter"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:"Times New Roman";} .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;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";} </style> <![endif]--> <p class="MsoNormal"><span style=""> </span>UNIX Unleashed, System Administrator's Edition</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">- 18 -</p> <p class="MsoNormal">File System and Disk Administration</p> <p class="MsoNormal">By Steve Shah</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This chapter discusses the trials and tribulations of creating, maintaining, and repairing file systems. While these tasks may appear simple from a user's standpoint, they are, in fact, intricate and contain more than a handful of nuances . In the course of this chapter, we'll step through many of these nuances and, hopefully, come to a strong understanding of the hows and whys of file systems.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Before we really jump into the topic, you should have a good understanding of UNIX directories, files, permissions, and paths. These are the key building blocks in understanding how to administer your file systems, and I assume you already have a mastery of them. If the statement, "Be sure to have /usr/bin before /usr/local/bin in your $PATH" confuses you in any way, you should be reading something more fundamental first. Refer to Part I, "Introduction to UNIX," for some basic instructions in UNIX.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This chapter goes about the explanation of file systems a bit differently than other books. We first discuss the maintenance and repair of file systems, then discuss their creation. This was done because it is more likely that you already have existing file systems you need to maintain and fix. Understanding how to maintain them also helps you better understand why file systems are created the way they are.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The techniques we cover here are applicable to most UNIX systems currently in use. The only exceptions are when we actually create the file systems. This is where the most deviation from any standard (if there ever was one) occurs. We cover the creation of file systems under the SunOS, Solaris, Linux, and IRIX implementations of UNIX. If you are not using one of these operating systems, you should check the documentation that came with your operating system for details on the creation of file systems. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">CAUTION: Working with file systems is inherently dangerous. You may be surprised at how quickly and easily you can damage a file system beyond repair. In some instances, it is even possible to damage the disk drive as well. BE CAREFUL. When performing the actions explained in this chapter, be sure you have typed the commands in correctly and you understand the resulting function fully before executing it. When in doubt, consult the documentation that came from the manufacturer. Most importantly, the documentation that comes from the manufacturer is always more authoritative than any book. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">NOTE: You should read the entire chapter before actually performing any of the tasks below. This will give you a better understanding of how all the components work together, thereby giving you more solid ground when performing potentially dangerous activities. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">What Is a File System</p> <p class="MsoNormal">The file system is the primary means of file storage in UNIX. Each file system houses directories, which, as a group, can be placed almost anywhere in the UNIX directory tree. The topmost level of the directory tree, the root directory, begins at /. Subdirectories nested below the root directory may traverse as deep as you like so long as the longest absolute path is less than 1,024 characters.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">With the proliferation of vendor-enhanced versions of UNIX, you will find a number of "enhanced" file systems. From the standpoint of the administrator, you shouldn't have to worry about the differences too much. The two instances where you will need to worry about vendor-specific details are in the creation of file systems and when performing backups. We will cover the specifics of: </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">SunOS 4.1.x, which uses 4.2 </p> <p class="MsoNormal">Solaris, which uses ufs </p> <p class="MsoNormal">Linux, which uses ext2 </p> <p class="MsoNormal">IRIX, which uses efs and xfs </p> <p class="MsoNormal">Note that the ufs and 4.2 file systems are actually the same.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">A file system, however, is only a part of the grand scheme of how UNIX keeps its data on disk. At the top level, you'll find the disks themselves. These disks are then broken into partitions, each varying in size depending on the needs of the administrator. It is on each partition that the actual file system is laid out. Within the file system, you'll find directories, subdirectories, and, finally, the individual files.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Although you will rarely have to deal with the file system at a level lower than the individual files stored on it, it is critical that you understand two key concepts: inodes and the superblock. Once you understand these, you will find that the behavior and characteristics of files make more sense. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">inodes</p> <p class="MsoNormal">An inode maintains information about each file. Depending on the type of file system, the inode can contain upwards of 40+ pieces of information. Most of it, however, is only useful to the kernel and doesn't concern us. The fields that do concern us are</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">mode The permission mask and type of file. </p> <p class="MsoNormal">link count The number of directories that contain an entry with this inode number. </p> <p class="MsoNormal">user ID The ID of the file's owner. </p> <p class="MsoNormal">group ID The ID of the file's group. </p> <p class="MsoNormal">size Number of bytes in this file. </p> <p class="MsoNormal">access time The time at which the file was last accessed. </p> <p class="MsoNormal">mod time The time at which the file was last modified. </p> <p class="MsoNormal">inode time The time at which this inode structure was last modified. </p> <p class="MsoNormal">block list A list of disk block numbers which contain the first segment of the file. </p> <p class="MsoNormal">indirect list A list of other block lists. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The mode, link count, user ID, group ID, size, and access time are used when generating file listings. Note that the inode does not contain the file's name. That information is held in the directory file (see below for details). </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Superblocks</p> <p class="MsoNormal">This is the most vital information stored on the disk. It contains information on the disk's geometry (number of heads, cylinders, and so on), the head of the inode list, and free block list. Because of its importance, the system automatically keeps mirrors of this data scattered around the disk for redundancy. You only have to deal with superblocks if your file system becomes heavily corrupted. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Types of Files</p> <p class="MsoNormal">Files come in 8 flavors: </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Normal Files </p> <p class="MsoNormal">Directories </p> <p class="MsoNormal">Hard Links </p> <p class="MsoNormal">Symbolic links </p> <p class="MsoNormal">Sockets </p> <p class="MsoNormal">Named Pipes </p> <p class="MsoNormal">Character Devices </p> <p class="MsoNormal">Block Devices </p> <p class="MsoNormal">Normal Files These are the files you use the most. They can be either text or binary files; however, their internal structure is irrelevant from a System Administrator standpoint. A file's characteristics are specified by the inode in the file system that describes it. An ls -l on a normal file will look something like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">-rw-------<span style=""> </span>1 sshah<span style=""> </span>admin<span style=""> </span>42 May 12 13:09 hello</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Directories These are a special kind of file that contains a list of other files. Although there is a one-to-one mapping of inode to disk blocks, there can be a many-to-one mapping from directory entry to inode. When viewing a directory listing using the ls -l command, you can identify directories by their permissions starting with the d character. An ls -l on a directory looks something like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">drwx------<span style=""> </span>2 sshah<span style=""> </span>admin<span style=""> </span>512 May 12 13:08 public_html</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Hard Links</p> <p class="MsoNormal">A hard link is actually a normal directory entry except instead of pointing to a unique file , it points to an already existing file . This gives the illusion that there are two identical files when you do a directory listing. Because the system sees this as just another file, it treats it as such. This is most apparent during backups because hard-linked files get backed up as many times as there are hard links to them. Because a hard link shares an inode, it cannot exist across file systems. Hard links are created with the ln command. For example, given this directory listing using ls -l, we see:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">-rw-------<span style=""> </span>1 sshah<span style=""> </span>admin<span style=""> </span>42 May 12 13:04 hello</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">When you type ln hello goodbye and then perform another directory listing using ls -l, you see:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">-rw-------<span style=""> </span>2 sshah<span style=""> </span>admin<span style=""> </span>42 May 12 13:04 goodbye</p> <p class="MsoNormal">-rw-------<span style=""> </span>2 sshah<span style=""> </span>admin<span style=""> </span>42 May 12 13:04 hello</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Notice how this appears to be two separate files that just happen to have the same file lengths. Also note that the link count (second column) has increased from one to two. How can you tell they actually are the same file? Use ls -il. Observe:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">13180 -rw-------<span style=""> </span>2 sshah<span style=""> </span>admin<span style=""> </span>42 May 12 13:04 goodbye</p> <p class="MsoNormal">13180 -rw-------<span style=""> </span>2 sshah<span style=""> </span>admin<span style=""> </span>42 May 12 13:04 hello</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">You can see that both point to the same inode, 13180. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">WARNING: Be careful when creating hardlinks, especially when hardlinking to a directory. It is possible to corrupt a filesystem by doing so since the hardlink does not contain the fact that the i-node being pointed to needs to be treated as a directory. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Symbolic Links</p> <p class="MsoNormal">A symbolic link (sometimes referred to as a symlink) differs from a hard link because it doesn't point to another inode but to another filename. This allows symbolic links to exist across file systems as well as be recognized as a special file to the operating system. You will find symbolic links to be crucial to the administration of your file systems, especially when trying to give the appearance of a seamless system when there isn't one. Symbolic links are created using the ln -s command. A common thing people do is create a symbolic link to a directory that has moved. For example, if you are accustomed to accessing the directory for your home page in the subdirectory www but at the new site you work at, home pages are kept in the public_html directory, you can create a symbolic link from www to public_html using the command ln -s public_html www. Performing an ls -l on the result shows the link.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">drwx------<span style=""> </span>2 sshah<span style=""> </span>admin<span style=""> </span>512 May 12 13:08 public_html</p> <p class="MsoNormal">lrwx------<span style=""> </span>1 sshah<span style=""> </span>admin<span style=""> </span>11 May 12 13:08 www -> public_html</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Sockets</p> <p class="MsoNormal">Sockets are the means for UNIX to network with other machines. Typically, this is done using network ports; however, the file system has a provision to allow for interprocess communication through socket files. (A popular program that uses this technique is the X Windows system.) You rarely have to deal with this kind of file and should never have to create it yourself (unless you're writing the program). If you need to remove a socket file, use the rm command. Socket files are identified by their permission settings beginning with an s character. An ls -l on a socket file looks something like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">srwxrwxrwx<span style=""> </span>1 root<span style=""> </span>admin<span style=""> </span>0 May 10 14:38 X0</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Named Pipes</p> <p class="MsoNormal">Similar to sockets, named pipes enable programs to communicate with one another through the file system. You can use the mknod command to create a named pipe. Named pipes are recognizable by their permissions settings beginning with the p character. An ls -l on a named pipe looks something like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">prw-------<span style=""> </span>1 sshah<span style=""> </span>admin<span style=""> </span>0 May 12 22:02 mypipe</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Character Devices</p> <p class="MsoNormal">These special files are typically found in the /dev directory and provide a mechanism for communicating with system device drivers through the file system one character at a time. They are easily noticed by their permission bits starting with the c character. Each character file contains two special numbers, the major and minor. These two numbers identify which device driver that file communicates with. An ls -l on a character device looks something like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">crw-rw-rw-<span style=""> </span>1 root<span style=""> </span>wheel<span style=""> </span>21,<span style=""> </span>4 May 12 13:40 ptyp4</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Block Devices</p> <p class="MsoNormal">Block devices also share many characteristics with character devices in that they exist in the /dev directory, are used to communicate with device drivers, and have major and minor numbers. The key difference is that block devices typically transfer large blocks of data at a time versus one character at a time. (A hard disk is a block device, whereas a terminal is a character device.) Block devices are identified by their permission bits starting with the b character. An ls -l on a block device looks something like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">brw-------<span style=""> </span>2 root<span style=""> </span>staff<span style=""> </span>16,<span style=""> </span>2 Jul 29<span style=""> </span>1992 fd0c</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Managing File Systems</p> <p class="MsoNormal">Managing file systems is relatively easy. That is, once you can commit to memory the location of all the key files in the directory tree on each major variation of UNIX as well as your own layout of file systems across the networkÉ</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">In other words, it can be a royal pain.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">From a technical standpoint there isn't much to deal with. Once the file systems have been put in their correct places and the boot time configuration files have been edited so that your file systems automatically come online at every start up, there isn't much to do besides watch your disk space.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">From a management standpoint, it's much more involved. Often you'll need to deal with existing configurations, which may not have been done "the right way," or you're dealing with site politics such as, "I won't let that department share my disks." Then you'll need to deal with users who don't understand why they need to periodically clean up their home directories. Don't forget the ever exciting vendor-specific nuisances and their idea of how the system "should be" organized.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This section covers the tools you need to manage the technical issues. Unfortunately, managerial issues are something that can't be covered in a book. Each site has different needs as well as different resources, resulting in different policies. If your site lacks any written policy, take the initiative to write one yourself. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Mounting and Unmounting File Systems</p> <p class="MsoNormal">As I mentioned earlier in this chapter, part of the power in UNIX stems from its flexibility in placing file systems anywhere in the directory tree. This feat is accomplished by mounting file systems.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Before you can mount a file system, you need to select a mount point. A mount point is the directory entry in the file system where the root directory of a different file system will overlay it. UNIX keeps track of mount points, and accesses the correct file system, depending on which directory the user is currently in. A mount point may exist anywhere in the directory tree. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">NOTE: While it is technically true that you can mount a file system anywhere in the directory tree, there is one place you will NOT want to mount it: the root directory. Remember that once a file system is mounted at a directory, that directory is overshadowed by the contents of the mounted file system. Hence, by mounting on the root directory, the system will no longer be able to see its own kernel or local configuration files. How long your system goes on before crashing depends on your vendor.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">There is an exception to the rule. Some installation packages will mount a network file system to the root directory. This is done to give the installation software access to many packages that may not be able to fit on your boot disk. Unless you fully understand how to do this yourself, don't. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Mounting and Unmounting File Systems Manually To mount a file system, use the mount command:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">mount /dev/device /directory/to/mount</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where /dev/device is the device name you want to mount and /directory/to/mount is the directory you want to overlay in your local file system. For example, if you wanted to mount /dev/hda4 to the /usr directory, you would type:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">mount /dev/hda4 /usr</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Remember that the directory must exist in your local file system before anything can be mounted there.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">There are options that can be passed to the mount command. The most important characteristics are specified in the -o option. These characteristics are:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">rw<span style=""> </span>read/write</p> <p class="MsoNormal">ro<span style=""> </span>read only</p> <p class="MsoNormal">bg<span style=""> </span>background mount (if the mount fails,</p> <p class="MsoNormal"><span style=""> </span>place the process into the background</p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>and keep trying until success.)</p> <p class="MsoNormal">intr<span style=""> </span>interruptible mount (if a process is</p> <p class="MsoNormal"><span style=""> </span>pending I/O on a mounted partition, it</p> <p class="MsoNormal"><span style=""> </span>will allow the process to be interrupted</p> <p class="MsoNormal"><span style=""> </span>and the I/O call dropped)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">An example of these parameters being used is:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">mount -o rw,bg,intr /dev/hda4 /usr</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">See the man page on your system for vendor specific additions.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To unmount a file system, use the umount command. For example:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">umount /usr</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This unmounts the /usr file system from the current directory tree, unveiling the original directory underneath it.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">There is, of course, a caveat. If users are using files on a mounted file system, you cannot unmount it. All files must be closed before this can happen, which on a large system can be tricky to say the least. There are three ways to handle this: </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Use the lsof program (available at ftp://vic.cc.purdue.edu/pub/tools/unix/lsof) to list the users and their open files on a given file system. Then either wait until they are done, beg them to leave, or kill their processes off. Then unmount the file system. Often, this isn't very desirable. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Use the -f option with umount command to force the unmount. This is often a bad idea because it leaves the programs (and users) accessing the partition confused. Files which are in memory that have not been committed to disk may be lost. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Bring the system to single user mode, then unmount the file system. While the largest inconvenience, it is the safest way because no one loses any work. </p> <p class="MsoNormal">Mounting File Systems Automatically At boot time, the system automatically mounts the root file system with read-only privileges. This enables it to load the kernel and read critical startup files. However, once it has bootstrapped itself, it needs guidance. Although it is possible for you to mount all the file systems by hand, it isn't realistic because you would then have to finish bootstrapping the machine yourself, and worse, the system could not come back online by itself. (Unless, of course, you enjoy coming into work at 2 a.m. to bring a system back up.)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To get around this, UNIX uses a special file called /etc/fstab (/etc/vfstab under Solaris). This file lists all the partitions that need to be mounted at boot time and the directory where they need to be mounted. Along with that information you can pass parameters to the mount command.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Each file system to be mounted is listed in the fstab file in the following format:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">/dev/device<span style=""> </span>/dir/to/mount<span style=""> </span>ftype parameters fs_freq fs_passno</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">/dev/device Is the device to be mounted, for instance, /dev/hda4. </p> <p class="MsoNormal">/dir/to/mount Is the location at which the file system should be mounted on your directory tree. </p> <p class="MsoNormal">ftype Is the file system type. This should be 4.2 under SunOS, ufs under Solaris, ext2 under Linux, efs or xfs in IRIX (depending on your version), nfs for NFS mounted file systems, swap for swap partitions, and proc for the /proc file system. Some operating systems, such as Linux, support additional filesystem types, although they are not as likely to be used. </p> <p class="MsoNormal">parameters Are the parameters we passed to mount using the -o option. They follow the same comma-delineated format. An example entry would look like rw,intr,bg. </p> <p class="MsoNormal">fs_freq Is used by dump to determine whether a file system needs to be dumped. </p> <p class="MsoNormal">fs_passno Is used by the fsck program to determine the order to check disks at boot time. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Any lines in the fstab file that start with the pound symbol (#) are considered comments.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If you need to mount a new file system while the machine is live, you must perform the mount by hand. If you wish to have this mount automatically active the next time the system is rebooted, you should be sure to add the appropriate entry to your fstab file.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">There are two notable partitions that don't follow the same set of rules as normal partitions. They are the swap partition and /proc. (Note that SunOS does not use the /proc file system.)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Mounting the swap partition is not done using the mount command. It is instead managed by the swap command under Solaris and IRIX, and by the swapon command under SunOS and Linux. In order for a swap partition to be mounted, it must be listed in the appropriate fstab file. Once it's there, use the appropriate command (swap or swapon) with the -a parameter followed by the partition on which you've allocated swap space.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The /proc file system is even stranger because it really isn't a file system. It is an interface to the kernel abstracted into a file system style format. This should be listed in your fstab file with file system type proc. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">TIP: If you need to remount a file system that already has an entry in the fstab file, you don't need to type in the mount command with all the parameters. Instead, simply pass the directory to mount as a parameter like this: </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">mount /dir/to/mount </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">mount automatically looks to the fstab file for all the details, such as which partition to mount and which options to use.</p> <p class="MsoNormal">If you need to remount a large number of file systems that are already listed in the fstab file (in other words, you need to remount directories from a system that has gone down), you can use the -a option in the mount command to try and remount all the entries in the fstab file like this: </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">mount -a </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If mount finds that a file system is already mounted, no action is performed on that file system. If, on the other hand, mount finds that an entry is not mounted, it automatically mounts it with the appropriate parameters. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Here is a complete fstab file from a SunOS systems:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">#</p> <p class="MsoNormal"># Sample /etc/fstab file for a SunOS machine</p> <p class="MsoNormal">#</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># Local mounts</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">/dev/sd0a<span style=""> </span>/<span style=""> </span>4.2<span style=""> </span>rw<span style=""> </span>1 1</p> <p class="MsoNormal">/dev/sd0g<span style=""> </span>/usr<span style=""> </span>4.2<span style=""> </span>rw<span style=""> </span>1 2</p> <p class="MsoNormal">/dev/sd0b<span style=""> </span><span style=""> </span>swap<span style=""> </span>swap<span style=""> </span>rw<span style=""> </span>0 0</p> <p class="MsoNormal">/dev/sd0d<span style=""> </span>/var<span style=""> </span>4.2<span style=""> </span>rw<span style=""> </span>0 0</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># Remote mounts</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">server1:/export/home<span style=""> </span>/home<span style=""> </span>nfs<span style=""> </span>rw,bg,intr<span style=""> </span>0 0</p> <p class="MsoNormal">server1:/export/usr/local<span style=""> </span>/usr/local<span style=""> </span>nfs<span style=""> </span>rw,bg,intr<span style=""> </span>0 0</p> <p class="MsoNormal">server2:/export/var/spool/mail<span style=""> </span>/var/spool/mail<span style=""> </span>nfs<span style=""> </span>rw,bg,intr<span style=""> </span>0 0</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Common Commands for File System Management</p> <p class="MsoNormal">In taking care of your system, you'll quickly find that you can use these commands and many of their parameters without having to look them up. This is because you're going to be using them all the time. I highly suggest you learn to love them. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">NOTE: In reading this book you may have noticed the terms program and command are used interchangably. This is because there are no "built in" commands to the system, each one is invoked as an individual program. However, you will quickly find that both the people who use UNIX, as well as UNIX related texts (such as this one), use the both terms to mean the same thing. Confusing? A bit. But it's tough to change 25+ years of history. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">NOTE: At the end of each command description, I mention the GNU equivalent. Linux users shouldn't worry about getting them, because Linux ships with all GNU tools. If you are using another platform and aren't sure whether you're using the GNU version, try running the command with the --version option. If it is GNU, it will display its title and version number. If it isn't GNU, it'll most likely reject the parameter and give an error. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">df The df command summarizes the free disk space by file system. Running it without any parameters displays all the information about normally mounted and NFS mounted file systems. The output varies from vendor to vendor (under Solaris, use df -t) but should closely resemble this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Filesystem<span style=""> </span>1024-blocks<span style=""> </span>Used Available Capacity Mounted on</p> <p class="MsoNormal">/dev/hda3<span style=""> </span>247871<span style=""> </span>212909<span style=""> </span>22161<span style=""> </span>91%<span style=""> </span>/</p> <p class="MsoNormal">/dev/hda6<span style=""> </span>50717<span style=""> </span>15507<span style=""> </span>32591<span style=""> </span>32%<span style=""> </span>/var</p> <p class="MsoNormal">/dev/hda7<span style=""> </span><span style=""> </span>481998<span style=""> </span>15<span style=""> </span>457087<span style=""> </span>0%<span style=""> </span>/local</p> <p class="MsoNormal">server1:/var/spool/mail</p> <p class="MsoNormal"><span style=""> </span>489702<span style=""> </span>222422<span style=""> </span>218310<span style=""> </span>50%<span style=""> </span>/var/spool/mail</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The columns reported show: Filesystem Which file system is being shown. File systems mounted using NFS are shown as hostname:/dir/that/is/mounted </p> <p class="MsoNormal">1024-blocks The number of 1 KB blocks the file system consists of. (Its total size.) </p> <p class="MsoNormal">Used The number of blocks used. </p> <p class="MsoNormal">Available The number of blocks available for use. </p> <p class="MsoNormal">Capacity Percentage of partition currently used. </p> <p class="MsoNormal">Mounted on The location in the directory tree this partition has been mounted on. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Common parameters to this command are:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">directory Show information only for the partition on which the specified directory exists. </p> <p class="MsoNormal">-a Show all partitions including swap and /proc. </p> <p class="MsoNormal">-i Show inode usage instead of block usage. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The GNU df program, which is part of the fileutils distribution, has some additional print formatting features you may find useful. You can download the latest fileutils package at ftp://ftp.cdrom.com/pub/gnu.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">du The du command summarizes disk usage by directory. It recurses through all subdirectories and shows disk usage by each subdirectory with a final total at the end. Running it without any parameters shows the usage like so:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">409<span style=""> </span>./doc</p> <p class="MsoNormal">945<span style=""> </span>./lib</p> <p class="MsoNormal">68<span style=""> </span>./man</p> <p class="MsoNormal">60<span style=""> </span>./m4</p> <p class="MsoNormal">391<span style=""> </span>./src</p> <p class="MsoNormal">141<span style=""> </span>./intl</p> <p class="MsoNormal">873<span style=""> </span>./po</p> <p class="MsoNormal">3402<span style=""> </span>.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The first column shows the blocks of disk used by the subdirectory, and the second column shows the subdirectory being evaluated. To see how many kilobytes each subdirectory consumes, use the -k option. Some common parameters to this command are</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">directory Show usage for the specified directory. The default is the current directory. </p> <p class="MsoNormal">-a Show usage for all files, not just directories. </p> <p class="MsoNormal">-s Show only the total disk usage. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Like the df program, this program is available as part of the GNU fileutils distribution. The GNU version has expanded on many of the parameters which you may find useful. The fileutils package can be downloaded from ftp://ftp.cdrom.com/pub/gnu.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">ln The ln program is used to generate links between files. This is very useful for creating the illusion of a perfect file system in which everything is in the "right" place when, in reality, it isn't. This is done by making a link from the desired location to the actual location.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The usage of this program is</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">ln file_being_linked_to link_name</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where file_being_linked_to is the file that already exists, and you wish to have another file point to it called link_name. The command above generates a hard link, meaning that the file link_name will be indistinguishable from the original file. Both files must exist on the same file system.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">A popular parameter to ln is the -s option, which generates symbolic links instead of hard links. The format of the command remains the same:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">ln -s file_being_linked_to link_name</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">the difference being that the link_name file is marked as a symbolic link in the file system. Symbolic links may span file systems and are given a special tag in the directory entry. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">TIP: Unless there is an explicit reason not to, you should always use symbolic links by specifying the -s option to ln. This makes your links stand out and makes it easy to move them from one file system to another. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar The tar program is an immensely useful archiving utility. It can combine an entire directory tree into one large file suitable for transferring or compression.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The command line format of this program is:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar parameters filelist</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Common parameters are:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">c Create an archive </p> <p class="MsoNormal">x Extract the archive </p> <p class="MsoNormal">v Be verbose </p> <p class="MsoNormal">f Specify a tar file to work on </p> <p class="MsoNormal">p Retain file permissions and ownerships </p> <p class="MsoNormal">t View the contents of an archive. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Unlike most other UNIX commands, the parameters do not need to have a dash before them.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To create the tarfile myCode.tar, I could use tar in the following manners:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar cf myCode.tar myCode</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where myCode is a subdirectory relative to the current directory where the files I wish to archive are located.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar cvf myCode.tar myCode</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Same as the previous tar invocation, although this time it lists all the files added to the archive on the screen.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar cf myCode.tar myCode/*.c</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This archives all the files in the myCode directory that are suffixed by .c</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar cf myCode.tar myCode/*.c myCode/*.h</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This archives all the files in the myCode directory that are suffixed by .c or .h</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To view the contents of the myCode.tar file, use:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar tf myCode.tar</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To extract the files in the myCode.tar file, use:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar xf myCode.tar</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If the myCode directory doesn't exist, tar creates it. If the myCode directory does exist, any files in that directory are overwritten by the ones being untarred.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar xvf myCode.tar</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Same as the previous invocation of tar, but this lists the files as they are being extracted.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">tar xpf myCode.tar</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Same as the previous invocation of tar, but this attempts to set the permissions of the unarchived files to the values they had before archiving (very useful if you're untarring files as root). </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">TIP: The greatest use of tar for Systems Administrators is to move directory trees around. This can be done using the following set of commands: </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">(cd /src;tar cf - *) | (cd /dest;tar xpf -) </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where /src is the source directory and /dest is the destination directory.</p> <p class="MsoNormal">This is better than using a recursive copy because symbolic links and file permissions are kept. Use this and amaze your friends. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">While the stock tar that comes with your system works fine for most uses, you may find that the GNU version of tar has some nicer features. You can find the latest version of GNU tar at ftp://ftp.cdrom.com/pub/gnu.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">find Of the commands that I've mentioned so far, you're likely to use find the most. Its purpose is to find files or patterns of files. The parameters for this tool are</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">find dir parameters</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where dir is the directory where the search begins, and parameters define what is being searched for. The most common parameters you will use are:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">-name Specify the filename or wildcards to look for. If you use any wildcards, be sure to place them inside of quotes so that the shell doesn't parse them before find does. </p> <p class="MsoNormal">-print Typically turned on by default, it tells find to display the resulting file list. </p> <p class="MsoNormal">-exec Executes the specified command on files found matching the -name criteria. </p> <p class="MsoNormal">-atime n File was last accessed n days ago. </p> <p class="MsoNormal">-mtime n File's data was last modified n days ago. </p> <p class="MsoNormal">-size n[bckw] File uses n units of space where the units are specified by either b,c,k, or w. b is for 512 byte blocks, c is bytes, k is kilobytes, and w is two-byte words. </p> <p class="MsoNormal">-xdev Do not traverse down nonlocal file systems. </p> <p class="MsoNormal">-o Logical or the options. </p> <p class="MsoNormal">-a Logical and the options. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Some examples of the find command are</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">find / -name core -mtime +7 -print -exec /bin/rm {} \;</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This starts its search from the root directory and finds all files named core that have not been modified in seven days.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">find / -xdev -atime +60 -a -mtime +60 -print</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This searches all files, from the root directory down, on the local file system, which have not been accessed for at least 60 days and have not been modified for at least 60 days, and prints the list. This is useful for finding those files that people claim they need but, in reality, never use.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">find /home -size +500k -print</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This searches all files from /home down and lists them if they are greater than 500 KB in size. A handy way of finding large files in the system.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The GNU version of find, which comes with the findutils package, offers many additional features you will find useful. You can download the latest version from ftp://ftp.cdrom.com/pub/gnu. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Repairing File Systems with fsck</p> <p class="MsoNormal">Sooner or later, it happens: Someone turns off the power switch. The power outage lasts longer than your UPS's batteries and you didn't shut down the system. Someone presses the reset button. Someone overwrites part of your disk. A critical sector on the disk develops a flaw. If you run UNIX long enough, eventually a halt occurs where the system did not write the remaining cached information (sync'ed) to the disks.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">When this happens, you need to verify the integrity of each of the file systems. This is necessary because if the structure is not correct, using the file systems could quickly damage them beyond repair. Over the years, UNIX has developed a very sophisticated file system integrity check that can usually recover the problem. It's called fsck. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The fsck Utility</p> <p class="MsoNormal">The fsck utility takes its understanding of the internals of the various UNIX file systems and attempts to verify that all the links and blocks are correctly tied together. It runs in five passes, each of which checks a different part of the linkage and each of which builds on the verifications and corrections of the prior passes.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">fsck walks the file system, starting with the superblock. It then deals with the allocated disk blocks, pathnames, directory connectivity, link reference counts, and the free list of blocks and inodes. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">NOTE: The xfs filesystem now shipped with all IRIX based machines no longer need the fsck command. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The Superblock Every change to the file system affects the superblock, which is why it is cached in RAM. Periodically, at the sync interval, it is written to disk. If it is corrupted, fsck checks and corrects it. If it is so badly corrupted that fsck cannot do its work, find the paper you saved when you built the file system and use the -b option with fsck to give it an alternate superblock to use. The superblock is the head of each of the lists that make up the file system, and it maintains counts of free blocks and inodes.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Inodes fsck validates each of the inodes. It makes sure that each block in the block allocation list is not on the block allocation list in any other inode, that the size is correct, and that the link count is correct. If the inodes are correct, then the data is accessible. All that's left is to verify the pathnames. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">What Is a Clean (Stable) File System?</p> <p class="MsoNormal">Sometimes fsck responds</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>/opt: stable<span style=""> </span>(ufs file systems)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This means that the superblock is marked clean and that no changes have been made to the file system since it was marked clean. First, the system marks the superblock as dirty; then it starts modifying the rest of the file system. When the buffer cache is empty and all pending writes are complete, it goes back and marks the superblock as clean. If the superblock is marked clean, there is normally no reason to run fsck, so unless fsck is told to ignore the clean flag, it just prints this notice and skips over this file system. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Where Is fsck?</p> <p class="MsoNormal">When you run fsck, you are running an executable in either the /usr/sbin or /bin directory called fsck, but this is not the real fsck. It is just a dispatcher that invokes a file system type-specific fsck utility. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">When Should I Run fsck?</p> <p class="MsoNormal">Normally, you do not have to run fsck. The system runs it automatically when you try to mount a file system at boot time that is dirty. However, problems can creep up on you. Software and hardware glitches do occur from time to time. It wouldn't hurt to run fsck just after performing the monthly backups. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">CAUTION: It is better to run fsck after the backups rather than before. If fsck finds major problems, it could leave the file system in worse shape than it was prior to running. Then you can just build an empty file system and reread your backup, which also cleans up the file system. If you did it in the other order, you would be left with no backup and no file system. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">How Do I Run fsck?</p> <p class="MsoNormal">Because the system normally runs it for you, running fsck is not an everyday occurrence for you to remember. However, it is quite simple and mostly automatic.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">First, to run fsck, the file system you intend to check must not be mounted. This is a bit hard to do if you are in multiuser mode most of the time, so to run a full system fsck you should bring the system down to single user mode.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">In single user mode you need to invoke fsck, giving it the options to force a check of all file systems, even if they are already stable.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>fsck -f<span style=""> </span>(SunOS)</p> <p class="MsoNormal"><span style=""> </span>fsck -o f<span style=""> </span>(Solaris)</p> <p class="MsoNormal"><span style=""> </span>fsck<span style=""> </span>(Linux and IRIX)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If you wish to check a single specific file system, type its character device name. (If you aren't sure what the device name is, see the section on adding a disk to the system for details on how to determine this information.) For example:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">fsck /dev/hda1</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Stepping Through an Actual fsck fsck occurs in five to seven steps, depending on your operating system and what errors are found, if any. fsck can automatically correct most of these errors and does so if invoked at boot time to automatically check a dirty file system.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The fsck we are about to step through was done on a ufs file system. While there are some differences between the numbering of the phases for different file systems, the errors are mostly the same, requiring the same solutions. Apply common sense liberally to any invocation of fsck and you should be okay.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Checking ufs File Systems For ufs file systems, fsck is a five-phase process. fsck can automatically correct most of these errors and does so if invoked at boot time to automatically check a dirty file system. However, when you run fsck manually, you are asked to answer the questions that the system would automatically answer. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">CAUTION: Serious errors reported by the ufs fsck at the very beginning, especially before reporting the sta8rt of phase 1, indicate an invalid superblock. fsck should be terminated and restarted with the -b option specifying one of the alternate superblocks. Block 32 is always an alternate and can be tried first, but if the front of the file system was overwritten, it too may be damaged. Use the hard copy you saved from the mkfs to find an alternate later in the file system. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Phase 1: Check Blocks and Sizes This phase checks the inode list, looking for invalid inode entries. Errors requiring answers include</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">UNKNOWN FILE TYPE I=inode number (CLEAR)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The file type bits are invalid in the inode. Options are to leave the problem and attempt to recover the data by hand later or to erase the entry and its data by clearing the inode.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">PARTIALLY TRUNCATED INODE I=inode number (SALVAGE)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The inode appears to point to less data than the file does. This is safely salvaged, because it indicates a crash while truncating the file to shorten it.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>block BAD I=inode number</p> <p class="MsoNormal"><span style=""> </span>block DUP I=inode number</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The disk block pointed to by the inode is either out of range for this inode or already in use by another file. This is an informational message. If a duplicate block is found, phase 1b is run to report the inode number of the file that originally used this block.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Phase 2: Check Pathnames This phase removes directory entries from bad inodes found in phase 1 and 1b and checks for directories with inode pointers that are out of range or pointing to bad inodes. You may have to handle</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">ROOT INODE NOT DIRECTORY (FIX?)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">You can convert inode 2, the root directory, back into a directory, but this usually means there is major damage to the inode table.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>I=OUT OF RANGE I=inode number NAME=file name (REMOVE?)</p> <p class="MsoNormal"><span style=""> </span>UNALLOCATED I=inode number OWNER=O MODE=M SIZE=S MTIME=T TYPE=F</p> <p class="MsoNormal"><span style=""> </span>(REMOVE?)</p> <p class="MsoNormal"><span style=""> </span>BAD/DUP I=inode number OWNER=O MODE=M SIZE=S MTIME=T TYPE=F (REMOVE?)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">A bad inode number was found, an unallocated inode was used in a directory, or an inode that had a bad or duplicate block number in it is referenced. You are given the choice to remove the file, losing the data, or to leave the error. If you leave the error, the file system is still damaged, but you have the chance to try to dump the file first and salvage part of the data before rerunning fsck to remove the entry.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">fsck may return one of a variety of errors indicating an invalid directory length. You will be given the chance to have fsck fix or remove the directory as appropriate. These errors are all correctable with little chance of subsequent damage.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Phase 3: Check Connectivity This phase detects errors in unreferenced directories. It creates or expands the lost+found directory if needed and connects the misplaced directory entries into the lost+found directory. fsck prints status messages for all directories placed in lost+found.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Phase 4: Check Reference Counts This phase uses the information from phases 2 and 3 to check for unreferenced files and incorrect link counts on files, directories, or special files.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">UNREF FILE I=inode number OWNER=O MODE=M SIZE=S MTIME=T (RECONNECT?)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The filename is not known (it is an unreferenced file), so it is reconnected into the lost+found directory with the inode number as its name. If you clear the file, its contents are lost. Unreferenced files that are empty are cleared automatically.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>LINK COUNT FILE I=inode number OWNER=O MODE=M SIZE=S MTIME=T COUNT=X</p> <p class="MsoNormal"><span style=""> </span>(ADJUST?)</p> <p class="MsoNormal"><span style=""> </span>LINK COUNT DIR I=inode number OWNER=O MODE=M SIZE=S MTIME=T COUNT=X</p> <p class="MsoNormal"><span style=""> </span>(ADJUST?)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">In both cases, an entry was found with a different number of references than what was listed in the inode. You should let fsck adjust the count.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">BAD/DUP FILE I=inode number OWNER=O MODE=M SIZE=S MTIME=T (CLEAR)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">A file or directory has a bad or duplicate block in it. If you clear it now, the data is lost. You can leave the error and attempt to recover the data, and rerun fsck later to clear the file.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Phase 5: Check Cylinder Groups This phase checks the free block and unused inode maps. It automatically corrects the free lists if necessary, although in manual mode it asks permission first. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">What Do I Do After fsck Finishes?</p> <p class="MsoNormal">First, relax, because fsck rarely finds anything seriously wrong, except in cases of hardware failure where the disk drive is failing or where you copied something on top of the file system. UNIX file systems are very robust.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">However, if fsck finds major problems or makes a large number of corrections, rerun it to be sure the disk isn't undergoing hardware failure. It shouldn't find more errors in a second run. Then, recover any files that it may have deleted. If you keep a log of the inodes it clears, you can go to a backup tape and dump the list of inodes on the tape. Recover just those inodes to restore the files.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Back up the system again, because there is no reason to have to do this all over again. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Dealing with What Is in lost+found</p> <p class="MsoNormal">If fsck reconnects unreferenced entries, it places them in the lost+found directory. They are safe there, and the system should be backed up in case you lose them while trying to move them back to where they belong. Items in lost+found can be of any type: files, directories, special files (devices), and so on. If it is a named pipe or socket, you may as well delete it. The process which opened it is long since gone and will open a new one when it is run again.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">For files, use the owner name to contact the user and have him look at the contents and see if the file is worth keeping. Often, it is a file that was deleted and is no longer needed, but the system crashed before it could be fully removed.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">For directories, the files in the directory should help you and the owner determine where they belong. You can look on the backup tape lists for a directory with those contents if necessary. Then just remake the directory and move the files back. Then remove the directory entry in lost+found. This re-creation and move has the added benefit of cleaning up the directory. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Creating File Systems</p> <p class="MsoNormal">Now that you understand the nuances of maintaining a file system, it's time to understand how they are created. This section walks you through the three steps of: </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Picking the right kind of disk for your system </p> <p class="MsoNormal">Creating partitions </p> <p class="MsoNormal">Creating the file system </p> <p class="MsoNormal">Disk Types</p> <p class="MsoNormal">Although there are many different kinds of disks, UNIX systems have come to standardize on SCSI for workstations. Many PCs also sport SCSI interfaces, but because of the lower cost and abundance, you'll find a lot of IDE drives on UNIX PC's as well.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">SCSI itself comes in a few different flavors now. There is regular SCSI, SCSI-2, SCSI-Wide, SCSI-Fast and Wide, and now SCSI-3. Although it is possible to mix and match these devices with converter cables, you may find it both easier on your sanity and your performance if you stick to one format. As of this writing, SCSI-2 is the most common interface.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">When attaching your SCSI drive, there are many important points to remember. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Terminate your SCSI chain. Forgetting to do this causes all sorts of non-deterministic behavior (a pain to track down). SCSI-2 requires active termination, which is usually indicated by terminators with LEDs on them. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If a device claims to be self-terminating, you can take your chances, but you'll be less likely to encounter an error if you put a terminator on anyway. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">There is a limit of eight devices on a SCSI chain with the SCSI card counting as a device. Some systems may have internal SCSI devices, so be sure to check for those. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Be sure all your devices have unique SCSI IDs. A common symptom of having two devices with the same ID is their tendency to frequently reset the SCSI chain. Of course, many devices simply won't work under those conditions. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">When adding or removing a SCSI disk, be sure to power the system down first. There is power running through the SCSI cables, and failing to shut them down first may lead to problems in the future. </p> <p class="MsoNormal">Although SCSI is king of the workstation, PCs have another choice: IDE. IDE tends to be cheaper and more available than SCSI devices with many motherboards offering direct IDE support. The advantage of using this kind of interface is its availability as well as lower cost. They are also simpler and require less configuration on your part.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The down side to IDEs is that their simplicity comes at the cost of configurability and expandability. The IDE chain can only hold two devices, and not all motherboards come with more than one IDE chain. If your CD-ROM is IDE, you only have space for one disk. This is probably okay with a single person workstation, but as you can imagine, it's not going to fly well in a server environment. Another consideration is speed. SCSI was designed with the ability to perform I/O without the aid of the main CPU, which is one of the reasons it costs more. IDE, on the other hand, was designed with cost in mind. This resulted in a simplified controller; hence, the CPU takes the burden for working the drive.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">While IDE did manage to simplify the PC arena, it did come with the limitation of being unable to handle disks greater than 540M. Various tricks were devised to circumvent this, however, the clean solution is now predominantly available. Known as EIDE (Enhanced IDE), it is capable of supporting disks up to 8G and can support up to 4 devices on one chain.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">In weighing the pros and cons of EIDE versus SCSI in the PC environment, don't forget to think about the cost-to-benefit ratio. Having a high speed SCSI controller in a single person's workstation may not be as necessary as the user is convinced it is. Plus, with disks being released in 2+ gigabyte configurations, there is ample room on the typical IDE disk.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Once you have decided on the disk subsystem to install, read the documentation that came with the machine for instructions on physically attaching the disk to the system. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">What Are Partitions and Why Do I Need Them?</p> <p class="MsoNormal">Partitions are UNIX's way of dividing the disk into usable pieces. UNIX requires that there be at least one partition; however, you'll find that creating multiple partitions, each with a specific function, is often necessary.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The most visible reason for creating separate partitions is to protect the system from the users. The one required partition mentioned earlier is called the root partition. It is here that critical system software and configuration files (the kernel and mount tables) must reside. This partition must be carefully watched so that it never fills up. If it fills up, your system may not be able to come back up in the event of a system crash. Because the root partition is not meant to hold the users' data, you must create separate partitions for the users' home directories, temporarily files, and so forth. This enables their files to grow without the worry of crowding out the key system files.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Dual boot configurations are becoming another common reason to partition, especially with the ever-growing popularity of Linux. You may find your users wanting to be able to boot to either Windows or Linux; therefore, you need to keep at least two partitions to enable them to do this.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The last, but certainly not least, reason to partition your disks is the issue of backups. Backup software often works by dumping entire partitions onto tape. By keeping the different types of data on separate partitions, you can be explicit about what gets backed up and what doesn't. For example, daily backup of the system software isn't necessary, but backups of home directories are. By keeping the two on separate partitions, you can be more concise in your selection of what gets backed up and what doesn't.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Another example relates more to company politics. It may be possible that one group does not want their data to be backed up to the same tape as another group's. (Note: common sense doesn't always apply to inter-group politicsÉ) By keeping the two groups on separate partitions, you can exclude one from your normal backups and exclude the others during your special backups.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Which Partitions To Create As I mentioned earlier, the purpose of creating partitions is to separate the users from the system areas. So how many different partitions need to be created? While there is no right answer for every installation, here are some guidelines to take into account.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">You always need a root partition. In this partition, you'll have your /bin, /etc, and /sbin directories at the very least. Depending on your version of UNIX, this could require anywhere from 30 to 100 megabytes. /tmp The /tmp directory is where your users, as well as programs, store temporarily files. The usage of this directory can quickly get out of hand, especially if you run a quota-based site. By keeping it a separate partition, you do not need to worry about its abuse interfering with the rest of the system. Many operating systems automatically clear the contents of /tmp on boot. Size /tmp to fit your site's needs. If you use quotas, you will want to make it a little larger, whereas sites without quotas may not need as much space. </p> <p class="MsoNormal"><span style=""> </span>Under Solaris, you have another option when setting up /tmp. Using the tmpfs filesystem, you can have your swap space and /tmp partition share the same physical location on disk. While it appears to be an interesting idea, you'll quickly find that it isn't a very good solution, especially on a busy system. This is because as more users do their work, more of /tmp will be used. Of course, if there are more users, there is a greater memory requirement to hold them all. The competition for free space can become very problematic. </p> <p class="MsoNormal">/var The /var directory is where the system places its spool files (print spool, incoming/outgoing mail queue, and so on) as well as system log files. Because of this, these files constantly grow and shrink with no warning. Especially the mail spool. Another possibility to keep in mind is the creation of a separate partition just for mail. This enables you to export the mail spool to all of your machines without having to worry about your print spools being exported as well. If you use a backup package that requires its own spool space, you may wish to keep this a separate partition as well. </p> <p class="MsoNormal">/home The /home directory is where you place your users' account directories. You may need to use multiple partitions to keep your home directories (possibly broken up by department) and have each partition mount to /home/dept where dept is the name of the respective department. </p> <p class="MsoNormal">/usr The /usr directory holds noncritical system software, such as editors and lesser used utilities. Many sites hold locally compiled software in the /usr/local directory where they either export it to other machines, or mount other machines' /usr/local to their own. This makes it easy for a site to maintain one /usr/local directory and share it amongst all of its machines. Keeping this a separate partition is a good idea since local software inevitably grows. </p> <p class="MsoNormal">swap This isn't a partition you actually keep files on, but it is key to your system's performance. The swap partition should be allocated and swapped to instead of using swap files on your normal file system. This enables you to contain all of your swap space in one area that is out of your way. A good guideline for determining how much swap space to use is to double the amount of RAM installed on your system. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">TIP: Several new versions of UNIX are now placing locally compiled software in the /opt directory. Like /usr/local, this should be made a separate partition as well. If your system does not use /opt by default, you should make a symbolic link from there to /usr/local. The vice versa is true as well, if your system uses /opt, you should create a symbolic link from /usr/local to /opt.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To add to the confusion, the Redhat Distribution of Linux has brought the practice of installing precompiled software (RPMs) in the /usr/bin directory. If you are using Redhat, you may want to make your /usr directory larger since locally installed packages will consume that partition. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The Device Entry</p> <p class="MsoNormal">Most implementations of UNIX automatically create the correct device entry when you boot it with the new drive attached. Once this entry has been created, you should check it for permissions. Only root should be given read/write access to it. If your backups run as a nonroot user, you may need to give group read access to the backup group. Be sure that no one else is in the backup group. Allowing world read/write access to the disk is the easiest way to have your system hacked, destroyed, or both.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Device entries under Linux IDE disks under Linux use the following scheme to name the hard disks:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">/dev/hd[drive][partition]</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Each IDE drive is lettered starting from a. So the primary disk on the first chain is a; the slave on the first chain is b; the primary on the secondary chain is c; and so on. Each disk's partition is referenced by number. For example, the third partition of the slave drive on the first chain is /dev/hdb3.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">SCSI disks use the same scheme except instead of using /dev/hd as the prefix, /dev/sd is used. So to refer to the second partition of the first disk on the SCSI chain, you would use /dev/sda2.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To refer to the entire disk, specify all the information except the partition. For example, to refer to the entire primary disk on the first IDE chain, you would use /dev/hda.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Device entries under IRIX SCSI disks under IRIX are referenced in either the /dev/dsk or /dev/rdsk directories. The following is the format:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">/dev/[r]dsk/dksCdSP</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where C is the controller number, S is the SCSI address, and P is the partition, s0,s1,s2, and so on. The partition name can also be vh for the volume header or vol to refer to the entire disk.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Device entries under Solaris The SCSI disks under Solaris are referenced in either the /dev/dsk or /dev/rdsk directories. The following is the format:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">/dev/[r]dsk/cCtSd0sP</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where C is the controller number, S is the SCSI address, and P is the partition number. Partition 2 always refers to the entire disk and label information. Partition 1 is typically used for swap.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Device entries under SunOS Disks under SunOS are referenced in the /dev directory. The following is the format:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">/dev/sdTP</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where T is the target number and P is the partition. Typically, the root partition is a, the swap partition is b, and the entire disk is referred to as partition c. You can have partitions from a through f.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">An important aspect to note is an oddity with the SCSI target and unit numbering: Devices that are target three need to be called target zero, and devices that are target zero need to be called target three. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">A Note About Formatting Disks</p> <p class="MsoNormal">"Back in the old days," disks needed to be formatted and checked for bad blocks. The procedure of formatting entailed writing the head, track, and sector numbers in a sector preamble and a checksum in the postamble to every sector on the disk. At the same time, any sectors that were unusable due to flaws in the disk surface were marked and, depending on the type of disk, an alternate sector mapped into its place.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Thankfully, we have moved on.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Both SCSI and IDE disks now come pre-formatted from the factory. Even better, they transparently handle bad blocks on the disk and remap them without any assistance from the operating system. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">CAUTION: You should NEVER attempt to low level format an IDE disk.</p> <p class="MsoNormal">Doing so will make your day very bad as you watch the drive quietly kill itself. Be prepared to throw the disk away should you feel the need to low level format it. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Partitioning Disks and Creating File Systems</p> <p class="MsoNormal">In this section, we will cover the step by step procedure for partitioning disks under Linux, IRIX, SunOS, and Solaris. Since the principles are similar across all platforms, each platform will also cover another method of determining how a disk should be partitioned up depending on its intended usage.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Linux To demonstrate how partitions are created under Linux, we will setup a disk with a single user workstation in mind. It will need not only space for system software, but for application software and the user's home directories.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Creating Partitions For this example, we'll create the partitions on a 1.6 GB IDE disk located on /dev/hda. This disk will become the boot device for a single user workstation. We will create the boot /usr, /var, /tmp, /home, and swap partitions.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">During the actual partitioning, we don't name the partitions. Where the partitions are mounted is specified with the /etc/fstab file. Should we choose to mount them in different locations later on, we could very well do that. However, by keeping the function of each partition in mind, we have a better idea of how to size them.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">A key thing to remember with the Linux fdisk command is that it does not commit any changes made to the partition table to disk until you explicitly do so with the w command.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">With the drive installed, we begin by running the fdisk command:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># fdisk /dev/hda</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This brings us to the fdisk command prompt. We start by using the p command to print what partitions are currently on the disk.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): p</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Disk /dev/hda: 64 heads, 63 sectors, 786 cylinders</p> <p class="MsoNormal"><span style=""> </span>Units = cylinders of 4032 * 512 bytes</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Device Boot<span style=""> </span>Begin<span style=""> </span>Start<span style=""> </span>End<span style=""> </span>Blocks<span style=""> </span>Id<span style=""> </span>System</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">We see that there are no partitions on the disk. With 1.6 GB of space, we can be very liberal with allocating space to each partition. Keeping this policy in mind, we begin creating our partitions with the n command:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): n</p> <p class="MsoNormal"><span style=""> </span>e<span style=""> </span>extended</p> <p class="MsoNormal"><span style=""> </span>p<span style=""> </span>primary partition (1-4)</p> <p class="MsoNormal"><span style=""> </span>p</p> <p class="MsoNormal"><span style=""> </span>Partition number (1-4): 1</p> <p class="MsoNormal"><span style=""> </span>First cylinder (1-786): 1</p> <p class="MsoNormal"><span style=""> </span>Last cylinder or +size or +sizeM or +sizeK ([1]-786): +50M</p> <p class="MsoNormal"><span style=""> </span>Command (m for help):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The 50 MB partition we just created becomes our root partition. Because it is the first partition, it is referred to as /dev/hda1. Using the p command, we see our new partition:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): p</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Disk /dev/hda: 64 heads, 63 sectors, 786 cylinders</p> <p class="MsoNormal"><span style=""> </span>Units = cylinders of 4032 * 512 bytes</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Device Boot<span style=""> </span>Begin<span style=""> </span>Start<span style=""> </span>End<span style=""> </span>Blocks<span style=""> </span>Id<span style=""> </span>System</p> <p class="MsoNormal"><span style=""> </span>/dev/hda1<span style=""> </span>1<span style=""> </span>1<span style=""> </span>26<span style=""> </span>52384+<span style=""> </span>83<span style=""> </span>Linux native</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">With the root partition out of the way, we will create the swap partition. Our sample machine has 32 MB of RAM and will be running X-Windows along with a host of development tools. It is unlikely that the machine will get a memory upgrade for a while, so we'll allocate 64 MB to swap.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>Command (m for help): n</p> <p class="MsoNormal"><span style=""> </span>Command action</p> <p class="MsoNormal"><span style=""> </span>e<span style=""> </span>extended</p> <p class="MsoNormal"><span style=""> </span>p<span style=""> </span>primary partition (1-4)</p> <p class="MsoNormal"><span style=""> </span>p</p> <p class="MsoNormal"><span style=""> </span>Partition number (1-4): 2</p> <p class="MsoNormal"><span style=""> </span>First cylinder (27-786): 27</p> <p class="MsoNormal"><span style=""> </span>Last cylinder or +size or +sizeM or +sizeK ([27]-786): +64M</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Because this partition is going to be tagged as swap, we need to change its file system type to swap using the t command.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): t</p> <p class="MsoNormal"><span style=""> </span>Partition number (1-4): 2</p> <p class="MsoNormal"><span style=""> </span>Hex code (type L to list codes): 82</p> <p class="MsoNormal"><span style=""> </span>Changed system type of partition 2 to 82 (Linux swap)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Because of the nature of the user, we know that there will be a lot of local software installed on this machine. With that in mind, we'll create /usr with 500 MB of space.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): n</p> <p class="MsoNormal"><span style=""> </span>Command action</p> <p class="MsoNormal"><span style=""> </span>e<span style=""> </span>extended</p> <p class="MsoNormal"><span style=""> </span>p<span style=""> </span>primary partition (1-4)</p> <p class="MsoNormal"><span style=""> </span>p</p> <p class="MsoNormal"><span style=""> </span>Partition number (1-4): 3</p> <p class="MsoNormal"><span style=""> </span>First cylinder (60-786): 60</p> <p class="MsoNormal"><span style=""> </span>Last cylinder or +size or +sizeM or +sizeK ([60]-786): +500M</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If you've been keeping your eyes open, you've noticed that we can only have one more primary partition to use, but we want to have /home, /var, and /tmp to be in separate partitions. How do we do this?</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Extended partitions.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The remainder of the disk is created as an extended partition. Within this partition, we can create more partitions for use. Let's create this extended partition:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): n</p> <p class="MsoNormal"><span style=""> </span>Command action</p> <p class="MsoNormal"><span style=""> </span>e<span style=""> </span>extended</p> <p class="MsoNormal"><span style=""> </span>p<span style=""> </span>primary partition (1-4)</p> <p class="MsoNormal"><span style=""> </span>e</p> <p class="MsoNormal"><span style=""> </span>Partition number (1-4): 4</p> <p class="MsoNormal"><span style=""> </span>First cylinder (314-786): 314</p> <p class="MsoNormal"><span style=""> </span>Last cylinder or +size or +sizeM or +sizeK ([314]-786): 786</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">We can now create /home inside the extended partition. Our user is going to need a lot of space, so we'll create a 500 MB partition. Notice that we are no longer asked whether we want a primary or extended partition.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): n</p> <p class="MsoNormal"><span style=""> </span>First cylinder (314-786): 314</p> <p class="MsoNormal"><span style=""> </span>Last cylinder or +size or +sizeM or +sizeK ([314]-786): +500M</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Using the same pattern, we create a 250 MB /tmp and a 180 MB /var partition.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): n</p> <p class="MsoNormal"><span style=""> </span>First cylinder (568-786): 568</p> <p class="MsoNormal"><span style=""> </span>Last cylinder or +size or +sizeM or +sizeK ([568]-786): +250M</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): n</p> <p class="MsoNormal"><span style=""> </span>First cylinder (695-786): 695</p> <p class="MsoNormal"><span style=""> </span>Last cylinder or +size or +sizeM or +sizeK ([695]-786): 786</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Notice on the last partition we created that I did not specify a size, but instead specified the last track. This is to ensure that all of the disk is used.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Using the p command, we look at our final work:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): p</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Disk /dev/hda: 64 heads, 63 sectors, 786 cylinders</p> <p class="MsoNormal"><span style=""> </span>Units = cylinders of 4032 * 512 bytes</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Device Boot<span style=""> </span>Begin<span style=""> </span>Start<span style=""> </span>End<span style=""> </span>Blocks<span style=""> </span>Id<span style=""> </span>System</p> <p class="MsoNormal"><span style=""> </span>/dev/hda1<span style=""> </span>1<span style=""> </span>1<span style=""> </span>26<span style=""> </span>52384+<span style=""> </span>83 <span style=""> </span>Linux native</p> <p class="MsoNormal"><span style=""> </span>/dev/hda2<span style=""> </span>27<span style=""> </span>27<span style=""> </span>59<span style=""> </span>66528<span style=""> </span>82<span style=""> </span>Linux swap</p> <p class="MsoNormal"><span style=""> </span>/dev/hda3<span style=""> </span>60<span style=""> </span>60<span style=""> </span>313<span style=""> </span>512064<span style=""> </span>83<span style=""> </span>Linux native</p> <p class="MsoNormal"><span style=""> </span>/dev/hda4<span style=""> </span>314<span style=""> </span>314<span style=""> </span>786<span style=""> </span>953568<span style=""> </span>5<span style=""> </span>Extended</p> <p class="MsoNormal"><span style=""> </span>/dev/hda5<span style=""> </span>314<span style=""> </span>314<span style=""> </span>567<span style=""> </span>512032+<span style=""> </span>83<span style=""> </span>Linux native</p> <p class="MsoNormal"><span style=""> </span>/dev/hda6<span style=""> </span>568<span style=""> </span>568<span style=""> </span>694<span style=""> </span>256000+<span style=""> </span>83<span style=""> </span>Linux native</p> <p class="MsoNormal"><span style=""> </span>/dev/hda7<span style=""> </span>695<span style=""> </span>695<span style=""> </span>786<span style=""> </span>185440+<span style=""> </span>83<span style=""> </span>Linux native</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Everything looks good. To commit this configuration to disk, we use the w command:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Command (m for help): w</p> <p class="MsoNormal"><span style=""> </span>The partition table has been altered!</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Calling ioctl() to re-read partition table.</p> <p class="MsoNormal"><span style=""> </span>(Reboot to ensure the partition table has been updated.)</p> <p class="MsoNormal"><span style=""> </span>Syncing disks.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Reboot the machine to ensure that the partition has been updated and you're done creating the partitions.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Creating File Systems in Linux Creating a partition alone isn't very useful. In order to make it useful, we need to make a file system on top of it. Under Linux, this is done using the mke2fs command and the mkswap command.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To create the file system on the root partition, we use the following commands:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">mke2fs /dev/hda1</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The program only takes a few seconds to run and generates output similar to this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>mke2fs 0.5b, 14-Feb-95 for EXT2 FS 0.5a, 95/03/19</p> <p class="MsoNormal"><span style=""> </span>128016 inodes, 512032 blocks</p> <p class="MsoNormal"><span style=""> </span>25601 blocks (5.00%) reserved for the super user</p> <p class="MsoNormal"><span style=""> </span>First data block=1</p> <p class="MsoNormal"><span style=""> </span>Block size=1024 (log=0)</p> <p class="MsoNormal"><span style=""> </span>Fragment size=1024 (log=0)</p> <p class="MsoNormal"><span style=""> </span>63 block groups</p> <p class="MsoNormal"><span style=""> </span>8192 blocks per group, 8192 fragments per group</p> <p class="MsoNormal"><span style=""> </span>2032 inodes per group</p> <p class="MsoNormal"><span style=""> </span>Superblock backups stored on blocks:</p> <p class="MsoNormal"><span style=""> </span>8193,16385,24577,32769,40961,49153,57345,65537,73729,</p> <p class="MsoNormal"><span style=""> </span>81921,90113,98305,106497,114689,122881,131073,139265,147457,</p> <p class="MsoNormal"><span style=""> </span>155649,163841,172033,180225,188417,196609,204801,212993,221185,</p> <p class="MsoNormal"><span style=""> </span>229377,237569,245761,253953,262145,270337,278529,286721,294913,</p> <p class="MsoNormal"><span style=""> </span>303105,311297,319489,327681,335873,344065,352257,360449,368641,</p> <p class="MsoNormal"><span style=""> </span>376833,385025,393217,401409,409601,417793,425985,434177,442369,</p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>450561,458753,466945,475137,483329,491521,499713,507905</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>Writing inode tables: done</p> <p class="MsoNormal">Writing superblocks and file system accounting information: done </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">You should make a note of these superblock backups and keep them in a safe place. Should the day arise that you need to use fsck to fix a superblock gone bad, you will want to know where the backups are.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Simply do this for all of the partitions, except for the swap partition.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To create the swap file system, you need to use the mkswap command like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">mkswap /dev/hda2</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Replace /dev/hda2 with the partition you chose to make your swap space.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The result of the command will be similar to:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Setting up swapspace, size = 35090432 bytes</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">And the swap space is ready.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To make the root file system bootable, you need to install the lilo boot manager. This is part of all the standard Linux distributions, so you shouldn't need to hunt for it on the Internet.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Simply modify the /etc/lilo.conf file so that /dev/hda1 is set to be the boot disk and run:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">lilo</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The resulting output should look something like:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Added linux *</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where linux is the name of the kernel to boot, as specified by the name= field in /etc/lilo.conf.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">SunOS In this example, we will be preparting a Seagate ST32550N as an auxiliary disk to an existing system. The disk will be divided into three partitions: one for use as a mail spool, one for use as a /usr/local, and the third as an additional swap partition.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Creating the partitions </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">CAUTION: The procedure for formatting disks is not the same for SunOS and Solaris. Read each section to note the differences. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Once a disk has been attached to the machine, you should verify its connection and SCSI address by running the probe-scsi command from the PROM monitor if the disk is attached to the internal chain, or the probe-scsi-all command to see all the SCSI devices on the system. When you are sure the drive is properly attached and verified to be functioning, you're ready to start accessing the drive from the OS.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">After the machine has booted, run the dmesg command to collect the system diagnostic messages. You may want to pipe the output to grep so that you can easily find the information on disks. For example:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">dmesg | grep sd</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">On our system this generated the following output:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>sd0: <sun0207></p> <p class="MsoNormal"><span style=""> </span>sd1 at esp0 target 1 lun 0</p> <p class="MsoNormal"><span style=""> </span>sd1:<span style=""> </span>corrupt label - wrong magic number</p> <p class="MsoNormal"><span style=""> </span>sd1: Vendor 'SEAGATE', product 'ST32550N', 4194058 512 byte blocks</p> <p class="MsoNormal"><span style=""> </span>root on sd0a fstype 4.2</p> <p class="MsoNormal"><span style=""> </span>swap on sd0b fstype spec size 32724K</p> <p class="MsoNormal"><span style=""> </span>dump on sd0b fstype spec size 32712K</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This result tells us that we have an installed disk on sd0 that the system is aware of and using. The information from the sd1 device is telling us that it found a disk, but it isn't usable because of a corrupt label. Don't worry about the error. Until we partition the disk and create file systems on it, the system doesn't know what to do with it, hence the error.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If you are using SCSI address 0 or 3, remember the oddity we mentioned earlier where device 0 needs to be referenced as 3 and device 3 needs to be referenced as 0.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Even though we do not have to actually format the disk, we do need to use the format program that come with SunOS because it also creates the partitions and writes the label to the disk.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To invoke the format program, simply run:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">format sd1</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where sd1 is the name of the disk we are going to partition.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The format program displays the following menu:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>FORMAT MENU:</p> <p class="MsoNormal"><span style=""> </span>disk<span style=""> </span>- select a disk</p> <p class="MsoNormal"><span style=""> </span>type<span style=""> </span>- select (define) a disk type</p> <p class="MsoNormal"><span style=""> </span>partition<span style=""> </span>- select (define) a partition table</p> <p class="MsoNormal"><span style=""> </span>current<span style=""> </span>- describe the current disk</p> <p class="MsoNormal"><span style=""> </span>format<span style=""> </span>- format and analyze the disk</p> <p class="MsoNormal"><span style=""> </span>repair<span style=""> </span>- repair a defective sector</p> <p class="MsoNormal"><span style=""> </span>show<span style=""> </span>- translate a disk address</p> <p class="MsoNormal"><span style=""> </span>label<span style=""> </span>- write label to the disk</p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>analyze<span style=""> </span>- surface analysis</p> <p class="MsoNormal"><span style=""> </span>defect<span style=""> </span>- defect list management</p> <p class="MsoNormal"><span style=""> </span>backup<span style=""> </span>- search for backup labels</p> <p class="MsoNormal"><span style=""> </span>quit</p> <p class="MsoNormal"><span style=""> </span>format></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">We need to enter type at the format> prompt so that we can tell SunOS the kind of disk we have. The resulting menu looks something like:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>AVAILABLE DRIVE TYPES:</p> <p class="MsoNormal"><span style=""> </span>0. Quantum ProDrive 80S</p> <p class="MsoNormal"><span style=""> </span>1. Quantum ProDrive 105S</p> <p class="MsoNormal"><span style=""> </span>2. CDC Wren IV 94171-344</p> <p class="MsoNormal"><span style=""> </span>3. SUN0104</p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>...</p> <p class="MsoNormal"><span style=""> </span>13. other</p> <p class="MsoNormal"><span style=""> </span>Specify disk type (enter its number):</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Because we are adding a disk this machine has not seen before, we need to select option 13, other. This begins a series of prompts requesting the disk's geometry. Be sure to have this information from the manufacturer before starting this procedure.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The first question, Enter number of data cylinders: is actually a three-part question. After you enter the number of data cylinders, the program asks for the number of alternative cylinders and then the number of physical cylinders. The number of physical cylinders is the number your manufacturer provided you. Subtract two from there to get the number of data cylinders, and then just use the default value of 2 for the number of alternate cylinders. For our Seagate disk, we answered the questions as follows:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter number of data cylinders: 3508</p> <p class="MsoNormal"><span style=""> </span>Enter number of alternate cylinders [2]: 2</p> <p class="MsoNormal"><span style=""> </span>Enter number of physical cylinders [3510]: 3510</p> <p class="MsoNormal"><span style=""> </span>Enter number of heads: 11</p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>Enter number of data sectors/track: 108</p> <p class="MsoNormal"><span style=""> </span>Enter rpm of drive [3600]:</p> <p class="MsoNormal"><span style=""> </span>Enter disk type name (remember quotes): "SEAGATE ST32550N"</p> <p class="MsoNormal"><span style=""> </span>selecting sd1: <seagate></p> <p class="MsoNormal"><span style=""> </span>[disk formatted, no defect list found]</p> <p class="MsoNormal"><span style=""> </span>No defined partition tables.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Note that even though our sample drive actually rotates at 7200 rpm, we stick with the default of 3600 rpm because the software will not accept entering a higher speed. Thankfully, this doesn't matter because the operating system doesn't use the information.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Even though format reported that the disk was formatted, it really wasn't. It only acquired information needed to later write the label.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now we are ready to begin preparations to partition the disk.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">These preparations entail computing the amount each cylinder holds and then approximating the number of cylinders we want in each partition.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">With our sample disk, we know that each cylinder is composed of 108 sectors on a track, with 11 tracks composing the cylinder.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">From the information we saw in dmesg, we know that each block is 512 bytes long. Hence, if we want our mail partition to be 1 GB in size, we perform the following math to compute the necessary blocks:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">1 gigabyte = 1048576 kilobytes</p> <p class="MsoNormal"><span style=""> </span>One cylinder = 108 sectors * 11 heads = 1188 blocks</p> <p class="MsoNormal"><span style=""> </span>1188 blocks = 594 kilobytes</p> <p class="MsoNormal"><span style=""> </span>1048576 / 594 = 1765 cylinders</p> <p class="MsoNormal"><span style=""> </span>1765 * 1188 = 2096820 blocks</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Obviously, there are some rounding errors since the exact one GB mark occurs in the middle of a cylinder and we need to keep each partition on a cylinder boundary. 1,765 cylinders is more than close enough. The 1,765 cylinders translates to 2,096,820 blocks.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The new swap partition we want to make needs to be 64 MB in size. Using the same math as before, we find that our swap needs to be 130,680 blocks long. The last partition on the disk needs to fill the remainder of the disk. Knowing that we have a 2 GB disk, a 1 GB mail spool, and a 64 MB swap partition, this should leave us with about 960 MB for /usr/local.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Armed with this information, we are ready to tackle the partitioning. From the format> prompt, type partition to start the partitioning menu. The resulting screen looks something like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>format> partition</p> <p class="MsoNormal"><span style=""> </span>PARTITION MENU:</p> <p class="MsoNormal"><span style=""> </span>a<span style=""> </span>- change 'a' partition</p> <p class="MsoNormal"><span style=""> </span>b<span style=""> </span>- change 'b' partition</p> <p class="MsoNormal"><span style=""> </span>c<span style=""> </span>- change 'c' partition</p> <p class="MsoNormal"><span style=""> </span>d<span style=""> </span>- change 'd' partition</p> <p class="MsoNormal"><span style=""> </span>e<span style=""> </span>- change 'e' partition</p> <p class="MsoNormal"><span style=""> </span>f<span style=""> </span>- change 'f' partition</p> <p class="MsoNormal"><span style=""> </span>g<span style=""> </span>- change 'g' partition</p> <p class="MsoNormal"><span style=""> </span>h<span style=""> </span>- change 'h' partition</p> <p class="MsoNormal"><span style=""> </span>select - select a predefined table</p> <p class="MsoNormal"><span style=""> </span>name<span style=""> </span>- name the current table</p> <p class="MsoNormal"><span style=""> </span>print<span style=""> </span>- display the current table</p> <p class="MsoNormal"><span style=""> </span>label<span style=""> </span>- write partition map and label to the disk</p> <p class="MsoNormal"><span style=""> </span>quit</p> <p class="MsoNormal"><span style=""> </span>partition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To create our mail partition, we begin by changing partition a. At the partition> prompt, type a.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition> a</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This brings up a prompt for entering the starting cylinder and the number of blocks to allocate. Because this is going to be the first partition on the disk, we start at cylinder 0. Based on the math we did earlier, we know that we need 2,096,820 blocks.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>partition a - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>Enter new starting cyl [0]: 0</p> <p class="MsoNormal"><span style=""> </span>Enter new # blocks [0, 0/0/0]: 2096820</p> <p class="MsoNormal"><span style=""> </span>partition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now we want to create the b partition, which is traditionally used for swap space. We know how many blocks to use based on our calculations, but we don't know which cylinder to start from.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To solve this, we simply display the current partition information for the entire disk using the p command:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition> p</p> <p class="MsoNormal">Current partition table (unnamed):</p> <p class="MsoNormal"><span style=""> </span>partition a - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>2096820 (1765/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition b - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition c - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition d - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition e - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition f - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition g - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition h - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">We can see that partition a is allocated with 2,096,820 blocks and is 1,765 cylinders long. Because we don't want to waste space on the disk, we start the swap partition on cylinder 1765.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">(Remember to count from zero!)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition> b</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>partition b - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter new starting cyl [0]: 1765</p> <p class="MsoNormal">Enter new # blocks [0, 0/0/0]: 130680</p> <p class="MsoNormal">partition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Before we create our last partition, we need to take care of some tradition first, namely partition c. This is usually the partition that spans the entire disk. Before creating this partition, we need to do a little math.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">108 cylinders x 11 heads x 3508 data cylinders = 4167504 blocks</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Notice that the number of blocks we compute here does not match the number actually on the disk. This number was computed based on the information we entered when giving the disk type information.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">It is important that we remain consistent.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Since the c partition spans the entire disk, we specify the starting cylinder as 0. Creating this partition should look something like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition> c</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>partition c - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter new starting cyl [0]: 0</p> <p class="MsoNormal">Enter new # blocks [0, 0/0/0]: 4167504</p> <p class="MsoNormal">partition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">We have only one partition left to create: /usr/local. Because we want to fill the remainder of the disk, we need to do one last bit of math to compute how many blocks are still free.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This is done by taking the size of partition c (the total disk) and subtracting the sizes of the existing partitions. For our example, this works out to be:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">4167504 - 2096820 - 130680 = 1940004 remaining blocks</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now we need to find out which cylinder to start from.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To do so, we run the p command again:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition> p</p> <p class="MsoNormal">Current partition table (unnamed):</p> <p class="MsoNormal"><span style=""> </span>partition a - starting cyl <span style=""> </span>0, # blocks<span style=""> </span>2096820 (1765/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition b - starting cyl<span style=""> </span>1765, # blocks<span style=""> </span>130680 (110/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition c - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>4167504 (3508/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition d - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>partition e - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition f - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition g - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><span style=""> </span>partition h - starting cyl<span style=""> </span>0, # blocks<span style=""> </span><span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To figure out which cylinder to start from, we add the number of cylinders used so far. Remember not to add the cylinders from partition c since it encompasses the entire disk.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">1765 + 110 = 1875</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now that we know which cylinder to start from and how many blocks to make it, we create our last partition.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition> d</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>partition d - starting cyl<span style=""> </span>0, # blocks<span style=""> </span>0 (0/0/0)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter new starting cyl [0]: 1875</p> <p class="MsoNormal">Enter new # blocks [0, 0/0/0]: 1940004</p> <p class="MsoNormal">partition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Congratulations! You've made it through the ugly part. Before we can truly claim victory, we need to commit these changes to disk using the label command. When given the prompt, Ready to label disk, continue? simply answer y.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition> label</p> <p class="MsoNormal">Ready to label disk, continue? y</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To leave the format program, type quit at the partition> prompt, and then quit again at the format> prompt.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Creating File Systems Now comes the easy part. Simply run the newfs command on all the partitions we created except for the swap partition and the entire disk partition . Your output should look similar to this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># newfs sd1a</p> <p class="MsoNormal">/dev/rsd1a:<span style=""> </span>2096820 sectors in 1765 cylinders of 11 tracks, 108 sectors</p> <p class="MsoNormal"><span style=""> </span>1073.6MB in 111 cyl groups (16 c/g, 9.73MB/g, 4480 i/g)</p> <p class="MsoNormal">superblock backups (for fsck -b #) at:</p> <p class="MsoNormal"><span style=""> </span>32, 19152, 38272, 57392, 76512, 95632, 114752, 133872, 152992,</p> <p class="MsoNormal"><span style=""> </span>172112, 191232, 210352, 229472, 248592, 267712, 286832, 304160, 323280,</p> <p class="MsoNormal"><span style=""> </span>342400, 361520, 380640, 399760, 418880, 438000, 457120, 476240, 495360,</p> <p class="MsoNormal"><span style=""> </span>514480, 533600, 552720, 571840, 590960, 608288, 627408, 646528, 665648,</p> <p class="MsoNormal"><span style=""> </span>684768, 703888, 723008, 742128, 761248, 780368, 799488, 818608, 837728,</p> <p class="MsoNormal"><span style=""> </span>856848, 875968, 895088, 912416, 931536, 950656, 969776, 988896, 1008016,</p> <p class="MsoNormal"><span style=""> </span>1027136, 1046256, 1065376, 1084496, 1103616, 1122736, 1141856, 1160976, 1180096,</p> <p class="MsoNormal"><span style=""> </span>1199216, 1216544, 1235664, 1254784, 1273904, 1293024, 1312144, 1331264, 1350384,</p> <p class="MsoNormal"><span style=""> </span>1369504, 1388624, 1407744, 1426864, 1445984, 1465104, 1484224, 1503344, 1520672,</p> <p class="MsoNormal"><span style=""> </span>1539792, 1558912, 1578032, 1597152, 1616272, 1635392, 1654512, 1673632, 1692752,</p> <p class="MsoNormal"><span style=""> </span>1711872, 1730992, 1750112, 1769232, 1788352, 1807472, 1824800, 1843920, 1863040,</p> <p class="MsoNormal"><span style=""> </span>1882160, 1901280, 1920400, 1939520, 1958640, 1977760, 1996880, 2016000, 2035120,</p> <p class="MsoNormal"><span style=""> </span>2054240, 2073360, 2092480,</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Be sure to note the superblock backups. This is critical information when fsck discovers heavy corruption in your file system. Remember to add your new entries into /etc/fstab if you want them to automatically mount on boot.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If you created the first partition with the intention of making it bootable, you have a few more steps to go. First, mount the new file system to /mnt.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># mount /dev/sd1a /mnt</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Once the file system is mounted, you need to clone your existing boot partition using the dump command like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># cd /mnt</p> <p class="MsoNormal"># dump 0f - / | restore -rf -</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">With the root partition cloned, use the installboot command to make it bootable:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># /usr/kvm/mdec/installboot /mnt/boot /usr/kvm/mdec/bootsd /dev/rsd1a</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Be sure to test your work by rebooting and making sure everything mounts correctly. If you created a bootable partition, be sure you can boot from it now. Don't wait for a disaster to find out whether or not you did it right.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Solaris For this example, we are partitioning a disk that is destined to be a web server for an intranet. We need a minimal root partition, adequate swap, tmp, var, and usr space, and a really large partition, which we'll call /web. Because the web logs will remain on the /web partition, and there will be little or no user activity on the machine, /var and /tmp will be set to smaller values. /usr will be a little larger because it may be destined to house web development tools.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Creating partitions </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal">TIP: In another wondrous effort on its part to be just a little different, Sun has decided to call partitions "slices." With the number of documents regarding the file system so vast, you'll find that not all of them have been updated to use this new term, so don't be confused by the mix of "slices" with "partitions"--they are both the same. </p> <p class="MsoNormal">--------------------------------------------------------------------------------</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Once a disk has been attached to the machine, you should verify its connection and SCSI address by running the probe-scsi command from the PROM monitor if the disk is attached to the internal SCSI chain, probe-scsi-all to list all the SCSI devices on the system Once this shows that the drive is properly attached and verified to be functioning, you're ready to start accessing the drive from the OS. Boot the machine and login as root.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">In order to find the device name, we are going to use for this, we again use the dmesg command.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># dmesg | grep sd</p> <p class="MsoNormal"><span style=""> </span>...</p> <p class="MsoNormal"><span style=""> </span>sd1 at esp0: target 1 lun 0</p> <p class="MsoNormal"><span style=""> </span>sd1 is /sbus@1,f8000000/esp@0,800000/sd@1,0</p> <p class="MsoNormal"><span style=""> </span>WARNING: /sbus@1,f8000000/esp@0,800000/sd@1,0 (sd1):</p> <p class="MsoNormal"><span style=""> </span>corrupt label - wrong magic number</p> <p class="MsoNormal"><span style=""> </span>Vendor 'SEAGATE', product 'ST32550N', 4194058 512 byte blocks</p> <p class="MsoNormal"><span style=""> </span>...</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">From this message, we see that our new disk is device /dev/[r]dsk/c0t1d0s2. The disk hasn't been set up for use on a Solaris machine before, which is why we received the corrupt label error.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If you recall the layout of Solaris device names, you'll remember that the last digit on the device name is the partition number. Noting that, we see that Solaris refers to the entire disk in partition 2, much the same way SunOS refers to the entire disk as partition c.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Before we can actually label and partition the disk, we need to create the device files. This is done with the drvconfig and disks commands. They should be invoked with no parameters:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># drvconfig ; disks</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Now that the kernel is aware of the disk, we are ready to run the format command to partition the disk.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># format /dev/rdsk/c0t1d0s2</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This brings up the format menu as follows:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">FORMAT MENU:</p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>disk<span style=""> </span>- select a disk</p> <p class="MsoNormal"><span style=""> </span>type<span style=""> </span>- select (define) a disk type</p> <p class="MsoNormal"><span style=""> </span>partition<span style=""> </span>- select (define) a partition table</p> <p class="MsoNormal"><span style=""> </span>current<span style=""> </span>- describe the current disk</p> <p class="MsoNormal"><span style=""> </span>format<span style=""> </span>- format and analyze the disk</p> <p class="MsoNormal"><span style=""> </span>repair<span style=""> </span>- repair a defective sector</p> <p class="MsoNormal"><span style=""> </span>label<span style=""> </span>- write label to the disk</p> <p class="MsoNormal"><span style=""> </span>analyze<span style=""> </span>- surface analysis</p> <p class="MsoNormal"><span style=""> </span>defect<span style=""> </span>- defect list management</p> <p class="MsoNormal"><span style=""> </span>backup<span style=""> </span>- search for backup labels</p> <p class="MsoNormal"><span style=""> </span>verify<span style=""> </span>- read and display labels</p> <p class="MsoNormal"><span style=""> </span>save <span style=""> </span>- save new disk/partition definitions</p> <p class="MsoNormal"><span style=""> </span>inquiry<span style=""> </span>- show vendor, product and revision</p> <p class="MsoNormal"><span style=""> </span>volname<span style=""> </span>- set 8-character volume name</p> <p class="MsoNormal"><span style=""> </span>quit</p> <p class="MsoNormal">format></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To help the format command with partitioning, we need to tell it the disk's geometry by invoking the type command at the format> prompt. We will then be asked to select what kind of disk we have. Because this is the first time this system is seeing this disk, we need to select other. This should look something like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">format> type</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">AVAILABLE DRIVE TYPES:</p> <p class="MsoNormal"><span style=""> </span>0. Auto configure</p> <p class="MsoNormal"><span style=""> </span>1. Quantum ProDrive 80S</p> <p class="MsoNormal"><span style=""> </span>2. Quantum ProDrive 105S</p> <p class="MsoNormal"><span style=""> </span>3. CDC Wren IV 94171-344</p> <p class="MsoNormal"><span style=""> </span>. . .</p> <p class="MsoNormal"><span style=""> </span>16. other</p> <p class="MsoNormal">Specify disk type (enter its number): 16</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The system now prompts for the number of data cylinders. This is two less than the number of cylinders the vendor specifies because Solaris needs two cylinders for bad block mapping.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter number of data cylinders: 3508</p> <p class="MsoNormal">Enter number of alternate cylinders[2]: 2</p> <p class="MsoNormal">Enter number of physical cylinders[3510]: 3510</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The next question can be answered from the vendor specs as well.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter number of heads: 14</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The followup question about drive heads can be left as default.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter physical number of heads[default]:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The last question you must answer can be pulled from the vendor specs as well.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter number of data sectors/track: 72</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The remaining questions should be left as default.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter number of physical sectors/track[default]:</p> <p class="MsoNormal">Enter rpm of drive[3600]:</p> <p class="MsoNormal">Enter format time[default]:</p> <p class="MsoNormal">Enter cylinder skew[default]:</p> <p class="MsoNormal">Enter track skew[default]:</p> <p class="MsoNormal">Enter tracks per zone[default]:</p> <p class="MsoNormal">Enter alternate tracks[default]:</p> <p class="MsoNormal">Enter alternate sectors[default]:</p> <p class="MsoNormal">Enter cache control[default]:</p> <p class="MsoNormal">Enter prefetch threshold[default]:</p> <p class="MsoNormal">Enter minimum prefetch[default]:</p> <p class="MsoNormal">Enter maximum prefetch[default]:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The last question you must answer about the disk is its label information. Enter the vendor name and model number in double quotes for this question. For our sample disk, this would be:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter disk type name (remember quotes): "SEAGATE ST32550N"</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">With this information, Solaris makes creating partitions easy. Dare I say, fun?</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">After the last question from the type command, you will be placed at the format> prompt. Enter partition to start the partition menu.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">format><span style=""> </span>partition</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">PARTITION MENU:</p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>0<span style=""> </span>- change '0' partition</p> <p class="MsoNormal"><span style=""> </span>1<span style=""> </span>- change '1' partition</p> <p class="MsoNormal"><span style=""> </span>2<span style=""> </span>- change '2' partition</p> <p class="MsoNormal"><span style=""> </span>3<span style=""> </span>- change '3' partition</p> <p class="MsoNormal"><span style=""> </span>4<span style=""> </span>- change '4' partition</p> <p class="MsoNormal"><span style=""> </span>5<span style=""> </span>- change '5' partition</p> <p class="MsoNormal"><span style=""> </span>6<span style=""> </span>- change '6' partition</p> <p class="MsoNormal"><span style=""> </span>7<span style=""> </span>- change '7' partition</p> <p class="MsoNormal"><span style=""> </span>select - select a predefined table</p> <p class="MsoNormal"><span style=""> </span>modify - modify a predefined partition table</p> <p class="MsoNormal"><span style=""> </span>name<span style=""> </span>- name the current table</p> <p class="MsoNormal"><span style=""> </span>print<span style=""> </span>- display the current table</p> <p class="MsoNormal"><span style=""> </span>label<span style=""> </span>- write partition map and label to the disk</p> <p class="MsoNormal"><span style=""> </span>quit</p> <p class="MsoNormal">partition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">At the partition> prompt, enter modify to begin creating the new partitions. This brings up a question about what template to use for partitioning. We want the All Free Hog method.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">partition> modify</p> <p class="MsoNormal">Select partitioning base:</p> <p class="MsoNormal"><span style=""> </span>0. Current partition table (unnamed)</p> <p class="MsoNormal"><span style=""> </span>1. All Free Hog</p> <p class="MsoNormal">Choose base (enter number)[0]? 1</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The All Free Hog method enables you to select one partition to receive the remainder of the disk once you have allocated a specific amount of space for the other partitions. For our example, the disk hog would be the /web partition because you want it to be as large as possible.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">As soon as you select option 1, you should see the following screen:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Part<span style=""> </span>Tag<span style=""> </span>Flag<span style=""> </span>Cylinders<span style=""> </span>Size<span style=""> </span>Blocks</p> <p class="MsoNormal"><span style=""> </span>0<span style=""> </span>root<span style=""> </span>wm<span style=""> </span>0<span style=""> </span>0<span style=""> </span>(0/0/0)</p> <p class="MsoNormal"><span style=""> </span>1<span style=""> </span>swap<span style=""> </span>wu<span style=""> </span>0<span style=""> </span>0<span style=""> </span>(0/0/0)</p> <p class="MsoNormal"><span style=""> </span>2<span style=""> </span>backup<span style=""> </span>wu<span style=""> </span>0 - 3507<span style=""> </span>1.99GB<span style=""> </span>(3508/0/0)</p> <p class="MsoNormal"><span style=""> </span>3<span style=""> </span>unassigned<span style=""> </span>wm<span style=""> </span>0<span style=""> </span>0<span style=""> </span>(0/0/0)</p> <p class="MsoNormal"><span style=""> </span>4<span style=""> </span>unassigned<span style=""> </span>wm<span style=""> </span>0<span style=""> </span>0<span style=""> </span>(0/0/0)</p> <p class="MsoNormal"><span style=""> </span>5<span style=""> </span>unassigned<span style=""> </span>wm<span style=""> </span>0<span style=""> </span>0<span style=""> </span>(0/0/0)</p> <p class="MsoNormal"><span style=""> </span>6<span style=""> </span>usr<span style=""> </span>wm<span style=""> </span>0<span style=""> </span>0<span style=""> </span>(0/0/0)</p> <p class="MsoNormal"><span style=""> </span>7<span style=""> </span>unassigned<span style=""> </span>wm<span style=""> </span>0<span style=""> </span>0<span style=""> </span>(0/0/0)</p> <p class="MsoNormal">Do you wish to continue creating a new partition</p> <p class="MsoNormal">table based on above table [yes]? yes</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Because the partition table appears reasonable, agree to use it as a base for your scheme. You will now be asked which partition should be the Free Hog Partition, the one that receives whatever is left of the disk when everything else has been allocated.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">For our scheme, we'll make that partition number 5.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Free Hog Partition[6]? 5</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Answering this question starts the list of questions asking how large to make the other partitions. For our web server, we need a root partition to be about 200 MB for the system software, a swap partition to be 64 MB, a /tmp partition to be 200 MB, a /var partition to be 200 MB, and a /usr partition to be 400 MB. Keeping in mind that partition 2 has already been tagged as the "entire disk" and that partition 5 will receive the remainder of the disk, you will be prompted as follows:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter size of partition '0' [0b, 0c, 0.00mb]: 200mb</p> <p class="MsoNormal">Enter size of partition '1' [0b, 0c, 0.00mb]: 64mb</p> <p class="MsoNormal">Enter size of partition '3' [0b, 0c, 0.00mb]: 200mb</p> <p class="MsoNormal">Enter size of partition '4' [0b, 0c, 0.00mb]: 200mb</p> <p class="MsoNormal">Enter size of partition '6' [0b, 0c, 0.00mb]: 400mb</p> <p class="MsoNormal">Enter size of partition '7' [0b, 0c, 0.00mb]: 0</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">As soon as you finish answering these questions, the final view of all the partitions appears looking something like:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Part<span style=""> </span>Tag<span style=""> </span>Flag<span style=""> </span>Cylinders<span style=""> </span>Size<span style=""> </span>Blocks</p> <p class="MsoNormal"><span style=""> </span>0<span style=""> </span>root<span style=""> </span>wm<span style=""> </span>0 - 344<span style=""> </span>200.13mb<span style=""> </span>(345/0/0)</p> <p class="MsoNormal"><span style=""> </span>1<span style=""> </span>swap<span style=""> </span>wu<span style=""> </span>345 - 455<span style=""> </span>64.39mb<span style=""> </span>(111/0/0)</p> <p class="MsoNormal"><span style=""> </span>2<span style=""> </span>backup<span style=""> </span>wu<span style=""> </span>0 - 3507<span style=""> </span>1.99GB<span style=""> </span>(3508/0/0)</p> <p class="MsoNormal"><span style=""> </span>3<span style=""> </span>unassigned<span style=""> </span>wm <span style=""> </span>456 - 800<span style=""> </span>200.13mb<span style=""> </span>(345/0/0)</p> <p class="MsoNormal"><span style=""> </span>4<span style=""> </span>unassigned<span style=""> </span>wm<span style=""> </span>801 - 1145<span style=""> </span>200.13mb<span style=""> </span>(345/0/0)</p> <p class="MsoNormal"><span style=""> </span>5<span style=""> </span>unassigned<span style=""> </span>wm<span style=""> </span>1146 - 2817<span style=""> </span>969.89mb<span style=""> </span>(1672/0/0)</p> <p class="MsoNormal"><span style=""> </span>6<span style=""> </span>unassigned<span style=""> </span>wm<span style=""> </span>2818 - 3507<span style=""> </span>400.25mb<span style=""> </span>(690/0/0)</p> <p class="MsoNormal"><span style=""> </span>7<span style=""> </span>unassigned<span style=""> </span>wm<span style=""> </span>0<span style=""> </span>0<span style=""> </span>(0/0/0)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This is followed by the question:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Okay to make this the correct partition table [yes]? yes</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Answer yes since the table appears reasonable. This brings up the question:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Enter table name (remember quotes): "SEAGATE ST32550N"</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Answer with a description of the disk you are using for this example. Remember to include the quote symbols when answering. Given all of this information, the system is ready to commit this to disk. As one last check, you will be asked:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Ready to label disk, continue? y</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">As you might imagine, we answer yes to the question and let it commit the changes to disk. You have now created partitions and can quit the program by entering quit at the partition> prompt and again at the format> prompt.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Creating file systems To create a file system, simply run:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># newfs /dev/c0t1d0s0</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">where /dev/c0t1d0s0 is the partition on which to create the file system. Be sure to create a file system on all the partitions except for partitions 2 and 3, the swap, and entire disk, respectively. Be sure to note the backup superblocks that were created. This information is very useful when fsck is attempting to repair a heavily damaged file system.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">After you create the file systems, be sure to enter them into the /etc/vfstab file so that they are mounted the next time you reboot.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">If you need to make the root partition bootable, you still have two more steps. The first is to clone the root partition from your existing system to the new root partition using:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span># mount /dev/dsk/c0t1d0s0 /mnt</p> <p class="MsoNormal"><span style=""> </span># ufsdump 0uf - / | ufsrestore -rf -</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Once the file root partition is cloned, you can run the installboot program like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># /usr/sbin/installboot /usr/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Be sure to test your new file systems before you need to rely on them in a disaster situation.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">IRIX For this example, we are creating a large scratch partition for a user who does modeling and simulations. Although IRIX has many GUI-based tools to perform these tasks, it is always a good idea to learn the command line versions just in case you need to do any kind of remote administration.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Creating partitions Once the drive is attached, run a program called hinv to take a "hardware inventory." On the sample system, you saw the following output:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">...</p> <p class="MsoNormal">Integral SCSI controller 1: Version WD33C93B, revision D</p> <p class="MsoNormal"><span style=""> </span>Disk drive: unit 6 on SCSI controller 1</p> <p class="MsoNormal">Integral SCSI controller 0: Version WD33C93B, revision D</p> <p class="MsoNormal"><span style=""> </span>Disk drive: unit 1 on SCSI controller 0</p> <p class="MsoNormal">...</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Our new disk is external to the system, so we know it is residing on controller 1. Unit 6 is the only disk on that chain, so we know that it is the disk we just added to the system.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">To partition the disk, run the fx command without any parameters. It prompts us for the device name, controller, and drive number. Choose the default device name and enter the appropriate information for the other two questions.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">On our sample system, this would look like:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># fx</p> <p class="MsoNormal">fx version 6.2, Mar<span style=""> </span>9, 1996</p> <p class="MsoNormal">fx: "device-name" = (dksc)</p> <p class="MsoNormal">fx: ctlr# = (0) 1</p> <p class="MsoNormal">fx: drive# = (1) 6</p> <p class="MsoNormal">fx: lun# = (0)</p> <p class="MsoNormal">...opening dksc(1,6,0)</p> <p class="MsoNormal">...controller test...OK</p> <p class="MsoNormal">Scsi drive type == SEAGATE ST32550N<span style=""> </span>0022</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">----- please choose one (? for help, .. to quit this menu)-----</p> <p class="MsoNormal">[exi]t<span style=""> </span>[d]ebug/<span style=""> </span>[l]abel/</p> <p class="MsoNormal">[b]adblock/<span style=""> </span>[exe]rcise/<span style=""> </span><span style=""> </span>[r]epartition/</p> <p class="MsoNormal">fx></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">We see that fx found our Seagate and is ready to work with it. From the menu we select r to repartition the disk. fx displays what it knows about the disk and then presents another menu specifically for partitioning the disk.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">fx> r</p> <p class="MsoNormal">----- partitions-----</p> <p class="MsoNormal">part<span style=""> </span>type<span style=""> </span>cyls<span style=""> </span>blocks<span style=""> </span>Megabytes<span style=""> </span>(base+size)</p> <p class="MsoNormal"><span style=""> </span>7: xfs<span style=""> </span>3 + 3521<span style=""> </span>3570 + 4189990<span style=""> </span>2 + 2046</p> <p class="MsoNormal"><span style=""> </span>8: volhdr<span style=""> </span>0 + 3<span style=""> </span>0 + 3570<span style=""> </span>0 + 2</p> <p class="MsoNormal"><span style=""> </span>10: volume<span style=""> </span>0 + 3524<span style=""> </span>0 + 4193560<span style=""> </span>0 + 2048</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">capacity is 4194058 blocks</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">----- please choose one (? for help, .. to quit this menu)-----</p> <p class="MsoNormal">[ro]otdrive<span style=""> </span>[u]srrootdrive<span style=""> </span>[o]ptiondrive<span style=""> </span>[re]size</p> <p class="MsoNormal">fx/repartition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Looking at the result, we see that this disk has never been partitioned in IRIX before. Part 7 represents the amount of partitionable space, part 8 the volume header, and part 10 the entire disk.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Because this disk is going to be used as a large scratch partition, we want to select the optiondrive option from the menu. After you select that, you are asked what kind of file system you want to use. IRIX 6 and above defaults to xfs, while IRIX 5 defaults to efs. Use the one appropriate for your version of IRIX.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Our sample system is running IRIX 6.3, so we accept the default of xfs:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">fx/repartition> o</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">fx/repartition/optiondrive: type of data partition = (xfs)</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Next we are asked whether we want to create a /usr log partition. Because our primary system already has a /usr partition, we don't need one here. Type no.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">fx/repartition/optiondrive: create usr log partition? = (yes) no</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The system is ready to partition the drive. Before it does, it gives one last warning allowing you to stop the partitioning before it completes the job. Because you know you are partitioning the correct disk, you can give it "the go-ahead":</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Warning: you must reinstall all software and restore user data from backups after changing the partition layout. Changing partitions causes all data on the drive to be lost. Be sure you have the drive backed up if it contains any user data. Continue? y</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The system takes a few seconds to create the new partitions on the disk. Once it is done, it reports what the current partition list looks like.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">----- partitions-----</p> <p class="MsoNormal">part<span style=""> </span>type<span style=""> </span>cyls<span style=""> </span>blocks<span style=""> </span>Megabytes<span style=""> </span>(base+size)</p> <p class="MsoNormal"><span style=""> </span>7: xfs<span style=""> </span>3 + 3521<span style=""> </span>3570 + 4189990<span style=""> </span>2 + 2046</p> <p class="MsoNormal"><span style=""> </span>8: volhdr<span style=""> </span>0 + 3<span style=""> </span>0 + 3570<span style=""> </span>0 + 2</p> <p class="MsoNormal"><span style=""> </span>10: volume<span style=""> </span>0 + 3524<span style=""> </span>0 + 4193560<span style=""> </span>0 + 2048</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">capacity is 4194058 blocks</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">----- please choose one (? for help, .. to quit this menu)-----</p> <p class="MsoNormal">[ro]otdrive<span style=""> </span>[u]srrootdrive<span style=""> </span>[o]ptiondrive<span style=""> </span>[re]size</p> <p class="MsoNormal">fx/repartition></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Looks good. We can exit fx now by typing .. at the fx/repartition> prompt and exit at the fx> prompt.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Our one large scratch partition is now called /dev/dsk/dks1d6s7.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Creating the filesystem To create the file system, we use the mkfs command like this:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"># mkfs /dev/rdsk/dks1d6s7</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">This generates the following output:</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">meta-data=/dev/dsk/dks1d6s7<span style=""> </span>isize=256<span style=""> </span>agcount=8, agsize=65469 blks</p> <p class="MsoNormal">data<span style=""> </span>=<span style=""> </span>bsize=4096<span style=""> </span>blocks=523748, imaxpct=25</p> <p class="MsoNormal">log<span style=""> </span>=internal log<span style=""> </span>bsize=4096<span style=""> </span>blocks=1000</p> <p class="MsoNormal">realtime =none<span style=""> </span>bsize=65536<span style=""> </span>blocks=0, rtextents=0</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Remember to add this entry into the /etc/fstab file so that the system automatically mounts the next time you reboot. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Summary</p> <p class="MsoNormal">As you've seen in this chapter, creating, maintaining, and repairing filesystems is not a trivial task. It is, however, a task which should be well understood. An unmaintained file system can quickly lead to trouble and without its stability, the remainder of the system is useless.</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Let's make a quick rundown of the topics we covered: </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Disks are broken into partitions (sometimes called slices). </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Each partition has a file system. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">A file system is the primary means of file storage in UNIX. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">File systems are made of inodes and superblocks. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Some partitions are used for raw data such as swap. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The /proc file system really isn't a file system, but an abstraction to kernel data. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">An inode maintains critical file information. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Superblocks track disk information as well as the location of the heads of various inode lists. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">In order for you to use a file system, it must be mounted. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">No one must be accessing a file system in order for it to be unmounted. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">File systems can be mounted anywhere in the directory tree. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">/etc/fstab (vfstab in Solaris) is used to by the system to automatically mount file systems on boot. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The root file system should be kept away from users. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">The root file system should never get filled. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Be sure to watch how much space is being used. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">fsck is the tool to use to repair file systems. </p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">Don't forget to terminate your SCSI chain! </p> <p class="MsoNormal">In short, file systems administration is not a trivial task and should not be taken lightly. Good maintenance techniques not only help maintain your uptime, but your sanity as well. </p> <p class="MsoNormal"><span style=""> </span></p> <p class="MsoNormal"><span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal">©Copyright, Macmillan Computer Publishing. All rights reserved. </p> <p class="MsoNormal"><span style=""> </span></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-28306264729362728372008-08-28T23:57:00.002-07:002008-12-23T00:12:05.690-08:00What Is System Administration?<h1 align="center"><span style="color:#000077;"><br /></span></h1> <p><i>By Eric Goebelbecker</i></p> <p>System Administration is planning, installing, and maintaining computer systems. If that seems like a very generalized answer, it's because "What is System Administration" is a broad question.</p> <p>In this chapter we'll describe what is expected from a System Administrator, and how she might approach her responsibilities.</p> <blockquote> <p> </p><hr /> <span style="color:#000077;"><b>Help Wanted</b></span><br /> Administer Sun and IBM UNIX systems and control Internet access. Assist with some database administration (Oracle). Administer Sun server and network: system configuration, user id/creation/maintenance, security administration, system backup, and ensuring all applications are running on the system properly. Administer Internet access and services: internal/external security, user identification creation and maintenance, and Web server maintenance. <hr /> </blockquote> <p>This is a typical "Help Wanted" advertisement for a UNIX System Administration position. From this description you might guess that a System Administrator has to install and configure the operating system, add new users, back up the system(s), keep the systems secure, and make sure they stay running. Setting up Internet access and keeping it running is part of the job too.</p> <p>Unfortunately, you'd only be considering about half of the job. Being an expert on installing, running, and maintaining all of the major UNIX variants isn't enough to be a truly good system administrator. There is a significant nontechnical component to being a system administrator, especially in terms of planning, organizational, and people skills.</p> <p>As computers become more and more pervasive in business, system administration becomes a mission critical position in more and more organizations. The administrator has to understand the systems that he is responsible for, the people who use them, and the nature of the business that they are used for. A key skill in administration is planning, because at the rate that systems are being created, overhauled, and expanded, trying to improvise and design a network "on the fly" just doesn't work.</p> <p>Companies are moving more and more processes not just to computers, but to point of sale systems, such as Web commerce and sophisticated in-store systems, such as electronic catalogs and cash registers that are directly connected to both inventory and credit systems. Companies that may have moved their inventory control to computers five years ago are scrambling to get order entry computerized and on the Web, while companies that haven't automated their inventory and ordering systems yet are scrambling to do so in order to remain competitive. E-mail is now regarded as just as important as faxes and telephones, while every part of customer service that can be manned by a computer and fax retrieval system already is. These companies are almost completely dependent on their computers, and their system administrators need to understand a lot more than how to partition a disk drive, add memory, and install Adobe PhotoShop.</p> <p>This chapter introduces some of the basic technical and organizational concepts that a system administrator needs to know in order to perform his job well. It also covers a few key system administration tools that are already found with most UNIX variants or are included on the UNIX Unleashed CD that accompanied this book.</p> <p>The chapter is divided into the following sections: </p><ul><li>Technical Concepts for System Administrators--in this section we introduce some of UNIX's important characteristics and how they differ from operating systems like Windows and Macintosh. <p> </p></li><li>UNIX is Heterogeneous--this section describes UNIX's diverse and sometimes self-contradictory user interfaces and how those interfaces ended up that way. <p> </p></li><li>System Administration Tasks--this part of the chapter is where basic administration tasks and responsibilities are introduced. <p> </p></li><li>Administration Resources--both the operating system itself and the Internet provide a wide variety of information for administrators. This section provides a few pointers to these resources. <p> </p></li><li>Tools of the Trade--UNIX provides users and administrators with an amazing set of tools. We briefly cover a few of them in the end of this chapter. </li></ul> <blockquote> <p> </p><hr /> <span style="color:#000077;"><b>TIP:</b> </span>No one, regardless of how long they've "been in the business" can remember all of the configuration options, command line switches, oddities, and outright bugs in the UNIX tool chest. Experienced users soon learn the value of UNIX's online documentation, the <i>manual pages. </i>Before you use any tool, read the man page(s) for it; many of them include useful examples. If you install a utility from the CD, be sure you read the installation instructions that accompany it and install the man page too. Later in this chapter we'll cover some advanced features found in the manual page system. <hr /> </blockquote> <h2><span style="color:#000077;"><b>Technical Concepts for New System Administrators</b></span></h2> <p>UNIX differs from Windows and Macintosh at a fundamental level. UNIX was originally intended for multiple users running multiple simultaneous programs. (At least it was by the time it was distributed outside of Bell Labs.) The phenomenon of a user having a low cost personal workstation, running Linux or any other variant of UNIX is actually a recent development in terms of the operating system's history. The fact that UNIX is designed for use by more than a single user is reflected throughout the operating system's file systems, security features, and programming model.</p> <p>Networking is not an afterthought or a recent development for UNIX, the way it seems to be for Windows and Macintosh. Support for sharing files, moving from workstation to workstation, and running applications on remote computers that are controlled and viewed on a local workstation is not only intuitive and natural on UNIX, but was more powerful and stable on past versions of UNIX than the latest versions of Windows and Windows NT. </p><h3><span style="color:#000077;"><b>Multiple Users and Multiple Accounts</b></span></h3> <p>The DOS/Windows and Macintosh environments are "computer centric" in terms of security and customization. The ownership of files and <i>processes</i> (programs that are currently running) is more or less governed by the computer where they are located as opposed to the notion of a user id or session. If a person can physically get to a computer, he has access to all of the files and programs on it. If a truly malicious person wants access to the contents of a PC, even a password-protected screen saver can be overcome by restarting the system, because the files and programs belong to the PC, not a user, and the computer will boot ready for use. (Even the login prompt on Windows 95 can be bypassed with the Cancel button, bringing the user interface up with no network resources connected.)</p> <p>Add-ons are available for DOS and Macintosh systems that enable users to identify themselves and save files in protected areas. But these are applications, not a part of the operating system, and come with their own set of problems, limitations, and rules. The fact is, as anyone who has ever had to share a computer with a family member or coworker will agree, personal computer operating systems are single user and geared toward supporting one user and one set of configuration options.</p> <p>UNIX systems are multi-user. Users must log in to the system. Each has his own areas for saving files, the <i>home directory, </i>and files have properties that determine who can or cannot access them, their<i> mode</i>. All running programs are associated with a user, and, similar to the way files have access control, programs can only be started or stopped by certain users. Unless a user can log in as the <i>super-user</i>, she cannot access another user's files unless the owner gives her permission through one of several direct or indirect means. Only the super-user can reboot the computer (without the power switch) or stop another user's processes. Even if a system is rebooted, all of the security features will be remain effect, so restarting is not a valid means of subverting security. </p><h3><span style="color:#000077;"><b>Network Centricity</b></span></h3> <p>Networking has become an integral part of UNIX. The ability to share files, support network logins, share network configuration information, and run applications across a network is included in all of the major UNIX distributions, and more importantly is a natural extension of the base operating system, not an application that was designed by an individual vendor, with their idea of networking and administration, and that has to be purchased separately.</p> <p>When configured to allow it, anything that can be done at the <i>console</i> (main keyboard and monitor) of a UNIX system can be done at another system via a network connection. (We'll refer to these other systems as <i>remote nodes </i>or <i>remote systems.</i>) Actually many server systems, such as Web servers and file servers, have consoles with very limited capabilities (such as a text-only terminal), and are deliberately designed with the idea of doing as much administration as possible from remote nodes outside the data center.</p> <p>Two of the mechanisms that provide these capabilities are <i>remote </i>(or <i>pseudo</i>) terminals<i> </i>and <i>remote shells. </i>Remote terminals emulate an actual terminal session, just as if the user were logged into a terminal connected to the system via a serial line, where the network is the line and the application (usually <i>telnet)</i> is the terminal (Remote terminals are usually referred to as telnet sessions, since telnet is by far the most common application.) This is similar, in theory at least, to dialing into a system and using an application like Procomm.</p> <p>Remote shells (or remote logins) are sessions on remote computers that are centered around the execution of a shell (or shell command) instead of a terminal on a remote system. A remote shell executes a command on a remote host, while a remote login runs a shell; both usually appear to be running on the local system. Remote shells are frequently used by administrators in shell scripts, allowing them to execute commands on several systems and consolidate the results in one place, such as collecting disk utilization statistics or automating backups.</p> <p>The differences between a remote shell and a telnet session are very important. Telnet sessions use terminal emulation and are run as separate applications. So the results cannot be shared with other applications unless a mechanism such as cut and paste is used, while remote shells allow the results of commands to be interspersed with local commands.</p> <p>So a directory on one workstation could be backed up to a tape drive on another via a simple shell command:</p> <pre><span style="color:#0066ff;">tar cvfb - tgt_dir | rsh -n bilbo dd of=/dev/rmt/0<br /></span></pre> <p>The <tt>tar</tt> command creates an archive<b> </b>of <tt>tgt_dir</tt> and sends it to <i>standard output.</i><b> </b>This stream of data is redirected to the <tt>rsh</tt> command. r<tt>sh</tt><b> </b>connects to the host <tt>bilbo</tt>, executes <tt>dd</tt>, and passes the output of <tt>tar</tt> to it. The <tt>dd</tt> command just happens to know how to save the archive to the tape drive on <tt>/dev/rmt/0</tt><b>. </b>(This may seem complicated. By the end of this chapter, it will make perfect sense.) So two programs on two different computers are linked as one, without any special configuration requirements or extra software.</p> <p>With remote logins and shells being so powerful, why would anyone use telnet? One reason is that telnet is much more robust over slow links, such as Internet and WAN connections between different sites than remote logins, The other is security. We'll cover some of the risks posed by remote shells later.</p> <p>X-windows is another example of UNIX's networking prowess. The X environment is a graphical user interface, much like the Windows or Macintosh environments. A key difference is that it is segmented into a client (the application) and a server (the display.) The server is a process that manages the keyboard, mouse, and screen, and accepts connections from applications over a <tt>socket</tt> (a network connection). Because a network connection is the method of communication between the two programs, the application can be running on a different workstation than the display that is controlling it. (When applications are running on the same workstation as the server, the network connection is frequently bypassed in favor of faster methods. These enhancements are proprietary extensions and differ widely from vendor to vendor.)</p> <p>The remote functionality of X-windows is a very powerful advantage, especially when considered in terms of large database, Web, or file servers that tend to be installed in data centers or equipment rooms, but have graphical management and configuration applications. Another possibility is installing slower, less expensive workstations on desktops while still being able to run more demanding applications on shared, more powerful computers.</p> <p>File sharing is another extension that has become a natural and integral part of UNIX computing. All of the major UNIX variants support <i>NFS </i>(Network File System) and can share files seamlessly between themselves and other UNIX versions.</p> <p>Because NFS file systems are treated like any other type of disk, the same way SCSI, IDE, and floppy disks are implemented, network drives fully support user accounts, file permissions, and all of the mechanisms UNIX already uses for adding, removing, and managing other types of files and file systems, even when shared between different UNIX variants.</p> <p>This means that two UNIX systems, regardless of what version of UNIX or on what type of computer they happen to be, can share files, maybe even from a common file server running on a third system type. Only the user IDs have to be coordinated in order for the files to be securely shared. No additional software or special modifications are required.</p> <p>Any UNIX system can <i>export</i> or <i>share </i>file systems. This is one of the ways that the difference between servers and clients is blurred with UNIX systems; any system can provide or consume file system resources. When file systems are shared, the workstation can specify which systems can and cannot use it, and also whether or not users may write to it.</p> <p>Clients specify where the file system will be mounted in their directory tree. For example, a system can mount the <tt>/export/applications</tt> directory from another system to the <tt>/mnt/apps</tt> directory. </p><h3><span style="color:#000077;"><b>UNIX Networking: Sharing files and Information</b></span></h3> <p>Consider the following practical applications to illustrate how UNIX networking works, and how some common tools and planning can make administration very easy.</p> <p>A system that is frequently used to administer NFS is the <i>automounter.</i> This program (or set of programs) allows administrators to specify file systems to be <i>mounted</i> (attached) and <i>unmounted</i> (detached) as needed, based on when clients refer to them. This process happens completely in the background, without any intervention after the automount program(s) are configured properly.</p> <blockquote> <p> </p><hr /> <span style="color:#000077;"><b>LINUX</b></span><b><br /> </b>Linux systems use a publicly available application called <tt>amd</tt><i> </i>instead of <tt>automount</tt>. Although the configuration files differ slightly, the functionality <tt>amd</tt> provides Linux is the same. <tt>amd</tt> is provided with all of the major Linux distributions. As always, see the manual page for specifics. <hr /> </blockquote> <p><tt>automount</tt> is configured with <i>maps </i>(a fancy term used for referring to configuration files)<i>, </i>where each map specifies a top level directory. So, if the automount system is to create five directories, the <i>master</i> map, which is contained in the file <tt>/etc/auto_master</tt> might look like this:</p> <pre><span style="color:#0066ff;">/share auto_share<br />/home auto_home<br />/gnu auto_gnu<br />/apps auto_apps<br />/opt auto_opt<br /></span></pre> <p>This file provides the <tt>automount</tt> with the names of the directories it will create and the files that contain what the directories will contain.</p> <p>For example, let's look at an organization that decided that all user directories belong under the directory <tt>/home</tt>. (Therefore, the user <tt>dan</tt> would find his files in <tt>/home/dan</tt>.)<b> </b>The first thirty home directories were located on the file server <tt>gandalf</tt> in the <tt>/export/home</tt> directory.</p> <p>When the next user comes along, the administrator realizes that <tt>gandalf</tt> does not have enough drive space for a new user, and, as a matter of fact, moving a couple of users over to the other file server, <tt>balrog</tt>, which has been used for applications until now, would probably be a good idea.</p> <p><tt>automount</tt> simplifies this distribution by allowing us to create a virtual <tt>/home</tt> directory on every workstation that runs the <tt>automount</tt> daemon. An excerpt from the home directory map, <tt>/etc/auto_home</tt>,<b> </b>as named in <tt>/etc/auto_master</tt> above, would look like this:</p> <pre><span style="color:#0066ff;">eric gandalf:/export/home/eric<br />dan gandalf:/export/home/dan<br />mike balrog:/export/home/michael<br /></span></pre> <p>In this map, <tt>eric</tt>, <tt>dan</tt>, and <tt>mike</tt> are referred to as directory <i>keys</i>. The directories are called <i>values. </i>When a program refers to <tt>/home/eric</tt><b> </b>for the first time<b>, </b>the system recognizes the key <tt>eric</tt><b> </b>and arranges for <tt>/export/home/eric</tt><b> </b>on <tt>gandalf</tt><b> </b>to be mounted at <tt>/home/eric</tt>. Because <tt>automount</tt> does a simple key/value replacement, Eric and Dan's directories can be on <tt>gandalf</tt><b> </b>while Mike's is on <tt>balrog</tt><b>. </b>Also note<b> </b>that the directory names in b<tt>alrog</tt><b> </b>and the automounter <i>virtual</i> directory do not have to agree. After a period of inactivity, <tt>automount</tt> unmounts the directory.</p> <p><tt>automount</tt><b> </b>alleviates the tedious task of mounting all of the directories that a user or group of users will need in advance. Permanently mounting all of those file systems leads to unnecessary system overhead and requires excessive human intervention. This system also makes it easier for users to travel from workstation to workstation, since they can always expect to find important application and data files in the same place.</p> <p><span style="color:#000077;"><b>Solaris</b></span><b><br /> </b>Sun Microsystems defined <i>autofs</i> as a new file system type in Solaris 2.x, and created a multi-threaded automounter system. This makes automounted file systems perform extraordinarily well under Solaris, since the kernel is now aware that automounted file systems exist and by preventing bottlenecks in the automount program through the use of threads.</p> <p><span style="color:#000077;"><b>HP-UX<br /> AIX</b></span><b><br /> </b>Hewlett Packard's<b> </b>HP-UX and IBM's AIX provide a version of <tt>automount.</tt> Since <tt>automount</tt> uses NFS, it is compatible across different UNIX variants.</p> <p>Newer versions of <tt>automount</tt> (and <tt>amd</tt>) also enable us to specify more than one file server for a directory, in order to provide a backup for when one file server is unavailable or overloaded. This system, with a little planning and thought, can simplify a distributed network and even make it a little more reliable.</p> <p>The maps, however, still must be kept up to date and distributed to each workstation. This could be done using <tt>ftp</tt><i>, </i>or even <tt>nfs</tt><b>, </b>but on a large network this can become tedious. There are two very elegant solutions that are examples of how experienced system administrators tend to solve these problems.</p> <p>The first is a tool called <tt>rdist</tt><b>. </b>It is a tool for maintaining identical copies of software between remote hosts. It can accept filenames from the command line or use a configuration file (usually referred to as a <i>distfile) </i>that lists what files to copy to which hosts.</p> <p>In order to distribute a set of automounter maps we might use a <i>distfile</i> like this simple example:</p> <pre><span style="color:#0066ff;">HOSTS = (bilbo frodo thorin snowball)<br />FILES = /etc/auto_master /etc/auto_home /etc/auto_apps<br />${FILES}->${HOSTS}<br /> install;<br /></span></pre> <p>The distfile<i> </i>is a very powerful mechanism. In this example, we take advantage of the ability to create variables<i>.</i> By specifying the hosts to be updated and the files to send in lists, we can easily add to them. After we define $FILES and $HOSTS, we indicate that the lists of files should be kept up to date on the hosts that are listed<b>.</b> <tt>install</tt><i> </i>(the one line command after the dependency line) is one of many <tt>rdist</tt> commands, it indicates the <tt>rdist</tt> should keep the files up to date with the local copies. See the man page for more information on the numerous directives and <tt>distfile</tt> options.</p> <p>To use this we could add the <tt>distfile</tt> to the <tt>/etc</tt> directory on the host where the master set of automounter maps are created. Whenever we make a change, we would execute:</p> <pre><span style="color:#0066ff;">rdist -f /etc/auto_distfile<br /></span></pre> <p><tt>rdist</tt> can be used for much more complicated tasks, such as synchronizing user directories between redundant file servers or distributing new versions of software packages where <tt>nfs</tt> is not being used.</p> <p>The disadvantage behind <tt>rdist</tt> is that it has the same security requirement as any other<b> </b>remote shell command. The user executing the <tt>rdist</tt> command must be able to attach to the remote host and execute commands without a password. (Refer to the following "Network Security Issues" section.)</p> <p>If the security issues associated with <tt>rdist</tt> are unacceptable, how could we conveniently distribute these maps?</p> <p>Sun Microsystems's<b> </b><i>Network Information Service</i><b> </b>(NIS)<b> </b>(also frequently called "yp" or yellow pages) may be an acceptable alternative. NIS provides common configuration information, such as IP addresses, service port numbers, and automount maps to hosts on a network from a server or set of servers.</p> <p>The NIS server(s) have master copies of the files that are made available. Instead of copying the files to the clients, they are distributed as needed across the network. So the clients retrieve the information from the server instead of reading files.</p> <p>NIS is used for <tt>hosts</tt><b>, </b><tt>services</tt><b>, </b><tt>passwd</tt><b>, </b><tt>automount</tt><b> </b>and a few other configuration files. Configuring a network for NIS is beyond the scope of this chapter, and is not the same for each UNIX variant, since many vendors made their own "improvements" on Sun's system. Thoroughly consult the documentation for the platform(s) that you are using before you try to implement it, and make sure you understand any changes that the vendor's have made. NIS does have some advantages and drawbacks that we can cover.</p> <p>The main advantage to NIS is convenience. Changes can be made to a map and made available to clients almost instantly, usually by executing a single command after the file is edited. Being able to keep all of this information in one place (or a few places if secondary servers are used) is obviously convenient, especially since synchronizing user IDs, IP addresses, and service ports is crucial to keeping a network working well.</p> <p>There are however, some significant disadvantages.</p> <p>A workstation that uses NIS to resolve IP addresses cannot use DNS for internet addresses without some important modifications. Sun's NIS+ solves this problem, but is not yet widely supported by other versions of UNIX and is considered to be a proprietary and very hard to use system. (Which is why it is not covered here.)</p> <p>If the <tt>passwd</tt> file is distributed by NIS, the encrypted password field can be read by anyone who connects to NIS. This can be used to subvert security by many hackers, because cracking the encrypted password field is susceptible to a brute force attack with publicly available software.</p> <p>NIS has no mechanism for controlling who connects to the server and reads the maps. This adds to the security issues, and is one of the reasons you won't find any NIS servers on the Internet. (NIS+ also addresses this issue with a complex authentication system.)</p> <p>If a client cannot contact a server to handle a request, the request tends to wait until a server is found instead of trying to find a way to continue.</p> <p>Obviously, NIS comes with its own set of issues, and is a system that requires considerable examination before being selected as an administration tool. </p><h3><span style="color:#000077;"><b>Network Security Issues</b></span></h3> <p>We've already mentioned a few security issues regarding UNIX and networking. These issues are very serious for administrators, and frequently have a huge impact on how a network is configured.</p> <p>Earlier we mentioned that telnet is still used extensively in favor of remote shells. Remote shells allow noninteractive logins, such as the examples above using <tt>tar</tt>,<b> </b><tt>dd</tt><b>, </b>and <tt>rdist</tt><b>. </b>While this is a very convenient feature, it's also a very dangerous one when not carefully administered.</p> <p>The automatic login feature is implemented with a pair of text files. One of them, <tt>/etc/hosts.equiv</tt>,<b> </b>controls users on the system level. The other, <tt>.rhosts</tt>,<b> </b>controls access for individual users. Each file lists the systems by name that a user can login from without supplying a password<b> </b>if the user ID exists on the target host<b>. </b>All of the major UNIX variants treat these files the same way.</p> <p><tt>hosts.equiv</tt> provides this access for an entire workstation, except for the root account. Obviously this file should be very carefully used, if at all. The <tt>.rhosts</tt><b> </b>file provides access for individual users, and is located in the user's home directory. It is consulted instead of <tt>hosts.equiv</tt>. If the <tt>root</tt> account has one of these files, then the <tt>root</tt><b> </b>account from the listed hosts may enter the workstation without any authentication at all<b>, </b>since the <tt>.rhosts</tt> effectively supercedes the <tt>hosts.equiv</tt> file.</p> <p>So the convenience of the remote logins and commands<b> </b>comes with a high price. If a set of workstations were configured to allow <tt>root</tt><b> </b>to travel back and forth without authentication than a malicious or, maybe even worse, ill-informed user only needs to compromise one of them in order to wreak havoc on them all.</p> <p>Some possible precautions are: </p><ul><li>Use root as little as possible. Root should never be used for remote operations<b> </b>is a simple enough general rule. <p> </p></li><li>Avoid using <tt>rlogin</tt> where <tt>telnet</tt> will do. <p> </p></li><li>If you must use <tt>rlogin</tt>, try to get by without using <tt>.rhosts</tt> or <tt>hosts.equiv</tt>. <p> </p></li><li>If you need to use noninteractive logins for operations such as backups or information collection, create a special account for it that only has access to the files and devices necessary for the job. <p> </p></li><li>Remote logins are just about out of the question on any systems that are directly connected to the Internet. (Please note that a home system that is dialing into the Internet through an ISP is not truly directly connected.) </li></ul> <p>A little bit of explanation regarding the first rule is in order. The <tt>root</tt> account should be used as little as possible in day-to-day operations. Many UNIX neophytes feel that <tt>root</tt> access is necessary to accomplish anything worthwhile, when that's not true at all. There is no reason for common operations, such as performing backups, scanning logs, or running network services to be done as <tt>root</tt>. (Other than the services that use ports numbered less than 1024. For historical reasons UNIX only allows processes run as <tt>root</tt> to monitor these ports.) The more situations where <tt>root</tt> is used, the more likely it is that something unexpected and quite possibly disastrous will occur.</p> <p>Even beyond remote logins, UNIX offers a lot of network services. File sharing, e-mail, X-windows, and information services, such as DNS and NIS, comprise only part of the flexibility and extensibility offered by networking. However many of these services represent risks that are not always necessary and sometimes are unacceptable.</p> <p>The right way to handle these services is to evaluate which ones are needed and enable only them. Many network services are managed by <tt>inetd</tt><b>. </b>This daemon process listens for requests for network services and executes the right program in order to service them.</p> <p>For example<b>, </b>the ftp service is administered by <tt>inetd</tt><b>. </b>When a request for the ftp service (service port number 21) is received, <tt>inetd</tt> consults its configuration information and executes <tt>ftpd</tt><b>.</b> Its input and output streams are connected to the requester.</p> <p>Network services are identified by ports<b>. </b>Common services such as ftp and telnet have <tt>well-known ports</tt>, numbers that all potential clients need to know. i<tt>netd</tt> <i>binds</i><b> </b>and<b> </b><i>listens</i><b> </b>to these ports based on its configuration data, contained in the file <tt>inetd.conf</tt><b>.</b></p> <p>A typical configuration file looks like this:</p> <pre><span style="color:#0066ff;"># Configuration file for inetd(1M). See inetd.conf(4).<br />#<br /># To re-configure the running inetd process, edit this file, then<br /># send the inetd process a SIGHUP.<br />#<br /># Syntax for socket-based Internet services:<br /># <service_name> <socket_type> <proto> <flags> <user> <server_pathname> <args><br />#<br />ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd<br />telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd<br />#<br /># Tnamed serves the obsolete IEN-116 name server protocol.<br />#<br />name dgram udp wait root /usr/sbin/in.tnamed in.tnamed<br />#<br /># Shell, login, exec, comsat and talk are BSD protocols.<br />#<br />shell stream tcp nowait root /usr/sbin/in.rshd in.rshd<br />login stream tcp nowait root /usr/sbin/in.rlogind in.rlogind<br />exec stream tcp nowait root /usr/sbin/in.rexecd in.rexecd<br />comsat dgram udp wait root /usr/sbin/in.comsat in.comsat<br />talk dgram udp wait root /usr/sbin/in.talkd in.talkd<br /></span></pre> <p>As the comment states, information for <tt>inetd</tt> is available on two different manual pages.</p> <p>Each configuration entry states the name of the service port, which is resolved by using the <tt>/etc/services</tt> file (or NIS map), some more information about the connection, the user name that the program should be run as, and, finally, the program to run. The two most important aspects of this file, from a security standpoint, are what user the services are run as and what services are run at all. (Details on network connection types are covered in Chapter 20, Networking.")</p> <p>Each service name corresponds to a number. Ports that are numbered less than 1024, which ftp, telnet, and login all use, can only be attached to as <tt>root</tt>, so <tt>inetd</tt> itself does have to be run as <tt>root</tt>, but it gives us the option of running the individual programs as other users. The reason for this is simple: If a program that is running as <tt>root</tt> is somehow compromised, the attacker will have <tt>root</tt> privileges. For example, if a network service that is running as root has a "back door" facility that allows users to modify files, an attacker could theoretically use the program to read, copy or modify any file on the host under attack.</p> <p>Some of the most serious and effective Internet security attacks exploited undocumented features and bugs in network services that were running as <tt>root</tt>. Therefore the best protection against the next attack is to avoid the service completely, or at least provide attackers with as little power as possible when they do get find a weakness to take advantage of.</p> <p>Most UNIX variants come from the vendor running unneeded and, in some cases, undesirable services, such as <tt>rexecd</tt><b>, </b>which is used for the remote execution of programs, frequently with no authentication. As you see above, this service came from the vendor configured as <tt>root</tt>. Many organizations configure key systems to deny all network services except the one service that they are built to provide, such as Internet Web and ftp servers.</p> <p>Well written network software also takes these issues into consideration. For example the Apache Web Server is usually configured to listen to the <tt>http</tt><b> </b>port, which is number 80 and therefore can only be bound to by <tt>root</tt>. Instead of handling client requests as <tt>root</tt> and posing a significant security risk, Apache accepts network connections as <tt>root</tt>, but only handles actual requests as <tt>nobody</tt>, a user with virtually no rights except to read Web pages. It does this by running multiple copies of itself as <tt>nobody</tt> and utilizing interprocess communication to dispatch user requests to the crippled processes.</p> <p>Sharing files on the network poses another set of security issues. Files should be shared carefully, with close attention to not only who can write to them, but who can read them, because e-mail and other forms of electronic communication have become more and more common and can contain important business information.</p> <p>See Chapters 20, "Networking," and 21, "System Accounting," for more detailed information and instructions on how to properly secure your systems. </p><h2><span style="color:#000077;"><b>UNIX Is Heterogeneous</b></span></h2> <p><b>Linux</b><br /> UNIX is frequently criticized for a lack of consistency between versions, vendors and even applications. UNIX is not the product of any single corporation or group, and this does have a significant impact on its personality. Linux is probably the ultimate expression of UNIX's collective identity. After Linus Torvalds created the Linux kernel and announced it to the Internet, people from all over the world began to contribute to what has become called the Linux Operating System. While there is a core group of a few developers who were key in its development, they do not all work for the same company or even live in the same country. Obviously, Linux reflects a few different views on how computers should work. UNIX does too. </p><h3><span style="color:#000077;"><b>Administration Tools</b></span></h3> <p>UNIX vendors all offer their own GUI administrative tools that are generally useful, provided that you do not have to do something that the vendor did not anticipate. These tools vary widely in how they work and how they are implemented.</p> <p><span style="color:#000077;"><b>AIX</b></span><b><br /> </b>IBM's UNIX operating system, AIX, comes with a sophisticated tool called SMIT. Administrators can use SMIT to configure the system, add and remove users, and upgrade software among other things. SMIT is widely considered to be the best and most mature of the system administration systems, because it can be customized and run in either X-windows or a terminal session. It also allows the user to view the command line equivalent of each task before it is performed. The downside (in at least some system administrator's opinions) is that use of SMIT is just about mandatory for some basic administration tasks.</p> <p><span style="color:#000077;"><b>HP-UX</b></span><br /> Hewlett Packard's HP/UX has a similar tool called SAM, which provides much of the functionality offered by SMIT but is not quite as powerful or sophisticated. Its use is not required to administer the system, however.</p> <p><span style="color:#000077;"><b>Solaris</b></span><br /> Sun's Solaris does not come with a tool comparable to SMIT or SAM. However, Sun's individual tools for upgrading and installing software and administering NIS+ are functional and intuitive. Unfortunately, the tool supplied with Solaris for administering users, printers, and NIS/NIS+ requires X-windows. It is not, however required to administer the system at all.</p> <p><span style="color:#000077;"><b>Linux</b></span><b><br /> </b>Linux distributions vary widely when it comes to administrative tools. RedHat offers a powerful desktop environment for adding software, administering users, configuring printers, and other everyday administrative tasks. Unlike the commercial tools, it's based on scripts, not binary code, and therefore can be examined and customized by administrators. The Slackware distribution comes with management tools for upgrading and adding software also.</p> <p>In addition to the different administrative tools and environments provided by the different UNIX vendors, each vendor has felt obligated to provide its own improvements to UNIX over the years. Fortunately, the threat of Windows NT and its homogeneous look and feel has made the UNIX vendors sensitive to these differences, and the tide has turned toward standardization.</p> <p>UNIX has historically been divided into two major variants, AT&T's UNIX System V and The University of California's BSD UNIX. Most of the major vendors are now moving toward a System V system, but many BSD extensions will always remain.</p> <p>Regardless of what the vendors do (and claim to do) UNIX's heterogeneous nature is a fact of life, and is probably one of its most important strengths, since that nature is what's responsible for giving us some of the Internet's most important tools, such as perl, e-mail, the Web, and Usenet News. It also provides us with a lot of choices and how to administer our systems. Few problems in UNIX have only one answer. </p><h3><span style="color:#000077;"><b>Graphical Interfaces</b></span></h3> <p>Macintosh and Microsoft Windows benefit from a user interface that is designed and implemented by a single vendor. For the most part, a set of applications running on one of these computers shares not only a common look and feel but the same keyboard shortcuts, menus, and mouse movements. X-windows does not have this advantage.</p> <p>X-windows is a collection of applications, not an integral part of the operating system. Because it is structured this way, it differs greatly from the windowing systems on a Macintosh or Microsoft Windows. As a result, the relationship between X applications and the operating system tends to be a bit more loose than on those platforms.</p> <p>One of the things that gives an X desktop its "personality" is the <i>window manager</i><b>.</b> This is the application that provides each window with a border and allows them to be moved and overlapped. However, it is just an application, not part of the X-window system. This separation enables users to select the manager they want, just like a shell. Individual users on the same system can also use different window managers. The differences between window managers are significant, having a significant impact on the look of the desktop, the way the mouse acts, and sometimes, what applications can be run.</p> <p>The OpenLook<b> </b>window manager, which is distributed by Sun and also accompanies many Linux distributions, has many proprietary extensions and is very lightweight and fast. It bears little resemblance, however, to Macintosh or Microsoft Windows in look or feel. (For one thing, it makes heavy use of the right mouse button, which Microsoft Windows only recently started to do and does not even exist on a Macintosh.) The Sun OpenWindows package comes with OpenLook and a set of tools for reading mail, managing files, and a few other common tasks.</p> <p>Motif<b>, </b>which has many similarities with Microsoft Windows,<b> </b>has become more popular in the past few years, with most of the major vendors having agreed to standardize on the <i>Common Desktop Environment (CDE)</i><b>, </b>which is based largely on Motif. The CDE also has additional features, such as a graphical file manager, a toolbar, and support for virtual screens. The CDE also comes with a set of user applications.</p> <p>Window managers also come with programming libraries for creating menus and other programming tasks. As a result, it is possible to create an application that runs poorly under some window managers or requires libraries that a UNIX version does not have. This is a common problem for Motif applications on Linux, because the libraries are not free. For this reason, many applications are available in a non-Motif version or with the libraries <i>statically linked,</i> which means they are built into the application. (This is generally considered undesirable because it makes the application larger and requires more memory and more disk space.)</p> <p>Windows 3.<i>x</i> has the <tt>win.ini</tt><b> </b>and <tt>.ini</tt> file scheme; Windows 95 and Windows NT have the system registry. Both serve as central repositories for application configuration information. X-windows has its own standard interface for configuration information, called <i>X resources</i><b>. </b>X resources are more flexible in many ways than the Windows mechanisms.</p> <p>X resources support wildcards with parameters, which allows administrators (and users) to standardize behavior between diverse applications. Most X-windows application developers recognize this ability and tend to use standard naming schemes for configuration parameters, which makes the use of wildcards even more convenient.</p> <p>Users are able to customize application to reflect their personal preferences without affecting others by maintaining personal resource files, unlike single user systems that maintain one set of parameters for an entire system. However, administrators still have the ability to set default parameters, so users that do not wish to customize an application still have minimal functionality. </p><h3><span style="color:#000077;"><b>Command Line Interfaces</b></span></h3> <p>The command line is where UNIX's long history and diversity really show. One would think that every utility was written by a different person for a different purpose, and one might be right.</p> <p>There is little cohesion between command line tools as far as the interface goes. The directory list command <tt>ls</tt> covers just about the whole alphabet when it comes to command line options. The <tt>find</tt><b> </b>command, however, uses abbreviations for options instead of letters and almost looks like a new language. Most commands require a <b>"-" </b>to delineate different arguments; others do not. Several commands use subtly different dialects of regular expressions<b> </b>(wildcards).</p> <p>There are also frequently two versions of the same command: one from the System V world and one from the BSD world. My favorite example of this is the <tt>mail</tt><b> </b>command<b>. </b>The <tt>mail</tt> command is a simple, text-based, virtually feature-free mail reading and sending tool. There are two versions of this command though, so there must have been something worth disagreeing about when it came time to create the most basic of mail readers.</p> <p>Both <tt>mail</tt> commands can be used to send e-mail from the command line and are invaluable for unattended scripting jobs since they can alert administrators of problems via e-mail. The BSD version allows you to specify a subject on the command line, like this:</p> <pre><span style="color:#0066ff;">mail -s "Backup Results" {hyperlink mailto:eric@niftydomain.com } < backup.txt<br /></span></pre> <p>where the <tt>-s</tt><b> </b>is an option for the mail subject. The System V version of <tt>mail</tt><b> </b>(which is the default for Solaris) quietly ignores the <b>-</b><tt>s</tt> option. This has led to my actually troubleshooting why my mail had no subject on at least three different occasions.</p> <p>Another endearing difference between the two major variants is the <tt>ps</tt><b> </b>command. Both commands provide the same information about running programs. The command line arguments are completely different.</p> <p>The best way to avoid problems with these pointless and gratuitous differences is to take full advantage of the wealth of information contained in the man pages. (In the "Administration Resources" portion of this chapter we cover a few ways to get more information from them.) And keep these tips in mind: </p><ul><li>UNIX has been around for more than 25 years. What are the chances that you have a problem that hasn't been solved by someone yet? Before you spend a lot of time and effort solving a problem, spend some time reading man pages about the problem and the tools you are using. <p> </p></li><li>Many of the tools on a UNIX system have been around for those 25+ years. Software that lasts that long must have something going for it. <p> </p></li><li>Experiment with the tools and try to solve the same problem using different methods every once in awhile. Sometimes you can pick up new tricks that will save you hours of time in the future. </li></ul> <h2><span style="color:#000077;"><b>System Administration Tasks</b></span></h2> <p>System administration can generally be divided into two broad categories: supporting users and supporting systems. </p><h3><span style="color:#000077;"><b>Supporting Users</b></span></h3> <p>Users are your customers. Without them the network would be a single computer, probably running a frivolous application like Doom and generating no business or creating no new sales. (Sounds awful doesn't it?) We support users by creating their logins and providing them with the information they need to use their computers to get something done, without forcing them to become computer experts or addicts. (Like us.)</p> <p><b>Creating User Accounts</b> The most fundamental thing that an administrator can do for a user is create her account. UNIX accounts are contained in the <tt>/etc/passwd</tt> file with the actual encrypted password being contained in either the <tt>passwd</tt> file or the <tt>/etc/shadow</tt> file if the system implements shadow passwords.</p> <p>When a user is created, the account obviously has to be added to the <tt>passwd</tt> file. (The specifics behind user accounts are covered in Chapter 17, "User Administration.") This is a very easy task that can be performed in less than a minute with any text editor. However, if the UNIX version you are using has a tool for adding users, it may not be a bad idea to just take advantage of it.</p> <p>These tools will frequently: </p><ul><li>Add the user to the <tt>passwd</tt> file. (and shadow file if it is used) Since all users require a unique user ID, letting the computer assign the number when you are administering a large number of users can be very convenient. <p> </p></li><li>Create a home directory for the user with the proper file permissions and ownership. <p> </p></li><li>Copy generic <i>skeleton files</i> to the account, which give the user a basic environment to work with. These files can be created by the administrator, so the paths to shared applications and necessary environment variables can be distributed to users as they are created. <p> </p></li><li>Register the new account with network systems, such as NIS and NFS, if the home directory needs to be accessed on other hosts. </li></ul> <p>So these tools can prevent common errors and save a bit of time. Most UNIX variants also provide a command line tool named <tt>useradd</tt> that will perform all or most of these steps. If using the GUI tool is uncomfortable or unworkable, <tt>useradd</tt> can be incorporated into a shell or perl script.</p> <p><b>Providing Support</b> Providing users with documentation and support is another key system administration task and potential headache. The best system administrator is both invisible and never missed. She also realizes that expecting users to get as excited about learning how to use a computer as she is is asking too much.</p> <p>A famous proverb talks about teaching a man to fish instead of buying him a McFish sandwich. (Or something like that.) The idea behind this expression can be applied to users with amazing results. However, few users will go out of their way to learn how to use their systems. How can an administrator teach his users how to help themselves without fighting a never ending battle?</p> <p>All user populations are different, and there is no universal solution to user training, but here are a couple of ideas that may help.</p> <p>Try to provide and gently enforce a formal method for requesting changes to systems and getting help. If users get accustomed to instant answers to questions, they will become angry when you can't drop what you're doing to help them. Try to set up an e-mail or Web-based help system. It may seem bureaucratic to force users to use these systems, but it helps prevent your day from becoming "interrupt-driven" and also provides you with a log of requests. (Have you ever forgotten to take care of a request because you were too overloaded? Give yourself an automatic to do list.)</p> <p>Provide as much documentation as you can through easy-to-use interfaces, such as Web browsers. The time you spend developing this information in user friendly formats will be paid back in phone calls and conversations that never happen, and may help you learn some more about your systems as you do it.</p> <p>If you have Internet access now, I'm sure your users spend hours glued to their browsers; take advantage of that. You may also find that a lot of the information your users need is already out there, so you may be able to link your users to some of the information they need, without generating it yourself. (We'll go over some of these resources later in the "Administration Resources" portion of this chapter.) </p><h3><span style="color:#000077;"><b>Supporting Systems</b></span></h3> <p>The other half of the job is supporting your systems. Systems have to be built, backed up, upgraded, and, of course, fixed.</p> <p><b>Adding Nodes</b> A frequent system administration task is adding new nodes to the network. It's also one of the parts of the job that can truly benefit from some planning and insight.</p> <p>Not all systems are created equal, and not all of them are used for the same thing. Spending some time understanding what your network is really used for and then applying that to systems is key in network planning. Workstations should have well defined roles and should be configured in accordance with those roles.</p> <p>When systems are designed and evaluated, some of the questions an administrator can ask are: </p><ul><li>Will users be able to access all or some of the systems? Do users need to access more than one system? Are there system that users should never access? <p> </p></li><li>What network file systems will each workstation need to access? Are there enough that <tt>automount</tt> would help? <p> </p></li><li>What network services, such as telnet, remote logins, sharing file systems, and e-mail, do workstations need to provide? Can each service be justified? <p> </p></li><li>What networks will workstations need to access? Are there networks that should be inaccessible from others? </li></ul> <p>These questions should help us develop a profile for each workstation. Following a profile makes workstations easier to build, maintain, and troubleshoot, not to mention making them more reliable since they tend to be less complex.</p> <p><b>Backups</b> Files get corrupted, lost, accidentally overwritten, or deleted. Our only protection against these situations is backups, since UNIX does not have an <tt>undelete</tt> command.</p> <p>UNIX provides several backup tools, and deciding which tool(s) to use can be a difficult.</p> <p>Earlier in the chapter we had an example of backing up a directory, using <tt>tar</tt><b> </b>and <tt>dd</tt><b>, </b>to a remote tape drive. In that example, <tt>dd</tt><b> </b>was just be used as a way to copy a stream of data to a tape, while <tt>tar</tt> was the command actually performing the backup.</p> <p><tt>tar</tt><b> </b>(<b>t</b>ape <b>ar</b>chive) is a commonly used backup tool.</p> <pre><span style="color:#0066ff;">tar -c -f /dev/rmt/0 /home/eric<br /></span></pre> <p>The above command would back up the contents of the <tt>/home/eric</tt> directory to the first tape drive installed on a Solaris system. <tt>tar</tt> automatically traverses the directory, so all files in <tt>/home/eric</tt> and its subdirectories are archived.</p> <p>The device name for tape drives on systems differs from variant to variant. BSD derivatives tend to refer to them as <tt>/dev/rst1</tt><b> </b>where 0 is the first, 1 is the second, and so on. (Linux, HP/UX, and SunOS 4.1.<i>x</i> use this nomenclature.) System V derivatives usually use <tt>/dev/rmt1</tt><b> </b>the same way. (AIX uses this model.) However, Solaris 2.<i>x</i>, which is System V based, adds a directory to the path, so it is <tt>/dev/rmt/1</tt>.</p> <p>The <tt>-f</tt> option tells <tt>tar</tt> which tape drive to use, while the <tt>-c</tt> option is telling it to create a new archive instead of modifying an existing one. One of tar's idiosyncrasies is that when a path is given to it as the back up specification, it is added to the archive, so when it time to restore <tt>/home/eric</tt>, that is where it will be restored to. A more flexible way to back up the directory is to do this:</p> <pre><span style="color:#0066ff;">cd /home/eric<br />tar -cf /dev/rmt/0 .<br /></span></pre> <p>Tar recognizes <tt>.</tt> as meaning backup the current directory. When the archive is extracted, it will be placed in the current directory, regardless of where that is.</p> <p><tt>cpio</tt> is another standard UNIX tool for backups. Its interface is a little more difficult than tar's, but has several advantages.</p> <p><tt>cpio</tt> is usually used with <tt>ls</tt> or <tt>find</tt> to create archives.</p> <pre><span style="color:#0066ff;">find . -print | cpio -o > /dev/rst0<br /></span></pre> <p>The <tt>find</tt> command prints the full path of all of the files in its current directory to standard out. <tt>cpio</tt> accepts these filenames and archives them to standard output. This is redirected to the tape, where it is archived. This command is an excellent example of the UNIX way of combining commands to create a new tool.</p> <p><tt>find</tt> is a tool for finding files. They can be located by name, size, creation date, modification date, and a whole universe of other criteria too extensive to cover here. (As always, see the man page!) This example takes this tool for locating files and makes it the user interface to our backup system.</p> <p><tt>cpio</tt> is the file copying and archiving "Swiss Army Knife." In addition to streaming files in a format suitable for tape it can: </p><ul><li>Backup special files, such as device drive <i>stubs</i> like <tt>/dev/rst0</tt>. <p> </p></li><li>Place data on tapes more efficiently than <tt>tar</tt> or <tt>dd</tt>. <p> </p></li><li>Skip over bad areas on tapes or floppies when restoring, when <tt>tar</tt> would simply die. With <tt>cpio</tt>, you can at least restore part of a damaged archive. <p> </p></li><li>Perform backups to floppies, including spread a single archive over more than one disk. <tt>tar</tt> can only put a single archive on one disk. <p> </p></li><li>Swap bytes during the archive or extraction in order to aid in transferring files from one architecture to another. </li></ul> <p>This example also illustrates how we can redirect standard output to a device name and expect the device driver to place it on the device.</p> <p>Our example could also be stretched into a full-featured backup system. Since <tt>find</tt> allows us to pick files based on creation and modification dates, we could perform a full backup to tape once a week by telling find to name all files, and perform incremental backups to floppy every other day. The UNIX command line is a very powerful tool, especially since programs have been designed for it steadily during the past three decades.</p> <p><span style="color:#000077;"><b>Solaris</b></span><br /> There are other backup tools, most notably <tt>dump </tt>or <tt>ufsdump</tt> as it is named on Solaris 2.x. These tools are oriented toward backing up entire disk partitions, instead of files. They are covered in Chapter 28, "Backing Up and Restoring Your System."</p> <p>Larger sites with more comprehensive backup requirements may need a commercial package. Legato's <i>NetWorker</i> provides an advanced backup and restore system that support the automated and unattended backup of UNIX systems, Windows and NT workstations, Macintosh PCs and even database servers. The process of scheduling backups, selecting file for backup and confirming the integrity of archives is all done automatically. Restoring files and file systems is also very simple due to the GUI.</p> <p><span style="color:#000077;"><b>Solaris</b></span><b><br /> </b>Sun bundles NetWorker with the Solaris 2.x server edition.</p> <p>Just as important as picking a backup tool is designing a backup strategy.</p> <p>Backing up the entire system daily is not acceptable, since it would take too long and would be too ponderous to restore if only one file is needed.</p> <p>Here is another area where it pays to know your users and understand their business. It's also important to design the network with backup and recovery in mind. </p><ul><li>Do the users have important files that they modify daily? <p> </p></li><li>Are the users clustered into one of two directories on one system, or will systems have to be backed up across the network? <p> </p></li><li>If only a single file has to be restored, will it have to be done quickly? Will our current backup system allow us to find one file. <p> </p></li><li>How often and for how long are users not using the system? (It is better to back up directories when they are not in use.) </li></ul> <p>Depending on the requirements, a commercial backup tool may be a good investment. The commercial tools, such as NetWorker, do excel in allowing you to locate and restore one specific file quickly, which may be necessary in your situation.</p> <p><b>System Load and Performance</b> The task of monitoring system load and system performance falls on the shoulders of the system administrator. This is yet another area where planning and anticipation are superior to waiting for something to happen and reacting to it.</p> <p>Daily monitoring of usage statistics is a good idea, especially on mission-critical systems and systems that users interact with regularly, such as Web servers and X displays. These statistics can be gathered with automated scripts.</p> <p>Some of the things to monitor are disk usage, CPU utilization, swap, and memory. The tools used for getting this information, such as <tt>du</tt><b> </b>and <tt>df</tt><b> </b>for disk information and <tt>top</tt> and <tt>vmstat</tt> for the rest, are covered in the next few chapters in Part III. </p><h2><span style="color:#000077;"><b>Administration Resources</b></span></h2> <p>A system administrator needs every shred of information and help he can get, and as much as UNIX vendors would hate to admit, the documentation that accompanies is sometimes lacking. Fortunately, it's a big world out there. </p><h3><span style="color:#000077;"><b>The Manual Pages</b></span></h3> <p>The famous rejoinder RTFM<b> </b>(Read The Fine Manual) refers to the manual pages installed on (hopefully) every UNIX system. The man pages, as they are frequently called, contain documentation and instructions on just about every UNIX command, C function call and data file on your system.</p> <p>The man command searches for documentation based on a command or topic name. So the command</p> <pre><span style="color:#0066ff;">man ls<br /></span></pre> <p>provides us with documentation on the <tt>ls</tt> command, which happens to be in section one.</p> <p>As simple as they may appear, the man pages actually have a sophisticated structure. The pages are divided into sections, with some of the sections being further divided into subsections.</p> <p>The section layout resembles this: </p><ul><li>User commands--commands like <tt>ls</tt>, <tt>tar</tt>, and <tt>cpio</tt>. <p> </p></li><li>System calls--C programming functions that are considered system calls, like opening and closing files. <p> </p></li><li>C library functions--C programming functions that are not considered system calls, like printing text. <p> </p></li><li>File formats--descriptions of file layouts, such as <tt>hosts.equiv</tt> and <tt>inetd.conf</tt>. <p> </p></li><li>Headers, Tables and Macros--miscellaneous documentation, such as character sets and header files, not already covered. <p> </p></li><li>Games and Demos--games and demo software. (Even Doom for UNIX has a man page!) </li></ul> <p>This is a generalized table of contents. BSD and System V started out with slightly different section schemes, and vendors tend to add their own sections and make their own "improvements." (How could it be any other way?)</p> <p>In order to view information about each section, we can view the intro page for it. In order to see information about section one, we would execute the following command.</p> <pre><span style="color:#0066ff;">man -s 1 intro<br /></span></pre> <p>The <tt>-s</tt> option selects which section of the man pages to search with the System V version of the <tt>man</tt><b> </b>command.<b> </b>BSD versions accept the section number as the first argument with no switch, while the Linux version will select the section from an environment variable or from a <tt>-s</tt><b> </b>option.</p> <p>All of the versions accept the <tt>-a</tt> option, which will force the <tt>man</tt> command to search all of the sections and display all pages that match. Since there are different pages with the same name, understanding the different sections and what belongs in each of them is helpful. However, there are additional tools, and it is not necessary to memorize the section layout for each system.</p> <p>Man pages can be indexed and pre-formatted with a tool called <tt>catman</tt><b>.</b> The pre-formatting part make the pages display faster and is less important than the indexing, which allows us to use more powerful information retrieval tools, namely <tt>whatis</tt><b> </b>and<b> </b><tt>apropos</tt>.</p> <p><tt>apropos</tt> displays the section number, name and short description of any page that contains the specified keyword. <tt>whatis</tt> gives us the man page name and section number.</p> <p>For example, let's try the <tt>apropos</tt> command for the keyword <tt>nfs</tt>:</p> <pre><span style="color:#0066ff;">apropos nfs<br /></span></pre> <p>A portion of the response would be this:</p> <p> <table border="1"> <tbody><tr rowspan="1" align="left"> <td valign="top" align="left">automount (8)</td> <td valign="top" align="left">Automatically mount NFS file systems</td> </tr> <tr rowspan="1" align="left"> <td valign="top" align="left">exportfs (8)</td> <td valign="top" align="left">Export and unexport directories to NFS clients</td> </tr> <tr rowspan="1" align="left"> <td valign="top" align="left">exports, xtab (5)</td> <td valign="top" align="left">Directories to export to NFS clients</td> </tr> <tr rowspan="1" align="left"> <td valign="top" align="left">nfs, NFS (4P)</td> <td valign="top" align="left">Network file system</td> </tr> <tr rowspan="1" align="left"> <td valign="top" align="left">nfsd, biod (8)</td> <td valign="top" align="left">NFS daemons</td> </tr> </tbody></table> (The output was edited, because the actual request returned 12 responses.)</p> <p>Now let's try <tt>whatis</tt>:</p> <pre><span style="color:#0066ff;">whatis nfs<br /></span></pre> <p>nfs, NFS (4P) Network file system</p> <p>With <tt>whatis</tt> we only see the name of the actual <tt>nfs</tt> manual page and its section number.</p> <p><span style="color:#000077;"><b>Solaris</b></span><b><br /> </b>In addition to the manual pages, Sun supplies <i>Answerbook</i> with Solaris. It's a GUI based online help system that supports full text search and just about completely removes the need for hard copy documentation.</p> <p><span style="color:#000077;"><b>AIX<br /> </b></span>IBM supplies <i>Infoviewer</i> which is also a GUI-based online help system. As a matter of fact, the default AIX installation program installs Infoviewer instead of the manual pages, which can be quite an inconvenience for users that do not use X-windows. </p><h3><span style="color:#000077;"><b>Internet Information resources</b></span></h3> <p>The internet provides administrators with a wealth of resources too. </p><dl><dd><b>1. Usenet News</b>--While not as useful as it was in the past (due to overcrowding and a plummeting signal to noise ratio) usenet news offers discussion groups about all of the UNIX variants and covers various aspects of them. Some examples are <tt>comp.sys.sun.admin</tt>,<b> </b><tt>comp.os.linux.setup</tt><b> </b>and <tt>comp.unix.admin</tt>.<b> </b>Because of the high traffic on usenet news, some sites do not carry it. If you cannot get access, try using a search service such as <tt>http://www.dejanews.com</tt> to find what you need. Sometimes searching for articles that interest you instead of browsing is a faster way to get what you need anyway. Dejanews offers searching and browsing. <p><b>2. FAQ Lists</b>--Frequently Asked Question Lists hold a wealth of information. Most of the computer-related usenet groups have their own FAQ lists. They can be found posted periodically in the groups and at the <tt>rtfm.mit.edu</tt><b> </b>ftp server. Many of the FAQS are also available in html format.</p> <p><b>3. The Web</b>--Documentation is available from the UNIX vendors and from people and groups involved with Linux. Many users and developers also post a wealth of information just to be helpful. Use the search services to get your research going. UNIX was one of the first operating systems to colonize the Internet, and, as a result, there is a huge number of UNIX users on it. </p></dd></dl> <p>There is a large amount of documentation and help available free on the Internet, and there is a lot more to be learned from seeking out an answer than simply paying a consultant to tell you or leaning on someone else to do what has to be done for you. </p><h2><span style="color:#000077;"><b>Tools of the Trade</b></span></h2> <p>A successful administrator takes full advantage of the tools provided with a UNIX system. To the uninitiated, UNIX seems difficult and unwieldy, but once you get the idea you'll never want to use another system. </p><h3><span style="color:#000077;"><b>The Shell</b></span></h3> <p>Earlier, we demonstrated how <tt>cpio</tt> uses the output of the <tt>find</tt> command to learn what files to archive. This was a demonstration of shell pipes, which redirect the output of one command to another. We also used this to back up files to a tape drive that is located on another host.</p> <p>We demonstrated mailing a file to a user on the command line using redirection, which opens a file and passes it to a command as if it was provided in the command line or typed in as a program requested it.</p> <p>UNIX shells also support sophisticated programming constructs, such as loops, and provide comparison operators, such as equality, greater than, and less than.</p> <p>Shell programming is essential to system administration, especially as networks grow larger and, as a result, more time consuming to maintain. File backups, adding users and nodes, collecting usage statistics, and a whole host of other administrative tasks are candidates for unattended scripts. </p><h3><span style="color:#000077;"><b>Perl and Other Automation Tools</b></span></h3> <p>Perl has become more and more popular over the past few years, and not without good reason. Many tasks that would have required the use of C in the past can now be done by a novice programmer in Perl. System administrators can benefit greatly from a little working knowledge of this language, since it can be used for tasks such as: </p><ul><li>Analyzing log files and alerting the administrator of trouble via e-mail or pager <p> </p></li><li>Automatically converting systems statistics into Web pages. <p> </p></li><li>Automating the process of creating user accounts, adding and distributing automounter maps, backing up systems, and creating html content. <p> </p></li><li>Creating and communicating over network connections. </li></ul> <p>These are only a few examples of what this language can do. Chapter 5, "Perl," in Volume 2 has in-depth coverage of Perl.</p> <p>Some other tools worth noting are TCL/TK, which most of the RedHat administrative tools are written in and awk, which is covered extensively in Chapter 4, "Awk," of Volume 2. </p><h3><span style="color:#000077;"><b>Intranet Tools</b></span></h3> <p>As mentioned earlier, consider using intranet tools like Web servers and e-mail to communicate with your users.</p> <p>There are many Web discussion and guest book applications, all written in perl, that could be modified and used to allow customers to enter requests for support. An internal home page could be used to announce scheduled outages and system enhancements. The Web also allows you to link clients to vendor-provided support resources and documentation. </p><h2><span style="color:#000077;"><b>Summary</b></span></h2> <p>What is system administration? This chapter kind of meandered along and tried to give you an idea of what administrators do and what they need to know.</p> <p>A literal attempt at answering the question may say that administrators are responsible for: </p><ul><li>Understanding how the systems they are responsible interact over the office or organizational LAN/WAN. <p> </p></li><li>Supporting users by creating their accounts, protecting their data and making their sometimes bewildering systems easier to use. <p> </p></li><li>Supporting systems by keeping the secure, up to date and well tuned. <p> </p></li><li>Planning the efforts behind support and growth. <p> </p></li><li>Anticipating and resolving problems. </li></ul> <p>But it may be better to generalize and say that system administration is the process and effort behind supporting a system or systems so that a company or group can attain its goals.</p> <p>The rest of this section delves much more deeply into the details of system support. Chapters 15 and 16 describe how to install a UNIX system and start it up and shut it down.</p> <p>In Chapter 17 we cover supporting users much more in-depth than was covered here. Chapter 18 covers file systems and disk configuration , while 19 provides coverage on kernel configuration.</p> <p>Chapter 20 is where the complete coverage on UNIX networking is located. In Chapter 21 we cover system accounting, which is key for administrators who are concerned with supported large groups of users or that need to come up with a comprehensive system for charging users for access.</p> <p>For information on system performance and how to improve it, see Chapter 22. In addition, Chapter 23 provides information on how to add and maintain new system components, such as tape drives and modems.</p> <p>Managing mail, Usenet news and other network services is covered in Chapters 23 through 27. Our last chapter in this section, 28, covers system backup and restore.</p>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-36944322011485818182008-08-28T23:57:00.001-07:002008-12-23T00:12:05.690-08:00What Is a Shell?<h1 align="center"><span style="color:#000077;"><br /></span></h1> <p><i>By William A. Farra</i></p> <p>Nearly every human-usable invention has an interface point with which you interact. Whether you are in the front seat of a horse and buggy, in the cockpit of a plane, or at the keyboard of a piano, this position is where you manipulate and manage the various aspects of the invention to achieve a desired outcome. The human interface point for UNIX is the <i>shell,</i> which is a program layer that provides you with an environment in which to enter commands and parameters to produce a given result. As with any invention, the more knowledge and experience you have with it, the greater the accomplishment you make with it.</p> <p>To meet varying needs, UNIX has provided different shells. Discussed in Chapters 9 through 13 are Bourne, Bourne Again, Korn, and C shells. Each of these offers features and ways to interact with UNIX. Topics discussed in this chapter are the following: </p><ul><li>How shells works with you and UNIX </li><li>The features of a shell </li><li>Manipulating the shell environment </li></ul> <h2><span style="color:#000077;"><b>How the Kernel and the Shell Interact</b></span></h2> <p>When a UNIX system is brought online, the program <tt>unix</tt> (the Kernel) is loaded into the computer's main memory, where it remains until the computer is shut down. During the bootup process, the program <tt>init</tt> runs as a background task and remains running until shutdown. This program scans the file <tt>/etc/inittab</tt>, which lists what ports have terminals and their characteristics. When an active, open terminal is found, <tt>init</tt> calls the program <tt>getty</tt>, which issues a <tt>login:</tt> prompt to the terminal's monitor. With these processes in place and running, the user is ready to start interacting with the system. </p><h3><span style="color:#000077;"><b>UNIX Calls the Shell at Login</b></span></h3> <p>Figure 8.1 shows the process flow from the kernel through the login process. At this point the user is in an active shell, ready to give command to the system.</p> <p><a href="file:///E:/Thangs/Study/Unix/unix%5B1%5D.zip/art/08/08uni01.jpg"><b>Figure 8.1.</b></a><br /> <i>How a shell is started from login.</i></p> <p>During login, when you type your user name, <tt>getty</tt> issues a <tt>password:</tt> prompt to the monitor. After you type your password, <tt>getty</tt> calls <tt>login</tt>, which scans for a matching entry in the file <tt>/etc/passwd</tt>. If a match is made, <tt>login</tt> proceeds to take you to your home directory and then passes control to a session startup program; both the user name and password are specified by the entry in <tt>/etc/passwd</tt>. Although this might be a specific application program, such as a menu program, normally the session startup program is a shell program such as <tt>/bin/sh</tt>, the Bourne shell.</p> <p>From here, the shell program reads the files <tt>/etc/profile</tt> and <tt>.profile</tt>, which set up the system-wide and user-specific environment criteria. At this point, the shell issues a command prompt such as <tt>$</tt>.</p> <p>When the shell is terminated, the kernel returns control to the init program, which restarts the login process. Termination can happen in one of two ways: with the <tt>exit</tt> command or when the kernel issues a kill command to the shell process. At termination, the kernel recovers all resources used by the user and the shell program. </p><h3><span style="color:#000077;"><b>The Shell and Child Processes</b></span></h3> <p>In the Unix system, there are many layers of programs starting from the kernel through a given application program or command. The relationship of these layers is represented in Figure 8.2.</p> <p><a href="file:///E:/Thangs/Study/Unix/unix%5B1%5D.zip/art/08/08uni02.jpg"><b>Figure 8.2.</b></a> <i><br /> UNIX system layers.</i></p> <p>After you finish logging on, the shell program layer is in direct contact with the kernel, as shown in Figure 8.2. As you type a command such as <tt>$ ls</tt>, the shell locates the actual program file, <tt>/bin/ls</tt>, and passes it to the kernel to execute. The kernel creates a new child process area, loads the program, and executes the instructions in <tt>/bin/ls</tt>. After program completion, the kernel recovers the process area and returns control to the parent shell program. To see an example of this, type the following command:</p> <pre><span style="color:#0066ff;">$ps<br /></span></pre> <p>This lists the processes you are currently running. You will see the shell program and the <tt>ps</tt> program. Now type the following:</p> <pre><span style="color:#0066ff;">$sleep 10 &<br />$ps<br /></span></pre> <p>The first command creates a <tt>sleep</tt> child process to run in background, which you see listed with the <tt>ps</tt> command. Whenever you enter a command, a child process is created and independently executes from the parent process or shell. This leaves the parent intact to continue other work. </p><h3><span style="color:#000077;"><b>Auto-Execution of the Shell</b></span></h3> <p>Some UNIX resources, such as <tt>cron</tt>, can execute a shell program without human interaction. When using this feature, the user needs to specify which shell to run in the first line of the shell program, like this:</p> <pre><span style="color:#0066ff;">#! /bin/sh<br /></span></pre> <p>This specifies the Bourne shell.</p> <p>You should also redirect any output, because no terminal is associated with auto-execution. This is described in the "File Handling: Input/Output Redirection and Pipes" section later in this chapter. </p><h2><span style="color:#000077;"><b>The Functions and Features of a Shell</b></span></h2> <p>It doesn't matter which of the standard shells you choose, because they all have the same purpose: to provide a user interface to UNIX. To provide this interface, all the shells offer the same basic characteristics: </p><ul><li>Command-line interpretation </li><li>Reserved words </li><li>Shell meta-characters (wild cards) </li><li>Access to and handling of program commands </li><li>File handling: input/output redirection and pipes </li><li>Maintenance of variables </li><li>Environment control </li><li>Shell programming </li></ul> <h3><span style="color:#000077;"><b>Command-Line Interpretation</b></span></h3> <p>When you log in, starting a special version of a shell called an <i>interactive shell,</i> you see a shell prompt, usually in the form of a dollar sign (<tt>$</tt>), a percent sign (<tt>%</tt>), or a pound sign (<tt>#</tt>). When you type a line of input at a shell prompt, the shell tries to interpret it. Input to a shell prompt is sometimes called a <i>command line.</i> The basic format of a command line is</p> <pre><span style="color:#0066ff;">command arguments<br /></span></pre> <p><i><tt>command</tt></i> is an executable UNIX command, program, utility, or shell program. <i><tt>arguments</tt></i> are passed to the executable. Most UNIX utility programs expect <i><tt>arguments</tt></i> to take the following form:</p> <pre><span style="color:#0066ff;">options filenames<br /></span></pre> <p>For example, in the command line</p> <pre><span style="color:#0066ff;">$ ls -l file1 file2<br /></span></pre> <p>there are three arguments to <tt>ls</tt>; the first is an option, and the last two are filenames.</p> <p>One of the things the shell does for the kernel is to eliminate unnecessary information. For a computer, one type of unnecessary information is whitespace; therefore, it is important to know what the shell does when it sees whitespace. Whitespace consists of space characters, horizontal tabs, and newline characters. Consider this example:</p> <pre><span style="color:#0066ff;">$ echo part A part B part C<br />part A part B part C<br /></span></pre> <p>Here, the shell has interpreted the command line as the <tt>echo</tt> command with six arguments and has removed the whitespace between the arguments. For example, if you were printing headings for a report and wanted to keep the whitespace, you would have to enclose the data in quotation marks, as in</p> <pre><span style="color:#0066ff;">$ echo 'part A part B part C'<br />part A part B part C<br /></span></pre> <p>The single quotation mark prevents the shell from looking inside the quotes. Now the shell interprets this line as the <tt>echo</tt> command with a single argument, which happens to be a string of characters including whitespace. </p><h3><span style="color:#000077;"><b>Reserved Words</b></span></h3> <p>All shell versions have words that have special meaning. In shell programming, words such as <tt>do</tt>, <tt>done</tt>, <tt>for</tt>, and <tt>while</tt> provide loop control--and <tt>if</tt>, <tt>then</tt>, <tt>else</tt>, and <tt>fi</tt> provide conditional control. Each shell version has different reserved word pertaining to its specific features. </p><h3><span style="color:#000077;"><b>Shell Meta-Character (Wild Cards)</b></span></h3> <p>All shell versions have meta-characters, which allow the user to specify filenames. The following are wild cards: <table border="1"> <tbody><tr> <td><i>Wild Card</i></td> <td><i>Description</i></td> </tr> <tr rowspan="1" align="left"> <td align="left"><tt>*</tt></td> <td align="left">Matches any portion</td> </tr> <tr rowspan="1" align="left"> <td align="left"><tt>?</tt></td> <td align="left">Matches any single character</td> </tr> <tr rowspan="1" align="left"> <td align="left"><tt>[]</tt></td> <td align="left">Matches a range or list of characters</td> </tr> </tbody></table> </p> <p>Wild cards can be useful when processing a number of specific files. The following are some examples:</p> <pre><span style="color:#0066ff;">$ls t*<br /></span></pre> <p>This lists all files starting with <tt>t</tt>.</p> <pre><span style="color:#0066ff;">$ls test?5.dat<br /></span></pre> <p>This lists all files starting with <tt>test,</tt> any single character and ends with <tt>5.dat</tt>.</p> <pre><span style="color:#0066ff;">$ls [a-c]*<br /></span></pre> <p>This lists all files starting with <tt>a</tt> through <tt>c</tt>.</p> <pre><span style="color:#0066ff;">$ls [e,m,t]*<br /></span></pre> <p>This lists all files starting with <tt>e</tt>, <tt>m</tt>, or <tt>t</tt>. </p><h3><span style="color:#000077;"><b>Program Commands</b></span></h3> <p>When a command is typed, the shell reads the environment variable <tt>$path</tt>, which contains a list of directories containing program files. The shell looks through this set of directories to find the program file for the command. The shell then passes the true filename to the kernel. </p><h3><span style="color:#000077;"><b>File Handling: Input/Output Redirection and Pipes</b></span></h3> <p>In previous chapters, you learned about standard input and output. Unless otherwise specified with arguments, most UNIX commands take input from the terminal keyboard and send output to the terminal monitor. To redirect output to a file, use the <tt>></tt> symbol. For example,</p> <pre><span style="color:#0066ff;">$ls > myfiles<br /></span></pre> <p>lists the files in your current directory and places them in a file called <tt>myfiles</tt>. Likewise, you can redirect input with the <tt><</tt> symbol. For example,</p> <pre><span style="color:#0066ff;">$wc -l < myfiles<br /></span></pre> <p>feeds the command <tt>wc</tt> with input from the file <tt>myfiles</tt>. Although you could obtain the same output by having the filename as an argument, the need for input redirection becomes more apparent in shell programming.</p> <p>To string the output from one command to the input of the next command, you can use the <tt>|</tt> (pipe) symbol. For example,</p> <pre><span style="color:#0066ff;">$ls -s | sort -nr | pg<br /></span></pre> <p>This lists the files in the current directory with blocksize and then pipes the output to the <tt>sort</tt>, which sorts the files in numeric descending order and pipes that output to the paging command <tt>pg</tt> for final display on the terminal's monitor. The pipe command is one of the most useful tools when creating command constructs. </p><h3><span style="color:#000077;"><b>Command Substitution</b></span></h3> <p>Command substitution is similar to redirection except that is used to provide arguments to a command from the output of another. For example,</p> <pre><span style="color:#0066ff;">$grep 'wc -l myfiles' *<br /></span></pre> <p>takes the number of lines in the file <tt>myfiles</tt> from the <tt>wc</tt> command and places the number as an argument to the <tt>grep</tt> command to search all files in the current directory for that number. </p><h3><span style="color:#000077;"><b>Maintenance of Variables</b></span></h3> <p>The shell is capable of maintaining variables. <i>Variables</i> are places you can store data for later use. You assign a value to a variable with an equal (<tt>=</tt>) sign:</p> <pre><span style="color:#0066ff;">$ LOOKUP=/usr/mydir<br /></span></pre> <p>Here, the shell establishes <tt>LOOKUP</tt> as a variable and assigns it the value <tt>/usr/mydir</tt>. Later, you can use the value stored in <tt>LOOKUP</tt> in a command line by prefacing the variable name with a dollar sign (<tt>$</tt>). Consider these examples:</p> <pre><span style="color:#0066ff;">$ echo $LOOKUP<br />/usr/mydir<br />$ echo LOOKUP<br />LOOKUP<br /></span></pre> <p>To make a variable available to child processes, you can use the <tt>export</tt> command--for example:</p> <pre><span style="color:#0066ff;">$ LOOKUP=/usr/mydir<br />$export LOOKUP<br /></span></pre> <blockquote> <p> </p><hr /> <span style="color:#000077;"><b>NOTE:</b></span><b> </b>Assigning values to variables in the C shell differs from doing so in the Bourne and Korn shells. To assign a variable in the C-shell, use the <tt>set</tt> command: <p><span style="color:#0066ff;"><tt>% set LOOKUP = /usr/mydir</tt></span> </p></blockquote> <blockquote> <p>Notice that spaces precede and follow the equal sign. </p><hr /> </blockquote> <p>Like filename substitution, variable name substitution happens before the program call is made. The second example omits the dollar sign (<tt>$</tt>). Therefore, the shell simply passes the string to <tt>echo</tt> as an argument. In variable name substitution, the value of the variable replaces the variable name.</p> <p>For example, in</p> <pre><span style="color:#0066ff;">$ ls $LOOKUP/filename<br /></span></pre> <p>the <tt>ls</tt> program is called with the single argument <tt>/<i>usr</i>/<i>mydir</i>/<i>filename</i></tt>. </p><h3><span style="color:#000077;"><b>Shell Startup--Environment Control</b></span></h3> <p>When a user begins a session with UNIX and the shell is executed, the shell creates a specified environment for the user. The following sections describe these processes.</p> <p><b>Shell Environment Variables</b> When the login program invokes your shell, it sets up your environment variables, which are read from the shell initialization files <tt>/etc/profile</tt> and <tt>.profile</tt>. These files normally set the type of terminal in the variable <tt>$TERM</tt> and the default path that is searched for executable files in the variable <tt>$PATH</tt>. Try these examples:</p> <pre><span style="color:#0066ff;">$ echo $TERM<br />$ echo $PATH<br /></span></pre> <p>You can easily change the variables the same way you assign values to any shell variable.</p> <blockquote> <p> </p><hr /> <span style="color:#000077;"><b>NOTE:</b></span><b> </b>C shell assigns values to environment variables using the <tt>setenv</tt> command: <p><span style="color:#0066ff;"><tt>% setenv TERM vt100</tt></span> </p><hr /> </blockquote> <p><b>Shell Startup Files</b> The file <tt>.profile</tt> is the local startup file for the Bourne shell. The Korn shell uses <tt>.kshrc</tt>, and the C shell uses <tt>.cshrc</tt>. You can edit these files to manipulate your startup environment. You can add additional variables as the need arises. You also can add shell programming to have conditional environment settings, if necessary.</p> <p><b>Shell Startup Options</b> When invoking the shell either from <tt>/etc/passwd</tt> or the command line, you can set several options as arguments to the shell program. For example, the Bourne shell has a <tt>-x</tt> option that displays commands and their arguments before they are executed. This is useful for debugging a shell program. These options are described in detail in the following chapters. </p><h3><span style="color:#000077;"><b>Shell Programming</b></span></h3> <p>You've seen that the shell is used to interpret command lines, maintain variables, and execute programs. The shell is also a programming language. You can store a set of shell commands in file. This is known as a <i>shell script</i> or <i>shell programming.</i> By combining commands and variable assignments with flow control and decision making, you have a powerful programming tool. Using the shell as a programming language, you can automate recurring tasks, write reports, and build and manipulate your own data files. The remaining chapters in Part II discuss shell programming in more detail. </p><h2><span style="color:#000077;"><b>Summary</b></span></h2> <p>The shell provides an interface between the user and the heart of UNIX--the kernel. The shell interprets command lines as input, makes filename and variable substitution, redirects input and output, locates the executable file, and initiates and interfaces programs. The shell creates child processes and can manage their execution. The shell maintains each user's environment variables. The shell is also a powerful programming language.</p> <p>While this chapter gives an overview of the UNIX shell, Chapters 9 through 13 describe in detail the various shells, their features, and language specifics. Also described are the fundamentals of shell programming and execution. Continued reading is highly recommended. </p>Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-80137711638705072342008-08-28T23:55:00.001-07:002008-12-23T00:12:05.690-08:00Unix commandscd matlab change to the subdirectory named matlab<br />cd change to the home directory<br />cp file1 file2 make a copy of file1 called file2<br />cp dir2/file1 . copy file1 from directory dir2 into current directory<br />echo $param show idefinition of param<br />env show values of environment variables<br />history show previous commands by number<br />lpr -Pworkman54 f1 print f1 (notice capital P)<br />lpq -Pworkman54 look at printer queue for sage<br />ls *dwg list names of all files ending in the letters dwg<br />man cp learn more about cp command (manual)<br />mkdir ansys make a new directory called ansys (change to root<br /> first with cd command)<br />more file1 look at file1 page by page (usually aliased to just m)<br />mv file1 file2 move or rename file1 to file2<br />pwd show current directory name<br />rm *bak remove all files ending in the letters bak<br />abbr=orig define abbreviation (usually shorter)<br />tail -15 file1 look at last 15 lines of file1<br /><br />You can rerun previous commands and make changes with emacs commands:<br />^P redisplay previous command (then use commands to change it)<br />^Rls repeat most recent command that begins with ls<br />!5 repeat command 5 (use history or h to find the command number)<br />!^ first option of previous command<br />!$ last option of previous command<br />!* all options of previous command<br />!:2 second option of previous command<br /><br />Before erasing files, check that the parameters are correct. For example, first give:<br /> ls fname* # list corresponding files<br /> rm !$ # erase those files<br /><br />To copy files from my class directory, define a short symbol a, then check th<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />rm': Remove files or directories<br /> =================================<br /><br /> `rm' removes each given FILE. By default, it does not remove<br /> directories. Synopsis:<br /><br /> rm [OPTION]... [FILE]...<br /><br /> If a file is unwritable, standard input is a terminal, and the `-f'<br /> or `--force' option is not given, or the `-i' or `--interactive' option<br /> _is_ given, `rm' prompts the user for whether to remove the file. If<br /> the response does not begin with `y' or `Y', the file is skipped.<br /><br /> The program accepts the following options. Also see XRef Common<br /> options.<br /><br /> `-d'<br /> `--directory'<br /> Remove directories with `unlink' instead of `rmdir', and don't<br /> require a directory to be empty before trying to unlink it. Only<br /> works if you have appropriate privileges. Because unlinking a<br /> directory causes any files in the deleted directory to become<br /> unreferenced, it is wise to `fsck' the filesystem after doing this.<br /><br /> `-f'<br /> `--force'<br /> Ignore nonexistent files and never prompt the user. Ignore any<br /> previous `--interactive' (`-i') option.<br /><br /> `-i'<br /> `--interactive'<br /> Prompt whether to remove each file. If the response does not begin<br /> with `y' or `Y', the file is skipped. Ignore any previous<br /> `--force' (`-f') option.<br /><br /> `-r'<br /> `-R'<br /> `--recursive'<br /> Remove the contents of directories recursively.<br /><br /> `-v'<br /> `--verbose'<br /> Print the name of each file before removing it.<br /><br /> One common question is how to remove files whose names begin with a<br /> `-'. GNU `rm', like every program that uses the `getopt' function to<br /> parse its arguments, lets you use the `--' option to indicate that all<br /> following arguments are non-options. To remove a file called `-f' in<br /> the current directory, you could type either:<br /><br /> rm -- -f<br /><br /> or:<br /><br /> rm ./-f<br /><br /> The Unix `rm' program's use of a single `-' for this purpose<br /> predates the development of the getopt standard syntax.<br /><br /><br />Prev (fileutils) mv invocation Up (fileutils) Basic operations<br />--------------------------------------------------------------------------------<br />automatically generated by info2html<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />FTP Options<br /> ===========<br /><br /> `--retr-symlinks'<br /> Retrieve symbolic links on FTP sites as if they were plain files,<br /> i.e. don't just create links locally.<br /><br /> `-g on/off'<br /> `--glob=on/off'<br /> Turn FTP globbing on or off. Globbing means you may use the<br /> shell-like special characters ("wildcards"), like `*', `?', `['<br /> and `]' to retrieve more than one file from the same directory at<br /> once, like:<br /><br /> wget ftp://gnjilux.cc.fer.hr/*.msg<br /><br /> By default, globbing will be turned on if the URL contains a<br /> globbing character. This option may be used to turn globbing on<br /> or off permanently.<br /><br /> You may have to quote the URL to protect it from being expanded by<br /> your shell. Globbing makes Wget look for a directory listing,<br /> which is system-specific. This is why it currently works only<br /> with Unix FTP servers (and the ones emulating Unix `ls' output).<br /><br /> `--passive-ftp'<br /> Use the "passive" FTP retrieval scheme, in which the client<br /> initiates the data connection. This is sometimes required for FTP<br /> to work behind firewalls.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-34993272500241113422008-08-12T04:59:00.000-07:002008-12-23T00:12:05.690-08:00Shell Scripting<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><title>© Moreniche</title><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"></o:smarttagtype><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>Marcus Polo</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-alt:Wingdings; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:ËÎÌå; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} h1 {mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; mso-outline-level:1; font-size:24.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US; font-weight:bold;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:#606420; text-decoration:underline; text-underline:single;} p {mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} code {font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New";} pre {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:"Courier New"; mso-fareast-language:EN-US;} tt {font-family:"Courier New"; mso-ascii-font-family:"Courier New"; mso-fareast-font-family:"Courier New"; mso-hansi-font-family:"Courier New"; mso-bidi-font-family:"Courier New";} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:715197189; mso-list-type:hybrid; mso-list-template-ids:92599426 -1188517740 -530799512 -598695272 899042700 1585353110 -1582956514 -586365152 -911154184 1473959580;} @list l0:level1 {mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in;} @list l1 {mso-list-id:1766881187; mso-list-type:hybrid; mso-list-template-ids:273993362 982664326 986370680 -204317022 -317400724 -1397041012 -179270248 1650645040 1397247610 -267460948;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <h1><span style="font-size: 14pt;"><o:p> </o:p></span></h1> <h1><span style="font-size: 16pt;">Variables in Shell<o:p></o:p></span></h1> <p>To process our data/information, data must be kept in computers RAM memory. RAM memory is divided into small locations, and each location had unique number called memory location/address, which is used to hold our data. Programmer can give a unique name to this memory location/address called memory variable or variable (Its a named storage location that may take different values, but only one at a time).</p> <p>In Shell, there are two types of variable:
<br />(1) <b>System variables</b> - Created and maintained by Linux itself. This type of variable defined in CAPITAL LETTERS.
<br />(2) <b>User defined variables (UDV)</b> - Created and maintained by user. This type of variable defined in lower letters.</p> <p>You can see system variables by giving command like <b>$ set</b>, some of the important System variables are:</p> <table class="MsoNormalTable" style="width: 99%;" width="99%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr> <td style="padding: 0.75pt; background: rgb(204, 204, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>System Variable </b></p> </td> <td style="padding: 0.75pt; background: rgb(204, 204, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Meaning </b></p> </td> </tr> <tr style="height: 12.75pt;"> <td style="padding: 0.75pt; height: 12.75pt;" valign="top"> <p class="MsoNormal">BASH=/bin/bash</p> </td> <td style="padding: 0.75pt; height: 12.75pt;" valign="top"> <p class="MsoNormal">Our shell name</p> </td> </tr> <tr> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">BASH_VERSION=1.14.7(1)</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Our shell version name</p> </td> </tr> <tr> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">COLUMNS=80</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">No. of columns for our screen</p> </td> </tr> <tr> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">HOME=/home/vivek</p> </td> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal">Our home directory</p> </td> </tr> <tr style="height: 1.5pt;"> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">LINES=25</p> </td> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">No. of columns for our screen</p> </td> </tr> <tr style="height: 1.5pt;"> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">LOGNAME=students</p> </td> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">students Our logging name</p> </td> </tr> <tr style="height: 1.5pt;"> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">OSTYPE=Linux</p> </td> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">Our Os type</p> </td> </tr> <tr style="height: 1.5pt;"> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">PATH=/usr/bin:/sbin:/bin:/usr/sbin</p> </td> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">Our path settings</p> </td> </tr> <tr style="height: 1.5pt;"> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">PWD=/home/students/Common</p> </td> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">Our current working directory</p> </td> </tr> <tr style="height: 1.5pt;"> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">SHELL=/bin/bash</p> </td> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">Our shell name</p> </td> </tr> <tr style="height: 1.5pt;"> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">USERNAME=vivek</p> </td> <td style="padding: 0.75pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style="">User name who is currently login to this PC</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">How to define User defined variables (UDV)<o:p></o:p></span></h1> <p>To define UDV use following syntax
<br /><i>Syntax: </i>
<br />variable name=value</p> <p>'<b>value</b>' is assigned to given '<b>variable name</b>' and Value must be on right side = sign.
<br />
<br /><i>Example:
<br /></i><code><span style="font-size: 10pt;">$ no=10</span></code># this is ok
<br /><code><span style="font-size: 10pt;">$ 10=no</span></code># Error, NOT Ok, Value must be on right side of = sign.
<br />To define variable called 'vech' having value Bus
<br /><code><span style="font-size: 10pt;">$ vech=Bus</span></code>
<br />To define variable called n having value 10
<br /><code><span style="font-size: 10pt;">$ n=10</span></code></p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">How to print or access value of UDV (User defined variables)<o:p></o:p></span></h1> <p>To print or access UDV use following syntax
<br /><i>Syntax: </i>
<br />$variablename</p> <p>Define variable vech and n as follows:
<br /><code><span style="font-size: 10pt;">$ vech=Bus</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /><code>$ n=10</code></span>
<br />To print contains of variable 'vech' type
<br /><code><span style="font-size: 10pt;">$ echo $vech</span></code>
<br />It will print 'Bus',To print contains of variable 'n' type command as follows
<br /><code><span style="font-size: 10pt;">$ echo $n</span></code></p> <p><b>Exercise </b>
<br />Q.1.How to Define variable x with value 10 and print it on screen.
<br />Q.2.How to Define variable xn with value Rani and print it on screen
<br />Q.3.How to print sum of two numbers, let's say 6 and 3?
<br />Q.4.How to define two variable x=20, y=5 and then to print division of x and y (i.e. x/y)
<br />Q.5.Modify above and store division of x and y to variable called z
<br />Q.6.Point out error if any in following script</p> <table class="MsoNormalTable" style="width: 100%;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style="height: 15.75pt;"> <td style="padding: 0.75pt; background: rgb(204, 204, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; height: 15.75pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$ vi variscript</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#</code>
<br /> <code>#</code>
<br /> <code># Script to test MY knowledge about variables!</code>
<br /> <code>#</code>
<br /> <code>myname=Vivek</code>
<br /> <code>myos = TroubleOS</code>
<br /> <code>myno=5</code>
<br /> <code>echo "My name is $myname"</code>
<br /> <code>echo "My os is $myos"</code>
<br /> <code>echo "My number is myno, can you see this number"</code></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">echo Command<o:p></o:p></span></h1> <p>Use echo command to display text or value of variable.</p> <p>echo [options] [string, variables...]
<br />Displays text or variables value on screen.
<br />Options
<br />-n Do not output the trailing new line.
<br />-e Enable interpretation of the following backslash escaped characters in the strings:
<br />\a alert (bell)
<br />\b backspace
<br />\c suppress trailing new line
<br />\n new line
<br />\r carriage return
<br />\t horizontal tab
<br />\\ backslash</p> <p>For e.g. <b>$ echo -e "An apple a day keeps away \a\t\tdoctor\n"</b></p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">Shell Arithmetic<o:p></o:p></span></h1> <p>Use to perform arithmetic operations.</p> <p><i>Syntax:</i>
<br />expr op1 math-operator op2
<br />
<br /><i>Examples: </i>
<br /><code><span style="font-size: 10pt;">$ expr 1 + 3</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /><code>$ expr 2 - 1</code>
<br /><code>$ expr 10 / 2</code>
<br /><code>$ expr 20 % 3</code>
<br /><code>$ expr 10 \* 3</code>
<br /><code>$ echo `expr 6 + 3`</code></span></p> <p><b>Note:
<br /></b>expr 20 %3 - Remainder read as 20 mod 3 and remainder is 2.
<br />expr 10 \* 3 - Multiplication use \* and not * since its wild card.</p> <p>For the last statement not the following points</p> <p>(1) First, before expr keyword we used ` (back quote) sign not the (single quote i.e. ') sign. Back quote is generally found on the key under tilde (~) on PC keyboard OR to the above of TAB key.</p> <p>(2) Second, expr is also end with ` i.e. back quote.</p> <p>(3) Here expr 6 + 3 is evaluated to 9, then echo command prints 9 as sum</p> <p>(4) Here if you use double quote or single quote, it will NOT work
<br />For e.g.
<br /><b>$ echo "expr 6 + 3"</b> # It will print expr 6 + 3
<br /><b>$ echo 'expr 6 + 3'</b> # It will print expr 6 + 3</p> <p class="MsoNormal"><o:p> </o:p></p> <p>There are three types of quotes</p> <table class="MsoNormalTable" style="width: 100%;" width="100%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr> <td style="padding: 0.75pt; background: rgb(204, 204, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Quotes</b></p> </td> <td style="padding: 0.75pt; background: rgb(204, 204, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Name</b></p> </td> <td style="padding: 0.75pt; background: rgb(204, 204, 204) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Meaning</b></p> </td> </tr> <tr> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b>"</b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">Double Quotes</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">"Double Quotes" - Anything enclose in double quotes removed meaning of that characters (except \ and $).</p> </td> </tr> <tr> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b>'</b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">Single quotes</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">'Single quotes' - Enclosed in single quotes remains unchanged.</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><b>`</b></p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">Back quote</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">
<br /> `Back quote` - To execute command</p> </td> </tr> </tbody></table> <p><i>Example</i>:
<br /><b>$ echo "Today is date" </b>
<br />Can't print message with today's date.
<br /><b>$ echo "Today is `date`". </b>
<br />It will print today's date as, Today is Tue Jan ....,Can you see that the `date` statement uses back quote?</p> <h1><span style="font-size: 12pt; font-weight: normal;"><o:p> </o:p></span></h1> <h1><span style="font-size: 16pt;">Exit Status<o:p></o:p></span></h1> <p>By default in Linux if particular command/shell script is executed, it return two type of values which is used to see whether command or shell script executed is successful or not.</p> <p>(1) If return <i>value is zero</i> (0), command is successful.
<br />(2) If return <i>value is nonzero</i>, command is not successful or some sort of error executing command/shell script.</p> <p>This value is know as <b><i>Exit Status</i></b>.</p> <p>But how to find out exit status of command or shell script?
<br />Simple, to determine this exit Status you can use <b>$? </b>special variable of shell.</p> <p>For e.g. (This example assumes that <b>unknow1file</b> doest not exist on your hard drive)
<br /><b>$ rm unknow1file </b>
<br />It will show error as follows
<br />rm: cannot remove `unkowm1file': No such file or directory
<br />and after that if you give command
<br /><b>$ echo $? </b>
<br />it will print nonzero value to indicate error. Now give command
<br /><b>$ ls
<br />$ echo $? </b>
<br />It will print 0 to indicate command is successful.</p> <p><o:p> </o:p></p> <h1><span style="font-size: 16pt;">The read Statement<o:p></o:p></span></h1> <p>Use to get input (data from user) from keyboard and store (data) to variable.
<br /><i>Syntax: </i>
<br />read variable1, variable2,...variableN</p> <p>Following script first ask user, name and then waits to enter name from the user via keyboard. Then user enters name from keyboard (after giving name you have to press ENTER key) and entered name through keyboard is stored (assigned) to variable fname.</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 0.75pt;" valign="top"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$ vi sayH</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#</code>
<br /> <code>#Script to read your name from key-board</code>
<br /> <code>#</code>
<br /> <code>echo "Your first name please:"</code>
<br /> <code>read fname</code>
<br /> <code>echo "Hello $fname, Lets be friend!"</code></span></p> </td> </tr> </tbody></table> <p>Run it as follows:
<br /><code><span style="font-size: 10pt;">$ chmod 755 sayH</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /><code>$ ./sayH</code></span>
<br /><i>Your first name please: <b>vivek</b>
<br />Hello vivek, Lets be friend!</i></p> <h1><span style="font-size: 16pt;">Wild cards (Filename Shorthand or meta Characters)<o:p></o:p></span></h1> <p> </p> <table class="MsoNormalTable" style="width: 100%;" width="100%" border="1" cellpadding="0"> <tbody><tr> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 15%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="15%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Wild card /Shorthand</b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 35%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="35%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Meaning</b></p> </td> <td colspan="2" style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="50%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Examples</b></p> </td> </tr> <tr style="page-break-inside: avoid;"> <td rowspan="4" style="padding: 0.75pt; width: 15%;" width="15%"> <p class="MsoNormal"><b>*</b></p> </td> <td rowspan="4" style="padding: 0.75pt; width: 35%;" width="35%"> <p class="MsoNormal">Matches any string or group of characters.</p> </td> <td style="padding: 0.75pt; width: 12%;" width="12%"> <p class="MsoNormal"><b>$ ls *</b></p> </td> <td style="padding: 0.75pt; width: 38%;" width="38%"> <p class="MsoNormal">will show all files</p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0.75pt; width: 12%;" width="12%"> <p class="MsoNormal"><b>$ ls a*</b></p> </td> <td style="padding: 0.75pt; width: 38%;" width="38%"> <p class="MsoNormal">will show all files whose first name is starting with letter 'a'</p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0.75pt; width: 12%;" width="12%"> <p class="MsoNormal"><b>$ ls *.c</b> </p> </td> <td style="padding: 0.75pt; width: 38%;" width="38%"> <p class="MsoNormal">will show all files having extension .c</p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0.75pt; width: 12%;" width="12%"> <p class="MsoNormal"><b>$ ls ut*.c</b></p> </td> <td style="padding: 0.75pt; width: 38%;" width="38%"> <p class="MsoNormal">will show all files having extension .c but file name must begin with 'ut'.</p> </td> </tr> <tr style="page-break-inside: avoid;"> <td rowspan="2" style="padding: 0.75pt; width: 15%;" width="15%"> <p class="MsoNormal"><b>?</b></p> </td> <td rowspan="2" style="padding: 0.75pt; width: 35%;" width="35%"> <p class="MsoNormal">Matches any single character.</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ ls ?</b> </p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal">will show all files whose names are 1 character long </p> </td> </tr> <tr style="page-break-inside: avoid;"> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ ls fo?</b></p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal">will show all files whose names are 3 character long and file name begin with fo</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 15%;" width="15%"> <p class="MsoNormal"><b>[...]</b></p> </td> <td style="padding: 0.75pt; width: 35%;" width="35%"> <p class="MsoNormal">Matches any one of the enclosed characters</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ ls [abc]* </b></p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal">will show all files beginning with letters a,b,c</p> </td> </tr> </tbody></table> <p><b>Note: </b>
<br />[..-..] A pair of characters separated by a minus sign denotes a range.</p> <p><i>Example</i>:
<br /><b>$ ls /bin/[a-c]* </b></p> <p>Will show all files name beginning with letter a,b or c like</p> <p> /bin/arch /bin/awk /bin/bsh /bin/chmod /bin/cp
<br /> /bin/ash /bin/basename /bin/cat /bin/chown /bin/cpio
<br /> /bin/ash.static /bin/bash /bin/chgrp /bin/consolechars /bin/csh</p> <p>But
<br /><b>$ ls /bin/[!a-o]
<br />$ ls /bin/[^a-o]</b></p> <p>If the first character following the [ is a ! or a ^ ,then any character not enclosed is matched i.e. do not show us file name that beginning with a,b,c,e...o, like</p> <p> /bin/ps /bin/rvi /bin/sleep /bin/touch /bin/view
<br /> /bin/pwd /bin/rview /bin/sort /bin/true /bin/wcomp
<br /> /bin/red /bin/sayHello /bin/stty /bin/umount /bin/xconf
<br /> /bin/remadmin /bin/sed /bin/su /bin/uname /bin/ypdomainname
<br /> /bin/rm /bin/setserial /bin/sync /bin/userconf /bin/zcat
<br /> /bin/rmdir /bin/sfxload /bin/tar /bin/usleep
<br /> /bin/rpm /bin/sh /bin/tcsh /bin/vi</p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">More command on one command line<o:p></o:p></span></h1> <p><i>Syntax:</i>
<br />command1;command2
<br />To run two command with one command line.</p> <p><i>Examples:</i>
<br /><b>$ date;who </b>
<br />Will print today's date followed by users who are currently login. Note that You can't use
<br /><b>$ date who </b>
<br />for same purpose, you must put semicolon in between date and who command.</p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">Why Command Line arguments required<o:p></o:p></span></h1> <ol start="1" type="1"><li class="MsoNormal" style="">Telling the command/utility which option to use. </li><li class="MsoNormal" style="">Informing the utility/command which file or group of files to process (reading/writing of files). </li></ol> <p>Let's take rm command, which is used to remove file, but which file you want to remove and how you will tail this to rm command (even rm command don't ask you name of file that you would like to remove). So what we do is we write command as follows:
<br /><b>$ rm {file-name}</b>
<br />Here rm is command and filename is file which you would like to remove. This way you tail rm command which file you would like to remove. So we are doing one way communication with our command by specifying filename Also you can pass command line arguments to your script to make it more users friendly. But how we access command line argument in our script.</p> <p>Lets take ls command
<br /><b>$ Ls -a /* </b>
<br />This command has 2 command line argument -a and /* is another. For shell script,
<br /><b>$ myshell foo bar </b></p> <p><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:formulas> <v:path extrusionok="f" gradientshapeok="t" connecttype="rect"> <o:lock ext="edit" aspectratio="t"> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="'width:138pt;"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image001.gif" href="http://www.freeos.com/guides/lsst/images/myshell.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image001.gif" shapes="_x0000_i1025" width="184" height="96" /><!--[endif]--></p> <p><!--[if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" alt="" style="'width:19.5pt;height:24pt'"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image002.gif" href="http://www.freeos.com/guides/lsst/images/1.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image002.gif" shapes="_x0000_i1026" width="26" height="32" /><!--[endif]-->Shell Script name i.e. myshell
<br /><!--[if gte vml 1]><v:shape id="_x0000_i1027" type="#_x0000_t75" alt="" style="'width:19.5pt;height:24.75pt'"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image003.gif" href="http://www.freeos.com/guides/lsst/images/2.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image003.gif" shapes="_x0000_i1027" width="26" height="33" /><!--[endif]-->First command line argument passed to myshell i.e. foo
<br /><!--[if gte vml 1]><v:shape id="_x0000_i1028" type="#_x0000_t75" alt="" style="'width:19.5pt;height:25.5pt'"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image004.gif" href="http://www.freeos.com/guides/lsst/images/3.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image004.gif" shapes="_x0000_i1028" width="26" height="34" /><!--[endif]-->Second command line argument passed to myshell i.e. bar</p> <p>In shell if we wish to refer this command line argument we refer above as follows</p> <p><!--[if gte vml 1]><v:shape id="_x0000_i1029" type="#_x0000_t75" alt="" style="'width:19.5pt;height:24pt'"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image002.gif" href="http://www.freeos.com/guides/lsst/images/1.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image002.gif" shapes="_x0000_i1029" width="26" height="32" /><!--[endif]-->myshell it is $0
<br /><!--[if gte vml 1]><v:shape id="_x0000_i1030" type="#_x0000_t75" alt="" style="'width:19.5pt;height:24.75pt'"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image003.gif" href="http://www.freeos.com/guides/lsst/images/2.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image003.gif" shapes="_x0000_i1030" width="26" height="33" /><!--[endif]-->foo it is $1
<br /><!--[if gte vml 1]><v:shape id="_x0000_i1031" type="#_x0000_t75" alt="" style="'width:19.5pt;height:24.75pt'"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image003.gif" href="http://www.freeos.com/guides/lsst/images/2.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image003.gif" shapes="_x0000_i1031" width="26" height="33" /><!--[endif]-->bar it is $2</p> <p>Here <b>$# </b>(built in shell variable ) will be 2 (Since foo and bar only two Arguments), Please note at a time such 9 arguments can be used from $1..$9, You can also refer all of them by using $* (which expand to `$1,$2...$9`). Note that $1..$9 i.e command line arguments to shell script is know as "<i>positional parameters</i>".</p> <p><b>Exercise</b>
<br />Try to write following for commands
<br />Shell Script Name ($0),
<br />No. of Arguments (i.e. $#),
<br />And actual argument (i.e. $1,$2 etc)
<br /><code><span style="font-size: 10pt;">$ sum 11 20</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /><code>$ math 4 - 7</code>
<br /><code>$ d</code>
<br /><code>$ bp -5 myf +20</code>
<br /><code>$ Ls *</code>
<br /><code>$ cal</code>
<br /><code>$ findBS 4 8 24 BIG</code></span></p> <p> </p> <table class="MsoNormalTable" style="width: 100%;" width="100%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr> <td style="padding: 0.75pt; background: gray none repeat scroll 0% 0%; width: 33%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="33%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Shell Script Name </b></p> </td> <td style="padding: 0.75pt; background: gray none repeat scroll 0% 0%; width: 33%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="33%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>No. Of Arguments to script</b></p> </td> <td colspan="5" style="padding: 0.75pt; background: gray none repeat scroll 0% 0%; width: 34%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="34%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Actual Argument ($1,..$9)</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 33%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="33%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><i>$0</i></b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 33%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="33%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><i>$#</i></b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 7%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="7%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><i>$1</i></b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 7%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="7%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><i>$2</i></b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 7%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="7%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><i>$3</i></b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 7%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="7%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><i>$4</i></b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 6%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="6%"> <p class="MsoNormal" style="text-align: center;" align="center"><b><i>$5</i></b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">Sum</p> </td> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">2</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">11</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">20</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 6%;" width="6%"> <p class="MsoNormal"> </p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">Math</p> </td> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">3</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">4</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">-</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">7</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 6%;" width="6%"> <p class="MsoNormal"> </p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">D</p> </td> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">0</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 6%;" width="6%"> <p class="MsoNormal"> </p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">Bp</p> </td> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">3</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">-5</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">myf</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">+20</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 6%;" width="6%"> <p class="MsoNormal"> </p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">Ls</p> </td> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">1</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">*</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 6%;" width="6%"> <p class="MsoNormal"> </p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal"><st1:state st="on"><st1:place st="on">Cal</st1:place></st1:state></p> </td> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">0</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; width: 6%;" width="6%"> <p class="MsoNormal"> </p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">FindBS</p> </td> <td style="padding: 0.75pt; width: 33%;" width="33%"> <p class="MsoNormal">4</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">4</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">8</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">24</p> </td> <td style="padding: 0.75pt; width: 7%;" width="7%"> <p class="MsoNormal">BIG</p> </td> <td style="padding: 0.75pt; width: 6%;" width="6%"> <p class="MsoNormal"> </p> </td> </tr> </tbody></table> <p>Following script is used to print command ling argument and will show you how to access them:</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$ vi demo</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#!/bin/sh</code>
<br /> <code>#</code>
<br /> <code># Script that demos, command line args</code>
<br /> <code>#</code>
<br /> <code>echo "Total number of command line argument are $#"</code>
<br /> <code>echo "$0 is script name"</code>
<br /> <code>echo "$1 is first argument"</code>
<br /> <code>echo "$2 is second argument"</code>
<br /> <code>echo "All of them are :- $* or $@"</code></span></p> </td> </tr> </tbody></table> <p>Run it as follows</p> <p>Set execute permission as follows:
<br /><b>$ chmod 755 demo</b></p> <p>Run it & test it as follows:
<br /><b>$ ./demo Hello World</b></p> <p>If test successful, copy script to your own bin directory (Install script for private use)
<br /><b>$ cp demo ~/bin</b></p> <p>Check whether it is working or not (?)
<br /><b>$ demo</b>
<br /><b>$ demo Hello World</b></p> <p>Also note that you <b><i>can't assigne the new value to command line arguments i.e positional parameters</i></b>. So following all statements in shell script are invalid:
<br /><b>$1 = 5
<br />$2 = "My Name"</b></p> <h1><span style="font-size: 16pt;">Redirection of Standard output/input i.e. Input - Output redirection<o:p></o:p></span></h1> <p>Mostly all command gives output on screen or take input from keyboard, but in Linux (and in other OSs also) it's possible to send output to file or to read input from file.</p> <p>For e.g.
<br /><b>$ ls</b> command gives output to screen; to send output to file of ls command give command
<br />
<br /><b>$ ls > filename</b>
<br />It means put output of ls command to filename.</p> <p>There are three main redirection symbols <b>>,>>,<</b></p> <p>(1) > Redirector Symbol
<br /><i>Syntax:</i>
<br />Linux-command > filename
<br />To output Linux-commands result (output of command or shell script) to file. Note that if file already exist, it will be overwritten else new file is created. For e.g. To send output of ls command give
<br /><b>$ ls > myfiles</b>
<br />Now if '<b>myfiles</b>' file exist in your current directory it will be overwritten without any type of warning.</p> <p>(2) >> Redirector Symbol
<br /><i>Syntax:</i>
<br />Linux-command >> filename
<br />To output Linux-commands result (output of command or shell script) to END of file. Note that if file exist , it will be opened and new information/data will be written to END of file, without losing previous information/data, And if file is not exist, then new file is created. For e.g. To send output of date command to already exist file give command
<br /><b>$ date >> myfiles</b></p> <p>(3) < Redirector Symbol
<br /><i>Syntax:</i>
<br />Linux-command < filename
<br />To take input to Linux-command from file instead of key-board. For e.g. To take input for cat command give
<br /><b>$ cat <></p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">Pipes<o:p></o:p></span></h1> <p>A pipe is a way to connect the output of one program to the input of another program without any temporary file.</p> <p style="text-align: center;" align="center"><!--[if gte vml 1]><v:shape id="_x0000_i1032" type="#_x0000_t75" alt="Pipe - Redirecting output of 1st command to 2nd without creating temporary file" style="'width:216.75pt;height:87pt'"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image005.gif" href="http://www.freeos.com/guides/lsst/images/pipe.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image005.gif" alt="Pipe - Redirecting output of 1st command to 2nd without creating temporary file" shapes="_x0000_i1032" width="289" height="116" /><!--[endif]--></p> <p>Pipe Defined as:
<br />"<i>A pipe is nothing but a temporary storage place where the output of one command is stored and then passed as the input for second command. Pipes are used to run more than two commands ( Multiple commands) from same command line.</i>"</p> <p><i>Syntax:</i>
<br />command1 | command2</p> <p><i>Examles:</i></p> <p> </p> <table class="MsoNormalTable" style="width: 100%;" width="100%" border="1" cellpadding="0"> <tbody><tr> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="50%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Command using Pipes</b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="50%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Meaning or Use of Pipes</b></p> </td> </tr> <tr style="height: 20.25pt;"> <td style="padding: 0.75pt; width: 50%; height: 20.25pt;" width="50%"> <p class="MsoNormal"><b>$ ls | more</b></p> </td> <td style="padding: 0.75pt; width: 50%; height: 20.25pt;" width="50%"> <p class="MsoNormal">Output of ls command is given as input to more command So that output is printed one screen full page at a time.</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal"><b>$ who | sort </b></p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Output of who command is given as input to sort command So that it will print sorted list of users</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal"><b>$ who | sort > user_list</b></p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Same as above except output of sort is send to (redirected) user_list file</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal"><b>$ who | wc -l </b></p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Output of who command is given as input to wc command So that it will number of user who logon to system</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal"><b>$ ls -l | wc -l </b></p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Output of ls command is given as input to wc command So that it will print number of files in current directory.</p> </td> </tr> <tr style="height: 1.5pt;"> <td style="padding: 0.75pt; width: 50%; height: 1.5pt;" width="50%"> <p class="MsoNormal" style=""><b>$ who | grep raju</b></p> </td> <td style="padding: 0.75pt; width: 50%; height: 1.5pt;" width="50%"> <p class="MsoNormal" style="">Output of who command is given as input to grep command So that it will print if particular user name if he is logon or nothing is printed (To see particular user is logon or not)</p> </td> </tr> </tbody></table> <h1><span style="font-size: 16pt;">Filter<o:p></o:p></span></h1> <p>If a Linux command accepts its input from the standard input and produces its output on standard output is know as a filter. A filter performs some kind of process on the input and gives output. For e.g.. Suppose you have file called 'hotel.txt' with 100 lines data, And from 'hotel.txt' you would like to print contains from line number 20 to line number 30 and store this result to file called 'hlist' then give command:
<br /><b>$ tail +20 <>hlist</b></p> <p>Here <b>head</b> command is filter which takes its input from tail command (tail command start selecting from line number 20 of given file i.e. hotel.txt) and passes this lines as input to head, whose output is redirected to 'hlist' file.</p> <p>Consider one more following example
<br /><b>$ sort <> u_sname</b></p> <p>Here <a href="http://www.freeos.com/guides/lsst/ch05sec08.html"><span style="">uniq</span></a> is filter which takes its input from sort command and passes this lines as input to uniq; Then uniqs output is redirected to "u_sname" file.</p> <h1><span style="font-size: 16pt;">Command Related with Process<o:p></o:p></span></h1> <p>Following tables most commonly used command(s) with process:</p> <table class="MsoNormalTable" style="width: 100%;" width="100%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 32%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="32%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>For this purpose</b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 30%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="30%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Use this Command</b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 25%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="25%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Examples*</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">To see currently running process </p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal">ps</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ ps</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">To stop any process by PID i.e. to kill process</p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal">kill {PID}</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ kill 1012</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">To stop processes by name i.e. to kill process</p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal">killall {Process-name}</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ killall httpd</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">To get information about all running process</p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal">ps -ag</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ ps -ag</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">To stop all process except your shell</p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal">kill 0</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ kill 0</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">For background processing (With &, use to put particular command and program in background)</p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal">linux-command &</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ ls / -R | wc -l &</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">To display the owner of the processes along with the processes <tt><span style="font-size: 10pt;"> </span></tt></p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal">ps aux</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ ps aux</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">To see if a particular process is running or not. For this purpose you have to use ps command in combination with the grep command</p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal"> </p> <p>ps ax | grep process-U-want-to see</p> <p> </p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal">For e.g. you want to see whether Apache web server process is running or not then give command </p> <p><b>$ ps ax | grep httpd</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">To see currently running processes and other information like memory and CPU usage with real time updates.</p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal">top
<br /> <span style="font-size: 10pt;"><a href="http://www.freeos.com/guides/lsst/images/toppid.jpg" target="_blank">See the output</a> of top command.</span></p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>
<br /> $ top</b><b><span style="font-size: 10pt;">
<br />
<br /> Note </span></b><span style="font-size: 10pt;">that to exit from top command press q.</span></p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 32%;" width="32%"> <p class="MsoNormal">To display a tree of processes</p> </td> <td style="padding: 0.75pt; width: 30%;" width="30%"> <p class="MsoNormal">pstree</p> </td> <td style="padding: 0.75pt; width: 25%;" width="25%"> <p class="MsoNormal"><b>$ pstree</b></p> </td> </tr> </tbody></table> <p><b>*</b> To run some of this command you need to be root or equivalnt user.</p> <h1><o:p> </o:p></h1> <h1><span style="font-size: 16pt;">if condition<o:p></o:p></span></h1> <p>if condition which is used for decision making in shell script, If given condition is true then command1 is executed.
<br /><i>Syntax:<o:p></o:p></i></p> <pre><i><span style=""> </span>if condition<o:p></o:p></i></pre><pre><i><span style=""> </span>then<o:p></o:p></i></pre><pre><i><span style=""> </span>command1 if condition is true or if exit status<o:p></o:p></i></pre><pre><i><span style=""> </span>of condition is 0 (zero)<o:p></o:p></i></pre><pre><i><span style=""> </span>...<o:p></o:p></i></pre><pre><i><span style=""> </span>...<o:p></o:p></i></pre><pre><i><span style=""> </span>fi<o:p></o:p></i></pre> <p>Condition is defined as:
<br />"<i>Condition is nothing but comparison between two values.</i>"
<br />
<br />For compression you can use test or [ expr ] statements or even exist status can be also used.
<br />
<br />Expreession is defined as:
<br />"<i>An expression is nothing but combination of values, relational operator (such as >,<, <> etc) and mathematical operators (such as +, -, / etc ).</i>"
<br />
<br />Following are all examples of expression:
<br />5 > 2
<br />3 + 6
<br />3 * 65
<br />a < b
<br />c > 5
<br />c > 5 + 30 -1</p> <p>Type following commands (assumes you have file called <b>foo</b>)
<br /><b>$ cat foo
<br />$ echo $? </b>
<br />The cat command return zero(0) i.e. exit status, on successful, this can be used, in if condition as follows, Write shell script as</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style="height: 56.25pt;"> <td style="padding: 0.75pt; height: 56.25pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$ cat > showfile</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#!/bin/sh</code>
<br /> <code>#</code>
<br /> <code>#Script to print file</code>
<br /> <code>#</code>
<br /> <code>if cat $1</code>
<br /> <code>then</code>
<br /> <code>echo -e "\n\nFile $1, found and successfully echoed"</code>
<br /> <code>fi</code></span></p> </td> </tr> </tbody></table> <p>Run above script as:
<br /><b>$ chmod 755 showfile</b>
<br /><b>$./showfile foo</b>
<br />Shell script name is showfile ($0) and foo is argument (which is $1).Then shell compare it as follows:
<br />if cat $1 which is expanded to if cat foo.</p> <p><b><i>Detailed explanation</i></b>
<br />if cat command finds foo file and if its successfully shown on screen, it means our cat command is successful and its exist status is 0 (indicates success), So our if condition is also true and hence statement echo -e "\n\nFile $1, found and successfully echoed" is proceed by shell. Now if cat command is not successful then it returns non-zero value (indicates some sort of failure) and this statement echo -e "\n\nFile $1, found and successfully echoed" is skipped by our shell.</p> <p><b>Exercise</b>
<br />Write shell script as follows:</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">cat > trmif</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#</code>
<br /> <code># Script to test rm command and exist status</code>
<br /> <code>#</code>
<br /> <code>if rm $1</code>
<br /> <code>then</code>
<br /> <code>echo "$1 file deleted"</code>
<br /> <code>fi</code></span></p> </td> </tr> </tbody></table> <p>Press Ctrl + d to save
<br /><b>$ chmod 755 trmif</b>
<br />
<br />Answer the following question in referance to above script:
<br />(A) foo file exists on your disk and you give command, <b>$ ./trmfi foo</b> what will be output?
<br />(B) If bar file not present on your disk and you give command, <b>$ ./trmfi bar </b>what will be output?
<br />(C) And if you type <b>$ ./trmfi</b> What will be output?</p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">test command or [ expr ]<o:p></o:p></span></h1> <p>test command or [ expr ] is used to see if an expression is true, and if it is true it return zero(0), otherwise returns nonzero for false.
<br /><i>Syntax: </i>
<br />test expression OR [ expression ]
<br /><i>
<br />Example:
<br /></i>Following script determine whether given argument number is positive.</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$ cat > ispostive</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#!/bin/sh</code>
<br /> <code>#</code>
<br /> <code># Script to see whether argument is positive</code>
<br /> <code>#</code>
<br /> <code>if test $1 -gt 0</code>
<br /> <code>then</code>
<br /> <code>echo "$1 number is positive"</code>
<br /> <code>fi</code></span></p> </td> </tr> </tbody></table> <p>Run it as follows
<br /><b>$ chmod 755 ispostive</b></p> <p><b>$ ispostive 5</b>
<br /><i>5 number is positive</i></p> <p><b>$ispostive -45</b>
<br /><i>Nothing is printed</i></p> <p><b>$ispostive</b>
<br /><i>./ispostive: test: -gt: unary operator expected </i></p> <p><b><i>Detailed explanation</i></b>
<br />The line, if test $1 -gt 0 , test to see if first command line argument($1) is greater than 0. If it is true(0) then test will return 0 and output will printed as 5 number is positive but for -45 argument there is no output because our condition is not true(0) (no -45 is not greater than 0) hence echo statement is skipped. And for last statement we have not supplied any argument hence error ./ispostive: test: -gt: unary operator expected, is generated by shell , to avoid such error we can test whether command line argument is supplied or not.</p> <p>test or [ expr ] works with
<br />1.Integer ( Number without decimal point)
<br />2.File types
<br />3.Character strings</p> <p style="text-align: center;" align="center"><b>For Mathematics, use following operator in Shell Script</b></p> <table class="MsoNormalTable" style="width: 100%;" width="100%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr> <td style="padding: 0.75pt; background: gray none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Mathematical Operator in Shell Script </b></p> </td> <td style="padding: 0.75pt; background: gray none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Meaning</b></p> </td> <td style="padding: 0.75pt; background: gray none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Normal Arithmetical/ Mathematical Statements</b></p> </td> <td colspan="2" style="padding: 0.75pt; background: gray none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>But in Shell</b></p> </td> </tr> <tr> <td style="padding: 0.75pt;"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal"> </p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>For test statement with if command</b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="text-align: center;" align="center"><b>For [ expr ] statement with if command</b></p> </td> </tr> <tr> <td style="padding: 0.75pt;"> <p class="MsoNormal">-eq</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">is equal to</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">5 == 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if test 5 -eq 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if [ 5 -eq 6 ]</p> </td> </tr> <tr> <td style="padding: 0.75pt;"> <p class="MsoNormal">-ne</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">is not equal to</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">5 != 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if test 5 -ne 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if [ 5 -ne 6 ]</p> </td> </tr> <tr> <td style="padding: 0.75pt;"> <p class="MsoNormal">-lt</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">is less than</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">5 <> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if test 5 -lt 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if [ 5 -lt 6 ]</p> </td> </tr> <tr> <td style="padding: 0.75pt;"> <p class="MsoNormal">-le</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">is less than or equal to</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">5 <= 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if test 5 -le 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if [ 5 -le 6 ]</p> </td> </tr> <tr> <td style="padding: 0.75pt;"> <p class="MsoNormal">-gt</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">is greater than</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">5 > 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if test 5 -gt 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if [ 5 -gt 6 ]</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal">-ge</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">is greater than or equal to</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">5 >= 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if test 5 -ge 6</p> </td> <td style="padding: 0.75pt;"> <p class="MsoNormal">if [ 5 -ge 6 ]</p> </td> </tr> </tbody></table> <p><b>NOTE:</b> == is equal, != is not equal.</p> <p style="text-align: center;" align="center"><b>For string Comparisons use</b></p> <div align="center"> <table class="MsoNormalTable" style="width: 73%;" width="73%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 24%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="24%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Operator</b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 76%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="76%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Meaning</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 24%;" width="24%"> <p class="MsoNormal">string1 = string2</p> </td> <td style="padding: 0.75pt; width: 76%;" width="76%"> <p class="MsoNormal">string1 is equal to string2</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 24%;" width="24%"> <p class="MsoNormal">string1 != string2</p> </td> <td style="padding: 0.75pt; width: 76%;" width="76%"> <p class="MsoNormal">string1 is NOT equal to string2</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 24%;" width="24%"> <p class="MsoNormal">string1</p> </td> <td style="padding: 0.75pt; width: 76%;" width="76%"> <p class="MsoNormal">string1 is NOT NULL or not defined </p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 24%;" width="24%"> <p class="MsoNormal">-n string1</p> </td> <td style="padding: 0.75pt; width: 76%;" width="76%"> <p class="MsoNormal">string1 is NOT NULL and does exist</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 24%;" width="24%"> <p class="MsoNormal">-z string1</p> </td> <td style="padding: 0.75pt; width: 76%;" width="76%"> <p class="MsoNormal">string1 is NULL and does exist</p> </td> </tr> </tbody></table> </div> <p style="text-align: center;" align="center"><b>Shell also test for file and directory types</b></p> <div align="center"> <table class="MsoNormalTable" style="width: 63%;" width="63%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 19%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="19%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Test</b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 81%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="81%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Meaning</b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 19%;" width="19%"> <p class="MsoNormal">-s file </p> </td> <td style="padding: 0.75pt; width: 81%;" width="81%"> <p class="MsoNormal">Non empty file</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 19%;" width="19%"> <p class="MsoNormal">-f file </p> </td> <td style="padding: 0.75pt; width: 81%;" width="81%"> <p class="MsoNormal">Is File exist or normal file and not a directory </p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 19%;" width="19%"> <p class="MsoNormal">-d dir </p> </td> <td style="padding: 0.75pt; width: 81%;" width="81%"> <p class="MsoNormal">Is Directory exist and not a file</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 19%;" width="19%"> <p class="MsoNormal">-w file </p> </td> <td style="padding: 0.75pt; width: 81%;" width="81%"> <p class="MsoNormal">Is writeable file</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 19%;" width="19%"> <p class="MsoNormal">-r file </p> </td> <td style="padding: 0.75pt; width: 81%;" width="81%"> <p class="MsoNormal">Is read-only file</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 19%;" width="19%"> <p class="MsoNormal">-x file </p> </td> <td style="padding: 0.75pt; width: 81%;" width="81%"> <p class="MsoNormal">Is file is executable</p> </td> </tr> </tbody></table> </div> <p style="text-align: center;" align="center"><b>Logical Operators</b></p> <p>Logical operators are used to combine two or more condition at a time</p> <div align="center"> <table class="MsoNormalTable" style="width: 72%;" width="72%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="50%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Operator </b></p> </td> <td style="padding: 0.75pt; background: silver none repeat scroll 0% 0%; width: 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="50%"> <p class="MsoNormal" style="text-align: center;" align="center"><b>Meaning </b></p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">! expression</p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Logical NOT</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">expression1 -a expression2</p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Logical AND</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">expression1 -o expression2</p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Logical OR</p> </td> </tr> </tbody></table> </div> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">if...else...fi<o:p></o:p></span></h1> <p>If given condition is true then command1 is executed otherwise command2 is executed.
<br /><i>Syntax:</i></p> <pre><span style=""> </span>if condition</pre><pre><span style=""> </span>then</pre><pre><span style=""> </span>condition is zero (true - 0)</pre><pre><span style=""> </span>execute all commands up to else statement</pre><pre><o:p> </o:p></pre><pre><span style=""> </span>else</pre><pre><span style=""> </span>if condition is not true then</pre><pre><span style=""> </span>execute all commands up to fi</pre><pre><span style=""> </span>fi</pre> <p>For e.g. Write Script as follows:</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style="height: 198.75pt;"> <td style="padding: 0.75pt; height: 198.75pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$ vi isnump_n</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#!/bin/sh</code>
<br /> <code>#</code>
<br /> <code># Script to see whether argument is positive or negative</code>
<br /> <code>#</code>
<br /> <code>if [ $# -eq 0 ]</code>
<br /> <code>then</code>
<br /> <code>echo "$0 : You must give/supply one integers"</code>
<br /> <code>exit 1</code>
<br /> <code>fi</code></span> </p> <p>
<br /> <code><span style="font-size: 10pt;">if test $1 -gt 0</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>then</code>
<br /> <code>echo "$1 number is positive"</code>
<br /> <code>else</code>
<br /> <code>echo "$1 number is negative"</code>
<br /> <code>fi</code></span></p> </td> </tr> </tbody></table> <p>Try it as follows:
<br /><b>$ chmod 755 isnump_n
<br />
<br />$ isnump_n 5</b>
<br /><i>5 number is positive</i>
<br /><b>
<br />$ isnump_n -45 </b>
<br /><i>-45 number is negative</i>
<br /><b>
<br />$ isnump_n</b>
<br /><i>./ispos_n : You must give/supply one integers</i>
<br /><b>
<br />$ isnump_n 0</b>
<br /><i>0 number is negative</i></p> <p><b><i>Detailed explanation</i></b>
<br />First script checks whether command line argument is given or not, if not given then it print error message as "<i>./ispos_n : You must give/supply one integers</i>". if statement checks whether number of argument ($#) passed to script is not equal (-eq) to 0, if we passed any argument to script then this if statement is false and if no command line argument is given then this if statement is true. The echo command i.e.
<br />echo "$0 : You must give/supply one integers"
<br /> | |
<br /> | |
<br /> 1 2
<br />1 will print Name of script
<br />2 will print this error message
<br />And finally statement exit 1 causes normal program termination with exit status 1 (nonzero means script is not successfully run).</p> <p>The last sample run<b> $ isnump_n 0</b> , gives output as "<i>0 number is negative</i>", because given argument is not > 0, hence condition is false and it's taken as negative number. To avoid this replace second if statement with <b>if test $1 -ge 0</b>.</p> <h1><!--[if gte vml 1]><v:shape id="_x0000_i1033" type="#_x0000_t75" alt="" style="'width:6.75pt;height:9.75pt'"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image006.gif" href="http://www.freeos.com/guides/lsst/images/bulb.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image006.gif" shapes="_x0000_i1033" width="9" border="0" height="13" /><!--[endif]--><span style="font-size: 16pt;">Nested if-else-fi</span></h1> <p>You can write the entire if-else construct within either the body of the if statement of the body of an else statement. This is called the nesting of ifs.</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p><code><span style="font-size: 10pt;">$ vi nestedif.sh</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>osch=0</code>
<br />
<br /> <code>echo "1. Unix (Sun Os)"</code>
<br /> <code>echo "2. Linux (Red Hat)"</code>
<br /> <code>echo -n "Select your os choice [1 or 2]? "</code>
<br /> <code>read osch</code>
<br />
<br /> <code>if [ $osch -eq 1 ] ; then</code>
<br />
<br /> <code> echo "You Pick up Unix (Sun Os)"</code>
<br />
<br /> <code>else #### nested if i.e. if within if ######</code>
<br /> <code> </code>
<br /> <code> if [ $osch -eq 2 ] ; then</code>
<br /> <code> echo "You Pick up Linux (Red Hat)"</code>
<br /> <code> else</code>
<br /> <code> echo "What you don't like Unix/Linux OS."</code>
<br /> <code> fi</code>
<br /> <code>fi</code></span></p> </td> </tr> </tbody></table> <p>Run the above shell script as follows:
<br /><b>$ chmod +x nestedif.sh
<br />$ ./nestedif.sh</b>
<br /><i>1. Unix (Sun Os)
<br />2. Linux (Red Hat)
<br />Select you os choice [1 or 2]? <b>1</b>
<br />You Pick up Unix (Sun Os)</i></p> <p><b>$ ./nestedif.sh</b>
<br /><i>1. Unix (Sun Os)
<br />2. Linux (Red Hat)
<br />Select you os choice [1 or 2]? <b>2</b>
<br />You Pick up Linux (Red Hat)</i></p> <p><b>$ ./nestedif.sh</b>
<br /><i>1. Unix (Sun Os)
<br />2. Linux (Red Hat)
<br />Select you os choice [1 or 2]? <b>3</b>
<br />What you don't like Unix/Linux OS.</i></p> <p>Note that Second <i>if-else</i> constuct is nested in the first <i>else</i> statement. If the condition in the first <i>if</i> statement is false the the condition in the second <i>if</i> statement is checked. If it is false as well the final <i>else</i> statement is executed.</p> <p>You can use the nested <i>if</i>s as follows also:
<br /><i>Syntax:</i></p> <pre><span style=""> </span>if condition</pre><pre><span style=""> </span>then</pre><pre><span style=""> </span>if condition</pre><pre><span style=""> </span>then</pre><pre><span style=""> </span>.....</pre><pre><span style=""> </span>..</pre><pre><span style=""> </span>do this</pre><pre><span style=""> </span>else</pre><pre><span style=""> </span>....</pre><pre><span style=""> </span>..</pre><pre><span style=""> </span>do this</pre><pre><span style=""> </span>fi</pre><pre><span style=""> </span>else</pre><pre><span style=""> </span>...</pre><pre><span style=""> </span>.....</pre><pre><span style=""> </span>do this</pre><pre><span style=""> </span>fi</pre> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">Multilevel if-then-else<o:p></o:p></span></h1> <p class="MsoNormal"><i>Syntax:</i></p> <pre><span style=""> </span>if condition</pre><pre><span style=""> </span>then</pre><pre><span style=""> </span>condition is zero (true - 0)</pre><pre><span style=""> </span>execute all commands up to elif statement</pre><pre><span style=""> </span>elif condition1
<br /><span style=""> </span>then</pre><pre><span style=""> </span>condition1 is zero (true - 0)</pre><pre><span style=""> </span>execute all commands up to elif statement<span style=""> </span></pre><pre><span style=""> </span>elif condition2</pre><pre><span style=""> </span>then</pre><pre><span style=""> </span>condition2 is zero (true - 0)</pre><pre><span style=""> </span>execute all commands up to elif statement<span style=""> </span></pre><pre><span style=""> </span>else</pre><pre><span style=""> </span>None of the above condtion,condtion1,condtion2 are true (i.e. </pre><pre><span style=""> </span>all of the above nonzero or false)</pre><pre><span style=""> </span>execute all commands up to fi</pre><pre><span style=""> </span>fi</pre> <p>For multilevel if-then-else statement try the following script:</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style="height: 120.75pt;"> <td style="padding: 0.75pt; height: 120.75pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$ cat > elf</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#</code>
<br /> <code>#!/bin/sh</code>
<br /> <code># Script to test if..elif...else</code>
<br /> <code>#</code>
<br /> <code>if [ $1 -gt 0 ]; then</code>
<br /> <code> echo "$1 is positive"</code>
<br /> <code>elif [ $1 -lt 0 ]</code>
<br /> <code>then</code>
<br /> <code> echo "$1 is negative"</code>
<br /> <code>elif [ $1 -eq 0 ]</code>
<br /> <code>then</code>
<br /> <code> echo "$1 is zero"</code>
<br /> <code>else</code>
<br /> <code> echo "Opps! $1 is not number, give number"</code>
<br /> <code>fi</code></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">Loops in Shell Scripts<o:p></o:p></span></h1> <p><st1:place st="on">Loop</st1:place> defined as:
<br />"<i>Computer can repeat particular instruction again and again, until particular condition satisfies. A group of instruction that is executed repeatedly is called a loop.</i>"</p> <p>Bash supports:</p> <ul type="disc"><li class="MsoNormal" style="">for loop </li><li class="MsoNormal" style="">while loop</li></ul> <p><b>Note </b>that in each and every loop,</p> <p>(a) First, the variable used in loop condition must be initialized, then execution of the loop begins.</p> <p>(b) A test (condition) is made at the beginning of each iteration.</p> <p>(c) The body of loop ends with a statement that modifies the value of the test (condition) variable.</p> <h1>for <st1:place st="on">Loop</st1:place></h1> <p class="MsoNormal"><i>Syntax:<o:p></o:p></i></p> <pre><i><span style=""> </span>for { variable name } in { list }<o:p></o:p></i></pre><pre><i><span style=""> </span>do<o:p></o:p></i></pre><pre><i><span style=""> </span>execute one for each item in the list until the list is<o:p></o:p></i></pre><pre><i><span style=""> </span>not finished (And repeat all statement between do and done)<o:p></o:p></i></pre><pre><i><span style=""> </span><span style=""> </span>done<o:p></o:p></i></pre> <p>Before try to understand above syntax try the following script:</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style="height: 51.75pt;"> <td style="padding: 0.75pt; height: 51.75pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$ cat > testfor</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>for i in 1 2 3 4 5</code>
<br /> <code>do</code>
<br /> <code>echo "Welcome $i times"</code>
<br /> <code>done</code></span></p> </td> </tr> </tbody></table> <p><o:p> </o:p></p> <h1><span style="font-size: 16pt;">while loop<o:p></o:p></span></h1> <p><i>Syntax:<o:p></o:p></i></p> <pre><i><span style=""> </span>while [ condition ]<o:p></o:p></i></pre><pre><i><span style=""> </span>do<o:p></o:p></i></pre><pre><i><span style=""> </span>command1<o:p></o:p></i></pre><pre><i><span style=""> </span>command2<o:p></o:p></i></pre><pre><i><span style=""> </span>command3<o:p></o:p></i></pre><pre><i><span style=""> </span>..<o:p></o:p></i></pre><pre><i><span style=""> </span>....<o:p></o:p></i></pre><pre><i><span style=""> </span>done<o:p></o:p></i></pre> <p><st1:place st="on">Loop</st1:place> is executed as long as given condition is true. For e.g.. <a href="http://www.freeos.com/guides/lsst/ch03sec06.html#forloopprog">Above for loop program</a> (shown in last section of for loop) can be written using while loop as:</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$cat > nt1</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#!/bin/sh</code>
<br /> <code>#</code>
<br /> <code>#Script to test while statement</code>
<br /> <code>#</code>
<br /> <code>#</code>
<br /> <code>if [ $# -eq 0 ]</code>
<br /> <code>then</code>
<br /> <code> echo "Error - Number missing form command line argument"</code>
<br /> <code> echo "Syntax : $0 number"</code>
<br /> <code> echo " Use to print multiplication table for given number"</code>
<br /> <code>exit 1</code>
<br /> <code>fi</code>
<br /> <code>n=$1</code>
<br /> <code>i=1</code>
<br /> <code>while [ $i -le 10 ]</code>
<br /> <code>do</code>
<br /> <code> echo "$n * $i = `expr $i \* $n`"</code>
<br /> <code> i=`expr $i + 1`</code>
<br /> <code>done</code></span></p> </td> </tr> </tbody></table> <p>Save it and try as
<br /><b>$ chmod 755 nt1
<br />$./nt1 7
<br /></b>Above loop can be explained as follows:</p> <p> </p> <table class="MsoNormalTable" style="width: 100%;" width="100%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">n=$1</p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Set the value of command line argument to variable n. (Here it's set to 7 )</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">i=1</p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Set variable i to 1</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">while [ $i -le 10 ] </p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">This is our loop condition, here if value of i is less than 10 then, shell execute all statements between do and done</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">do </p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Start loop</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">echo "$n * $i = `expr $i \* $n`"</p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Print multiplication table as
<br /> 7 * 1 = 7
<br /> 7 * 2 = 14
<br /> ....
<br /> 7 * 10 = 70, Here each time value of variable n is multiply be i.</p> </td> </tr> <tr> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">i=`expr $i + 1`</p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">Increment i by 1 and store result to i. ( i.e. i=i+1)
<br /> <b><u><span style="color: red;">Caution:</span></u></b> If you ignore (remove) this statement than our loop become infinite loop because value of variable i always remain less than 10 and program will only output
<br /> 7 * 1 = 7
<br /> ...
<br /> ...
<br /> E (infinite times)</p> </td> </tr> <tr style=""> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p class="MsoNormal">done </p> </td> <td style="padding: 0.75pt; width: 50%;" width="50%"> <p><st1:place st="on">Loop</st1:place> stops here if i is not less than 10 i.e. condition of loop is not true. Hence
<br /> loop is terminated.</p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">The case Statement<o:p></o:p></span></h1> <p class="MsoNormal">The case statement is good alternative to Multilevel if-then-else-fi statement. It enable you to match several values against one variable. Its easier to read and write.
<br /><i>Syntax:<o:p></o:p></i></p> <pre><i><span style=""> </span>case<span style=""> </span>$variable-name<span style=""> </span>in<o:p></o:p></i></pre><pre><i><span style=""> </span>pattern1)<span style=""> </span>command<o:p></o:p></i></pre><pre><i><span style=""> </span>...<o:p></o:p></i></pre><pre><i><span style=""> </span>..<o:p></o:p></i></pre><pre><i><span style=""> </span>command;;<o:p></o:p></i></pre><pre><i><span style=""> </span>pattern2)<span style=""> </span>command<o:p></o:p></i></pre><pre><i><span style=""> </span><span style=""> </span>...<o:p></o:p></i></pre><pre><i><span style=""> </span>..<o:p></o:p></i></pre><pre><i><span style=""> </span>command;;<o:p></o:p></i></pre><pre><i><span style=""> </span>patternN)<span style=""> </span>command<o:p></o:p></i></pre><pre><i><span style=""> </span>...<o:p></o:p></i></pre><pre><i><span style=""> </span>..<o:p></o:p></i></pre><pre><i><span style=""> </span>command;;<o:p></o:p></i></pre><pre><i><span style=""> </span>*)<span style=""> </span>command<o:p></o:p></i></pre><pre><i><span style=""> </span>...<o:p></o:p></i></pre><pre><i><span style=""> </span>..<o:p></o:p></i></pre><pre><i><span style=""> </span>command;;<o:p></o:p></i></pre><pre><i><span style=""> </span>esac<o:p></o:p></i></pre> <p>The<i> $variable-name</i> is compared against the patterns until a match is found. The shell then executes all the statements up to the two semicolons that are next to each other. The default is *) and its executed if no match is found. For e.g. write script as follows:</p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal"><code><span style="font-size: 10pt;">$ cat > car</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>#</code>
<br /> <code># if no vehicle name is given</code>
<br /> <code># i.e. -z $1 is defined and it is NULL</code>
<br /> <code>#</code>
<br /> <code># if no command line arg</code></span> </p> <p><code><span style="font-size: 10pt;">if [ -z $1 ]</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code>then</code>
<br /> <code> rental="*** Unknown vehicle ***"</code>
<br /> <code>elif [ -n $1 ]</code>
<br /> <code>then</code>
<br /> <code># otherwise make first arg as rental</code>
<br /> <code> rental=$1</code>
<br /> <code>fi</code></span></p> <p><code><span style="font-size: 10pt;">case $rental in</span></code><span style="font-size: 10pt; font-family: "Courier New";">
<br /> <code> "car") echo "For $rental Rs.20 per k/m";;</code>
<br /> <code> "van") echo "For $rental Rs.10 per k/m";;</code>
<br /> <code> "jeep") echo "For $rental Rs.5 per k/m";;</code>
<br /> <code> "bicycle") echo "For $rental 20 paisa per k/m";;</code>
<br /> <code> *) echo "Sorry, I can not gat a $rental for you";;</code>
<br /> <code>esac</code></span></p> </td> </tr> </tbody></table> <p>Save it by pressing CTRL+D<i> </i>and run it as follows:<i>
<br /></i><b>$ chmod +x car
<br />$ car van
<br />$ car car
<br />$ car Maruti-800</b></p> <p>First script will check, that if $1(first command line argument) is given or not, if NOT given set value of rental variable to "*** Unknown vehicle ***",if command line arg is supplied/given set value of rental variable to given value (command line arg). The $rental is compared against the patterns until a match is found.
<br />For first test run its match with van and it will show output "<i>For van Rs.10 per k/m.</i>"
<br />For second test run it print, "<i>For car Rs.20 per k/m</i>".
<br />And for last run, there is no match for Maruti-800, hence default i.e. *) is executed and it prints, "<i>Sorry, I can not gat a Maruti-800 for you</i>".
<br /><b>Note</b> that esac is always required to indicate end of case statement.</p> <h1><span style="font-size: 16pt;">How to de-bug the shell script?<o:p></o:p></span></h1> <p>While programming shell sometimes you need to find the errors (bugs) in shell script and correct the errors (remove errors - debug). For this purpose you can use -v and -x option with sh or bash command to debug the shell script. General syntax is as follows:
<br /><i>Syntax:</i>
<br />sh option { shell-script-name }
<br /><b>OR</b>
<br />bash option { shell-script-name }
<br />Option can be
<br /><b>-v </b>Print shell input lines as they are read.
<br /><b>-x </b>After expanding each simple-command, bash displays the expanded value of PS4 system variable, followed by the command and its expanded arguments.</p> <p><i>Example:</i></p> <table class="MsoNormalTable" style="background: rgb(204, 204, 204) none repeat scroll 0% 0%; width: 100%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="100%" border="0" cellpadding="0" cellspacing="1"> <tbody><tr style="height: 91.5pt;"> <td style="padding: 0.75pt; height: 91.5pt;"> <p class="MsoNormal">$ cat > dsh1.sh
<br /> #
<br /> # Script to show debug of shell
<br /> #
<br /> tot=`expr $1 + $2`
<br /> echo $tot</p> </td> </tr> </tbody></table> <p>Press ctrl + d to save, and run it as
<br /><b>$ chmod 755 dsh1.sh
<br />$ ./dsh1.sh 4 5</b>
<br /><i>9</i>
<br /><b>$ sh -x dsh1.sh 4 5</b>
<br /><i>#
<br /># Script to show debug of shell
<br />#
<br />tot=`expr $1 + $2`
<br />expr $1 + $2
<br />++ expr 4 + 5
<br />+ tot=9
<br />echo $tot
<br />+ echo 9
<br />9</i></p> <p>See the above output, -x shows the exact values of variables (or statements are shown on screen with values).</p> <p><b>$ sh -v dsh1.sh 4 5</b></p> <p>Use -v option to debug complex shell script.</p> <p class="MsoNormal"><o:p> </o:p></p> <h1><span style="font-size: 16pt;">/dev/null - Use to send unwanted output of program<o:p></o:p></span></h1> <p class="MsoNormal">This is special Linux file which is used to send any unwanted output from program/command.
<br /><i>Syntax:</i>
<br />command > /dev/null </p> <p><i>Example:</i>
<br /><b>$ ls > /dev/null</b>
<br />Output of above command is not shown on screen its send to this special file. The /dev directory contains other device files. The files in this directory mostly represent peripheral devices such disks like floppy disk, sound card, line printers etc. See the <a href="http://www.freeos.com/guides/lsst/appa.html" target="_blank"><span style="">file system tutorial</span></a> for more information on Linux disk, partition and file system.</p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-56231425352383256572008-08-06T02:42:00.001-07:002008-12-23T00:12:05.690-08:00BASIC UNIX COMMANDS COMMANDSCommands are what you type at the prompt. Com-<br />mands have arguments on which they operate. For<br />example, in rm temp, the command is rm and the ar-<br />gument is temp; this command removes the le called<br />temp. Here I put arguments in UPPER CASE. Thus,<br />words such as FILE are taken to stand for some other<br />word, such as temp. In the following list, I use [ ] for<br />optional arguments that are not typicaly used.<br />Commands have options that are controlled with<br />switches, which are usually letters following a single<br />dash. Usually you can write several letters after one<br />dash. For example ls -l lists les in a long format,<br />with more information. ls -a lists all the les, in-<br />cluding those that begin with ., which are usually<br /> les used by various programs. ls -al lists all the<br /> les in the long format. The following list omits most<br />options. Many programs will give you a list of their<br />options if you type the name of the program followed<br />by -h or -?.<br />Other options are controlled in special les usu-<br />ally beginning with ., such as .emacs, .mailrc, and<br />.newsrc. You can edit these. The le .cshrc con-<br />tains general options, plus aliases that you make up<br />for commands you use often.<br />|, the pipe symbol, takes the output of one command<br />and gives it to the second command as input, for<br />example, ls -l | more allows you to view a long<br /> le list through \more".<br />> directs the output to a le, e.g., ls -l ><br />listing.tmp puts the listing into a le named list-<br />ing.tmp. > overwrites an old le of the same name.<br />>> appends to a le.<br />* stands for any string of letters. For example, ls t*<br />lists all the les beginning with t.<br />" recalls previous commands, and you can edit these<br />commands using emacs editing.<br />The tab key completes commands if you type the rst<br />few letters.<br />ctrl-z suspends most programs. fg resumes. ctrl-c<br />stops most programs.<br />alias abbreviates a series of commands, separated<br />by semicolons. Useful in .cshrc.<br />GETTING HELP<br />apropos KEYWORD: Looks for commands related to<br />KEYWORD.<br />man COMMAND: Shows manual pages on COMMAND.<br />This is the authoritative source on the items de-<br />scribed here. The commands can do much more<br />than is listed here.<br />whatis COMMAND: Tells what COMMAND does.<br />FILES AND DIRECTORIES<br />All information is stored in les. File names and<br />commands are case sensitive. Case matters. Files<br />are contained in directories. You start out in your<br />own home directory, and your prompt usually tells<br />its name. At any given time, one of these directories<br />is your working directory, the one you are in.<br />You can refer to les in your working directory by<br />just their names. You can refer to a le that is in a<br />subdirectory by giving a subdirectory name, a slash,<br />and the le name, e.g., Mail/baron. You can refer to<br />any le on the computer by giving its full name, start-<br />ing with a slash, such as /home7/b/baron/mbox.<br />If the le is a program, typing its name will run it.<br />(That is what commands do.) If the program is some-<br />thing you have just written and is in the director you<br />are in, put ./ before the name. If the le is not a<br />program, typing its name will give you an error mes-<br />sage. If you want to see its contents, for example, you<br />must use a command such as \more" before the le<br />name.<br />ls [DIRECTORY]: Lists les. (Also try: ls -f, ls -s, ls<br />-a.)<br />rm FILE: Removes FILE.<br />more FILE or less FILE: View FILE. (? or h for<br />help.)<br />cd DIRECTORY: Change the directory you are in to<br />DIRECTORY.<br />cd: Change to your home directory.<br />cd ..: Change to the next directory up in the hier-<br />archy.<br />mkdir DIRECTORY: Make DIRECTORY.<br />rmdir DIRECTORY: Remove DIRECTORY.<br />rm -rf: Recursively remove a directory and anything<br />in it.<br />mv FILE1 FILE2: Moves or renames FILE1 to<br />FILE2.<br />cp FILE1 FILE2: Makes a copy of FILE1, called<br />FILE2.<br />cat FILE1 FILE2 > FILE3: Concatenate FILE1<br />and FILE2, calling the result FILE3.<br />chmod 644 FILE: Unprotect FILE for others to read<br />or copy.<br />chmod 755 FILE: Unprotect program or \script."<br />chmod 755 DIRECTORY: Unprotect DIRECTORY,<br />needed for web page directories.<br />head and tail: Print the top and bottom of a text<br /> le.<br />TEXT FILE MANIPULATION<br />These commands operate on les. The output goes<br />to the \standard output," which is your terminal dis-<br />play. If you want to \redirect" the output to a le,<br />use > FILENAME at the end of the command (with<br />FILENAME being the name of the le). Use >> instead<br />of > if you want to append to the le rather than<br />write it from scratch.<br />diff: Find the di erences between two text les.<br />grep LETTER-STRING FILE1 [> FILE2]: Prints (or<br />puts in FILE2) all lines of FILE1 that contain<br />LETTER-STRING. Use the -v switch to get lines<br />not containing the string.<br />sed s/STRING1/STRING2/g: replace STRING1 with<br />STRING2 throughout a le. See also the y switch<br />for replacing characters.<br />cut -d" " -f2 FILE: Extract the second column<br />from a le, where the columns are delimited by<br />spaces. Use paste to put such cuttings back to-<br />gether.<br />sort FILE: Sort the lines alphabetically.<br />uniq FILE: Remove adjacent duplicate lines. Typi-<br />cally used with the output of sort, e.g., sort FILE<br />| uniq. Use the -c to count the number of ad-<br />jacent examples of each line.<br />wc FILE: Count characters, words, and lines.<br />WHAT'S GOING ON?<br />w [USER]: Who is using the computer. This is useful<br />to see whether you are logged on twice. (See ps and<br />kill, below, in case this happens.) Also try who and<br />finger.<br />finger USER: Gives information about the user, in-<br />cluding the les .project and .plan, if you have<br />these les. You can sometimes use this for people<br />on other computers. You can keep useful infor-<br />mation in your .plan, such as your schedule, your<br />phone number, etc.<br />quota -v: Tells you how much of your quota for les<br />is used up.<br />ps -fu USERNAME: Lists the processes that you are<br />running, if you put in your username. You can use<br />this to nd the number of processes that you want<br />to kill, such as those left over when you did not<br />log out properly. It is the rst number listed.<br />kill PROCESS-NUMBER: Kills the process you don't<br />want. If this doesn't work, try kill -9<br />PROCESS-NUMBER.<br />last -22: Shows you the last 22 users who logged<br />in.<br />THE INTERNET<br />mutt and elm: Read and write electronic mail. Each<br />has its own \help". See the discussion of these in<br />the psychology web page computer section.<br />slrn and tin: Read news (and respond to postings).<br />Pnews: Post to newsgroups. (You can<br />also say mutt psych-general@psych or<br />elm psych-general@psych to post to<br />upenn.psych.general.)<br />lynx [URL]: Reads web pages as text les.<br />ssh HOST: Connects to a remote computer.<br />talk USERNAME: Allows you to talk with someone<br />logged on. The full username must be speci ed<br />for remote computers, and you must use ntalk<br />instead of talk. It is not a good idea to use this<br />casually unless you know that the other person will<br />not be annoyed.<br />TRANSFERRING FILES<br />Many computers on the internet have ftp or ssh, but<br />all of the programs for transferring les depend on<br />having the relevant software on both computers.<br />ftp and scp: Fast way of uploading and down-<br />loading, or moving any le from one com-<br />puter to another. For example, scp myfile<br />baron@psych.upenn.edu: - you need the colon<br />at the end.<br />rsync: synchronize les or directories on two di er-<br />ent computers. Good for backing up.<br />EDITING<br />pico FILE or emacs FILE xemacs FILE or vi FILE:<br />Edit FILE. One of these editors may be speci ed<br />as the default for mailing and news programs. Pico<br />is easiest because it has all the commands listed at<br />the bottom of the screen, but it is the least useful<br />because it has few commands.<br />COMPRESSING, ENCRYPTING, and SE-<br />CURITY<br />tar cvf FILE.tar and tar xvf FILE.tar: Create<br />and extract an archive le. Useful for backing up<br />directories. On Linux xvfz will extract and unzip<br />in one step.<br />gzip FILE: Reduce the size of les for storage. use<br />gunzip FILE to unzip them. Files \zipped" with<br />gzip have the su x .gz.<br />crypt <> FILE2: Encrypts or decodes<br /> le1 so that you need a password to read it. But if<br />you want to be absolutely sure beyond any doubt<br />that nobody will read your les, do not leave them<br />on cattell.<br />antiword FILE1 > FILE2: Decodes a Word le<br />into text. (That is all most of them are.) Save<br />storage space. You can use this with Mutt or Elm<br />to read doc les sent in email messages.<br />passwd: Change your password.<br />Jon Baron, September, 2003Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-28098571009496916682008-08-06T02:41:00.001-07:002008-12-23T00:12:05.690-08:00commandswho > filename command who will give results and (>) will redirect the standar output to "filename"<br />wc -l filename (wc) wordcount will count how many lines in the file<br />sort < filename will sort the contain of a filename and display them on screen<br />sort < filename1 > filename2 will sort the contain of a filename1 and store them in filename2<br /><br />set -o vi to use the vi editor temporarily<br />set +o vi to turn off the vi editing mode<br />vi filename start using vi in a file<br />history -3 to display the last 3 command<br /><br />echo "Hai" will display 'Hai'<br />nama1="yudhi" assigning 'yudhi' into variabel 'nama1'<br />nama1=${nama2} the contain of nama1 will be assigned to variabel nama2<br />echo $nama1 will display the contain of variabel nama1<br />expr 1+2 the output will be 3<br />expr $angka1 + 3 will added the contain of variabel 'angka1' to 3<br /><br />UNIX SCRIPT ON CA DAILY ACTIVITY <br /><br />ftp [servername] file transfer protocol , to GET [filename] or MGET [files] from other server to local server. End session with BYE<br />file [filename] to know the specification of current file<br />ln to make a link from a file in other directory so it can be executed from current directory (SEE MANUAL)<br />remsh to access other server (remote access) and do specific action in the target server (SEE MANUAL)<br />rcp to run 'cp' from remote server of a file in other server (SEE MANUAL)<br />cmviewcl -v to display the status of nodes and package (SEE MANUAL)<br />bdf to display the space status of current server<br />cmmodpkg -d/-e -n [node] -v [package] to disable/enable the status of current node (SEE MANUAL) Run the command in current server !<br />cmrunpkg to run/down the status of current package (SEE MANUAL)<br />cmhaltpkg to halt/stop the status of current package (SEE MANUAL)<br />haltapp to reset/stop all the running application on CA server. Run the command from /etc in ivMAC<br />startapp to run all the stopping application on CA server. Run the command from /etc in ivMAC<br />at -f [file] -t [yymmddhhmm] to schedule files to be executed on specific time<br />sed -e 's/[char1]/[char2]/g' [file1] stream editor : replace every 'char1' with 'char2' in 'file1'Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-15890909775546250552008-08-06T02:38:00.000-07:002008-12-23T00:12:05.690-08:00Telnet commands<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_filelist.xml"><title>Oracle Certification Program Candidate Guide</title><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>misebast</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????¡ì??????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Trebuchet MS"; panose-1:2 11 6 3 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:647 0 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {color:#0000A0; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:#606420; text-decoration:underline; text-underline:single;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal" style=""><span style="font-size: 14pt; font-family: "Trebuchet MS"; color: rgb(204, 51, 51);">
<br /><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 99%;" width="99%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 1.5pt;" valign="top"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> telnet</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> [<b>-8ELadr</b>] [<b>-S</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">tos</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">] [<b>-e</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">escapechar</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">] [<b>-l</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">user</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">] [<b>-n</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">tracefile</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">] [</span><i><span style="font-size: 10pt; font-family: Arial; color: black;">host </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">[</span><i><span style="font-size: 10pt; font-family: Arial; color: black;">port</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">]]
<br />
<br /> <b>
<br /> DESCRIPTION</b><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">The <b>telnet</b> command is used for interactive communication with another host using the TELNET protocol. It begins in command mode, where it prints a telnet prompt ("telnet> "). If <b>telnet</b> is invoked with a host argument, it performs an <b>open</b> command implicitly; see the description below.
<br />
<br /> </span><b><span style="font-size: 10pt; font-family: Arial; color: rgb(204, 51, 51);">OPTIONS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <table class="MsoNormalTable" style="" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-8</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Request 8-bit operation. This causes an attempt to negotiate the TELNET BINARY option for both input and output. By default Telnet is not 8-bit clean.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-E</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Disables the Escape character functionality; sets the Escape character to ``no character''.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-L</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Specifies an 8-bit data path on output. This causes the TELNET BINARY option to be negotiated on just output.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-a</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Attempt automatic login. This sends the user name via the USER variable of the ENVIRON option if supported by the remote system. The username is retrieved via getlogin(3).<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-d</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Sets the initial value of the <b>debug</b> toggle to TRUE.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-r</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Emulate rlogin(1). In this mode, the default escape character is a tilde. The interpretation of the escape character is changed: an escape character followed by a dot causes <b>telnet</b> to disconnect from the remote host. A ^Z instead of a dot suspends <b>telnet</b>, and a ^] (the default <b>telnet</b> escape character) generates a normal telnet prompt. These codes are accepted only at the beginning of a line.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-S</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i><span style="font-size: 10pt; font-family: Arial; color: black;">tos :</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> Sets the IP type of service (TOS) option for the telnet connection to the value </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">tos</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-e</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i><span style="font-size: 10pt; font-family: Arial; color: black;">escapechar </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">: Sets the escape character to </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">escapechar.</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> If no character is supplied, no escape character will be used. Entering the escape character while connected causes telnet to drop to command mode.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-l</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i><span style="font-size: 10pt; font-family: Arial; color: black;">user : </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">Specify </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">user</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> as the user to log in as on the remote system. This is accomplished by sending the specified name as the USER environment variable, so it requires that the remote system supports the TELNET ENVIRON option. This option implies the <b>-a</b> option, and may also be used with the <b>open</b> command.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt; width: 26.25pt;" valign="top" width="35"> <p class="MsoNormal" style="text-align: right;" align="right"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-n</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><i><span style="font-size: 10pt; font-family: Arial; color: black;">tracefile : </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">When LINEMODE is enabled, character processing is done on the local system, under the control of the remote system. When input editing or character echoing is to be disabled, the remote system will relay that information. The remote system will also relay changes to any special characters that happen on the remote system, so that they can take effect on the local system. In ``character at a time'' mode, most text typed is immediately sent to the remote host for processing. <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">In ``old line by line'' mode, all text is echoed locally, and only completed lines are sent to the remote host. The ``local echo character'' (initially ``^E'') may be used to turn off and on the local echo (this would mostly be used to enter passwords without the password being echoed). If the LINEMODE option is enabled, or if the <b>localchars</b> toggle is TRUE (the default for ``old line by line``), the user's <b>quit</b>, <b>intr</b>, and <b>flush</b> characters are trapped locally, and sent as TELNET protocol sequences to the remote side. If LINEMODE has ever been enabled, then the user's <b>susp</b> and <b>eof</b> are also sent as TELNET protocol sequences, and <b>quit</b> is sent as a TELNET ABORT instead of BREAK. There are options (see <b>toggle</b> <b>autoflush</b> and <b>toggle</b> <b>autosynch</b>) which cause this action to flush subsequent output to the terminal (until the remote host acknowledges the TELNET sequence) and flush previous terminal input (in the case of <b>quit</b> and <b>intr</b>).<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: rgb(204, 51, 51);">TELNET COMMANDS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> The following <b>telnet</b> commands are available. Unique prefixes are understood as abbreviations.
<br />
<br /> <b>auth</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">argument</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">...</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> The <b>auth</b> command controls the TELNET AUTHENTICATE protocol option. If <b>telnet</b> was compiled without authentication, the <b>auth</b> command will not be supported. <o:p></o:p></span></p> <p class="MsoNormal" style=""><i><span style="font-size: 10pt; font-family: Arial; color: black;">Valid arguments are:</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">disable</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">type</span></i><i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">Disable the specified type of authentication. To obtain a list of available types, use the <b>auth</b> <b>disable</b> <b>?</b> command.
<br />
<br /> <b>enable</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">type</span></i><i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">Enable the specified type of authentication. To obtain a list of available types, use the <b>authenable</b> <b>?</b> command. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">status
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">List the current status of the various types of authentication. <o:p></o:p></span></p> <p class="MsoNormal" style=""><i><span style="font-size: 10pt; font-family: Arial; color: black;">Valid arguments are:</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">disable</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">type</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> <b>[input|output]</b>
<br /> Disable the specified type of encryption. If you do not specify input or output, encryption of both is disabled. To obtain a list of available types, use ``encrypt disable ?''.
<br />
<br /> <b>enable</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">type</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> <b>[input|output]</b>
<br /> Enable the specified type of encryption. If you do not specify input or output, encryption of both is enabled. To obtain a list of available types, use ``encrypt enable ?''. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">input</span></b><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> This is the same as ``encrypt start input''.
<br />
<br /> <b>-input</b>
<br /> This is the same as ``encrypt stop input''.
<br />
<br /> <b>output
<br /> </b>This is the same as ``encrypt start output''.
<br />
<br /> <b>-output
<br /> </b>This is the same as ``encrypt stop output''.
<br />
<br /> <b>start</b> <b>[input|output]
<br /> </b> Attempt to begin encrypting. If you do not specify input or output, encryption of both input and output is started.
<br />
<br /> <b>status
<br /> </b>Display the current status of the encryption module.
<br />
<br /> <b>stop</b> <b>[input|output]</b>
<br /> Stop encrypting. If you do not specify input or output, encryption of both is stopped.
<br />
<br /> <b>type</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">type</span></i><i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">Sets the default type of encryption to be used with later ``encrypt start'' or ``encrypt stop'' commands. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">environ</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">arguments...</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> The <b>environ</b> command is used to propagate environment variables across the <b>telnet</b> link using the TELNET ENVIRON protocol option. All variables exported from the shell are defined, but only the DISPLAY and PRINTER variables are marked to be sent by default. The USER variable is marked to be sent if the <b>-a</b> or <b>-l</b> command line options were used.
<br />
<br /> <i>Valid arguments are:</i> <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">define</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">variable</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">value</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> <b>unexport</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">variable</span></i><i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">Do not mark the specified variable for propagation to the remote host. The remote host may still ask for variables that are not exported.
<br />
<br /> <b>list
<br /> </b>List the current set of environment variables. Those marked with a <b>*</b> will be propagated to the remote host. The remote host may still ask for the rest.
<br />
<br /> <b>?
<br /> </b>Prints out help information for the <b>environ</b> command. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">logout</span></b><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Send the TELNET LOGOUT protocol option to the remote host. This command is similar to a <b>close</b> command. If the remote host does not support the LOGOUT option, nothing happens. But if it does, this command should cause it to close the connection. If the remote side also supports the concept of suspending a user's session for later reattachment, the logout command indicates that the session should be terminated immediately.
<br />
<br /> <b>mode</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">type</span></i><i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> </span></i><i><span style="font-size: 10pt; font-family: Arial; color: black;">Type</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> is one of several options, depending on the state of the session. Telnet asks the remote host to go into the requested mode. If the remote host says it can, that mode takes effect. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">character
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">Disable the TELNET LINEMODE option, or if the remote side does not understand the LINEMODE option, then enter ``character at a time`` mode.
<br />
<br /> <b>line
<br /> </b>Enable the TELNET LINEMODE option, or if the remote side does not understand the LINEMODE op tion, then attempt to enter ``old-line-by-line`` mode.
<br />
<br /> <b>isig</b> (<b>-isig</b>)
<br /> Attempt to enable (disable) the TRAPSIG mode of the LINEMODE option. This requires that the LINEMODE option be enabled.
<br />
<br /> <b>edit</b> (<b>-edit</b>)
<br /> Attempt to enable (disable) the EDIT mode of the LINEMODE option. This requires that the LINEMODE option be enabled.
<br />
<br /> <b>softtabs</b> (<b>-softtabs</b>)
<br /> Attempt to enable (disable) the SOFT_TAB mode of the LINEMODE option This requires that the LINEMODE option be enabled.
<br />
<br /> <b>litecho</b> (<b>-litecho</b>)
<br /> Attempt to enable (disable) the LIT_ECHO mode of the LINEMODE option. This requires that the LINEMODE option be enabled. It is possible to connect to services that do not support the telnet protocol without creating problems. Protocol negotiation can be forced by placing a dash before the port number. After establishing a connection, any commands associated with the remote host in the user's </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">.telnetrc</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> file are executed. The format of the .telnetrc file is as follows: Lines beginning with a #, and blank lines, are ignored. The rest of the file should consist of hostnames and sequences of <b>telnet</b> commands to use with that host. Commands should be one per line, indented by whitespace lines beginning without whitespace are interpreted as hostnames. Upon connecting to a particular host, the commands associated with hat host are executed. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">quit
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">Close any open session and exit <b>telnet</b>. An end of file condition on input, when in command mode, will trigger this operation as well.
<br />
<br /> <b>send</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">arguments</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Send one or more special telnet protocol character sequences to the remote host. The following are the codes which may be specified (more than one may be used in one command): <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">abort
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">Sends the TELNET ABORT (Abort Processes) sequence.
<br />
<br /> <b>ao
<br /> </b>Sends the TELNET AO (Abort Output) sequence, which should cause the remote system to flush all output from the remote system </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">to</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> the user's terminal.
<br />
<br /> <b>ayt
<br /> </b>Sends the TELNET AYT (Are You There?) sequence, to which the remote system may or may not choose to respond.
<br />
<br /> <b>brk
<br /> </b>Sends the TELNET BRK (Break) sequence, which may have significance to the remote system.
<br />
<br /> <b>ec
<br /> </b>Sends the TELNET EC (Erase Character) sequence, which should cause the remote system to erase the last character entered.
<br />
<br /> <b>el
<br /> </b>Sends the TELNET EL (Erase Line) sequence, which should cause the remote system to erase the line currently being entered.
<br />
<br /> <b>eof
<br /> </b>Sends the TELNET EOF (End Of File) sequence.
<br />
<br /> <b>eor
<br /> </b>Sends the TELNET EOR (End of Record) sequence.
<br />
<br /> <b>escape
<br /> </b>Sends the current <b>telnet</b> escape character.
<br />
<br /> <b>ga
<br /> </b>Sends the TELNET GA (Go Ahead) sequence, which likely <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">susp
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">Sends the TELNET SUSP (Suspend Process) sequence.
<br />
<br /> <b>synch
<br /> </b>Sends the TELNET SYNCH sequence. This sequence causes the remote system to discard all previously typed but not yet read input. This sequence is sent as TCP urgent data and if it doesn't work, a lower case ``r'' may be echoed on the terminal.
<br />
<br /> <b>do</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">cmd</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> <b>dont</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">cmd</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> <b>will</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">cmd</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> <b>wont</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">cmd</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Sends the TELNET DO </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">cmd</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> sequence. </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">Cmd</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> can be either a decimal number between 0 and 255, or a symbolic name for a specific TELNET command. C</span><i><span style="font-size: 10pt; font-family: Arial; color: black;">md</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> can also be either <b>help</b> or <b>?</b> to print out help information, including a list of known symbolic names.
<br />
<br /> <b>?
<br /> </b>Prints out help information for the <b>send</b> command. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">set</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">argument</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">value</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> <b>unset</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">argument</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">value</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> The <b>set</b> command will set any one of a number of <b>telnet</b> variables to a specific value or to TRUE. The special value <b>off</b> turns off the function associated with the variable. This is equivalent to using the <b>unset</b> command. The <b>unset</b> command will disable or set to FALSE any of the specified variables. The values of variables may be interrogated with the <b>display</b> command. The variables which may be set or unset, but not toggled, are listed here. In addition, any of the variables for the <b>toggle</b> command may be explicitly set or unset. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">ayt
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">If telnet is in localchars mode, or LINEMODE is enabled, and the status character is typed, a TELNET AYT sequence is sent to the remote host. The initial value for the "Are You There" character is the terminal's status character.
<br />
<br /> <b>echo
<br /> </b>This is the value (initially ``^E'') which, when in ``line by line'' mode, toggles between doing local echoing of entered characters for normal processing, and suppressing echoing of entered characters (f.e. a password).
<br />
<br /> <b>eof
<br /> </b>If <b>telnet</b> is operating in LINEMODE or ``old line by line'' mode, entering this character as the first character on a line will cause this character to be the end of file.
<br />
<br /> <b>flushoutput</b>
<br /> If <b>telnet</b> is in <b>localchars</b> mode and the <b>flushoutput</b> character is typed, a TELNET AO sequence is sent to the remote host. The initial value for the flush character is taken to be the terminal's <b>flush</b> character.
<br />
<br /> <b>forw1</b>
<br />
<br /> <b>forw2
<br /> </b>If TELNET is operating in LINEMODE, these are the characters that, when typed, cause partial lines to be forwarded to the remote system. The initial value for the forwarding characters are taken from the terminal's eol and eol2 characters.
<br />
<br /> <b>interrupt</b>
<br /> If <b>telnet</b> is in <b>localchars</b> mode and the <b>interrupt</b> character is typed, a TELNET IP sequence is sent to the remote host. The initial value for the interrupt character is taken to be the terminal's <b>intr</b> character.
<br />
<br /> <b>kill
<br /> </b>If <b>telnet</b> is in <b>localchars</b> mode and if <b>telnet</b> is operating in ``character at a time'' mode, then when this character is typed, a TELNET EL sequence is sent to the remote system. The initial value for the kill character is taken to be the terminal's <b>kill</b> character.
<br />
<br /> <b>lnext
<br /> </b>If <b>telnet</b> is operating in LINEMODE or ``old line by line`` mode, then this character is taken to be the terminal's <b>lnext</b> character. The initial value for the lnext character is taken to be the terminal's <b>lnext</b> character.
<br />
<br /> <b>quit
<br /> </b>If <b>telnet</b> is in <b>localchars</b> mode and the <b>quit</b> character is typed, a TELNET BRK sequence is sent to the remote host. The initial value for the quit character is taken to be the terminal's <b>quit</b> character.
<br />
<br /> <b>reprint</b>
<br /> If <b>telnet</b> is operating in LINEMODE or ``old line by line`` mode, then this character is taken to be the terminal's <b>reprint</b> character. The initial value for the reprint character is taken to be the terminal's <b>reprint</b> character.
<br />
<br /> <b>rlogin
<br /> </b>This is the rlogin mode escape character. Setting it enables rlogin mode, as with the </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">r</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> command-line option.
<br />
<br /> <b>susp
<br /> </b>If <b>telnet</b> is in <b>localchars</b> mode, or LINEMODE is enabled, and the <b>suspend</b> character is typed, a TELNET SUSP sequence is sent to the remote host. The initial value for the suspend character is taken to be the terminal's <b>suspend</b> character.
<br />
<br /> <b>tracefile</b>
<br /> This is the file to which the output, caused by <b>netdata</b> or <b>option</b> tracing being TRUE, will be written. If it is set to ``<b>-</b>'', then tracing information will be written to standard output.
<br />
<br /> <b>worderase</b>
<br /> If <b>telnet</b> is operating in LINEMODE or ``old line by line`` mode, then this character is taken to be the terminal's <b>worderase</b> character. The initial value for the worderase character is taken to be the terminal's <b>worderase</b> character.
<br />
<br /> <b>?
<br /> </b>Displays the legal <b>set</b> (<b>unset</b>) commands. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">slc</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">state</span></i><i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">The <b>slc</b> command (Set Local Characters) is used to set or change the state of the the special characters when the TELNET LINEMODE option has been enabled. Special characters are characters that get mapped to TELNET commands sequences (<b>ip</b> or <b>quit</b>) or line editing characters (<b>erase</b> and <b>kill</b>). By default, the local special characters are exported. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">check
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">Verify the current settings for the current special characters. The remote side is requested to send all the current special character settings, and if there are any discrepancies with the local side, the local side will switch to the remote value.
<br />
<br /> <b>export
<br /> </b>Switch to the local defaults for the special characters. The local default characters are those of the local terminal at the time when <b>telnet</b> was started.
<br />
<br /> <b>import
<br /> </b>Switch to the remote defaults for the special characters. The remote default characters are those of the remote system at the time when the TELNET connection was established.
<br />
<br /> <b>?
<br /> </b>Prints out help information for the <b>slc</b> command. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">status
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">Show the current status of <b>telnet</b>. This includes the name of the remote host, as well as the current mode.
<br />
<br /> <b>toggle</b> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">arguments</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">...</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Toggle (between TRUE and FALSE) various flags that control how system acknowledges (via a TELNET TIMING MARK option) that it has processed those TELNET sequences. The initial value for this toggle is TRUE if the terminal user had not done an "stty noflsh", otherwise FALSE (see stty(1)).<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">autodecrypt
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">When the TELNET ENCRYPT option is negotiated, by default the actual encryption (decryption) of the data stream does not start automatically. The autoencrypt (autodecrypt) command states that encryption of the output (input) stream should be enabled as soon as possible. This flag exists only if encryption support is enabled.
<br />
<br /> <b>autologin
<br /> </b>If the remote side supports the TELNET AUTHENTICATION option, telnet attempts to use it to perform automatic authentication. If the TELNET AUTHENTICATION option is not supported, the user's login name is propagated using the TELNET ENVIRON option. Setting this flag is the same as specifying the </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">a</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> option to the <b>open</b> command or on the command line.
<br />
<br /> <b>autosynch
<br /> </b>If <b>autosynch</b> and <b>localchars</b> are both TRUE, then when either the <b>intr</b> or <b>quit</b> characters is typed, the resulting telnet sequence sent is followed by the TELNET SYNCH sequence. This procedure should cause the remote system to begin discarding all previously typed input until both of the telnet sequences have been read and acted upon. The initial value of this toggle is FALSE.
<br />
<br /> <b>binary
<br /> </b>Enable or disable the TELNET BINARY option on both input and output.
<br />
<br /> <b>inbinary
<br /> </b>Enable or disable the TELNET BINARY option on input.
<br />
<br /> <b>outbinary
<br /> </b>Enable or disable the TELNET BINARY option on output.
<br />
<br /> <b>crlf
<br /> </b>If this is TRUE, then carriage returns will be sent as <cr><lf>. If this is FALSE, then carriage returns will be send as <cr><nul>. The initial value for this toggle is FALSE.
<br />
<br /> <b>crmod
<br /> </b>Toggle carriage return mode. This flag only exists if encryption support is available.
<br />
<br /> <b>localchars
<br /> </b>If this is TRUE, then the <b>flush</b>, <b>interrupt</b>, <b>quit</b>, <b>erase</b>, and <b>kill</b> characters are recognized locally, and transformed into appropriate TELNET control sequences (respectively <b>ao</b>, <b>ip</b>, <b>brk</b>, <b>ec</b>, and <b>el</b>). The initial value for this toggle is TRUE in ``old line by line'' mode, and FALSE in ``character at a time'' mode. When the LINEMODE option is enabled, the value of <b>localchars</b> is ignored, and assumed to always be TRUE. If LINEMODE has ever been enabled, then <b>quit</b> is sent as <b>abort</b>, and <b>eof</b> <b>and</b> are sent as <b>eof</b> <b>and</b> <b>susp</b>.
<br />
<br /> <b>netdata
<br /> </b>Toggles the display of all network data in hexadecimal format. The initial value for this toggle is FALSE.
<br />
<br /> <b>options
<br /> </b>Toggles the display of some internal <b>telnet</b> protocol processing. The initial value for this toggle is FALSE.
<br />
<br /> <b>prettydump
<br /> </b>When the <b>netdata</b> toggle is enabled, if <b>prettydump</b> is enabled the output from the <b>netdata</b> command will be formatted in a more user readable format. Spaces are put between each character in the output, and the beginning of telnet escape sequences are preceded by a '*' to aid in locating them.
<br />
<br /> <b>skiprc
<br /> </b>When the skiprc toggle is TRUE, telnet does not read the </span><i><span style="font-size: 10pt; font-family: Arial; color: black;">.telnetrc</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> file. The initial value for this toggle is FALSE.
<br />
<br /> <b>termdata
<br /> </b>Toggles the display of all terminal data (in hexadecimal format). The initial value for this toggle is FALSE.
<br />
<br /> <b>verbose_encrypt</b>
<br /> When the <b>verbose_encrypt</b> toggle is TRUE, TELNET prints out a message each time encryption is enabled or disabled. The initial value for this toggle is FALSE. This flag only exists if encryption support is available.
<br />
<br /> <b>?
<br /> </b>Displays the legal <b>toggle</b> commands. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">z
<br /> </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">Suspend <b>telnet</b>. This command only works when the user is using <b>Telnet</b> uses at least the HOME, SHELL, DISPLAY, and TERM environment variables. Other environment variables may be propagated to the other side via the TELNET ENVIRON option.
<br />
<br /> NOTE: on some remote systems, echo has to be turned off manually when in ``old line by line'' mode. In ``old line by line'' mode or LINEMODE the terminal's <b>eof</b> character is only recognized and sent to the remote system when it is the first character on a line.<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-84072067904326769942008-08-06T02:37:00.002-07:002008-12-23T00:12:05.691-08:00VI Unix editor<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_filelist.xml"><title>Oracle Certification Program Candidate Guide</title><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"></o:smarttagtype><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>misebast</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????¡ì??????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Trebuchet MS"; panose-1:2 11 6 3 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:647 0 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {color:#0000A0; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:#606420; text-decoration:underline; text-underline:single;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><o:p></o:p><o:p></o:p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal" style=""><span style="font-size: 14pt; font-family: "Trebuchet MS"; color: rgb(204, 51, 51);">
<br /><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 99%;" width="99%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 1.5pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> The <b>vi </b>editor is a shell editor for Unix systems. It makes use of a regular keyboard with an Escape key. On a DEC station the Escape key is the F11 key. It works on all Unix computers. Use a Telnet or SSH client and login to your web server. Enter your username and password, then type <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;"> <b>su -</b> <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">at the command line. Enter your root password to get access to root.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Complete documentation is available by typing: <b>man vi</b><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> START SESSION</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;"> <b>vi <i>filename</i> </b> - filename is the file to be edited<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">UNDO</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> u</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - undo the last command<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> SCREEN COMMANDS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> (CTRL-X means pressing the CTRL key and the X key simultaneously)<o:p></o:p></span></p> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;"> CTRL-l </span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - reprint current screen <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> CTRL-L</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - expose one more line at the top of the screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> CTRL-E</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - expose one more line at the bottom of the screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> CTRL-F</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - go forward one screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> CTRL-B</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - go back one screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> CTRL-D</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - page down half a screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> CTRL-U</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - page up half a screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> CURSOR POSITIONING COMMANDS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> j</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - move cursor down one line, same column<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> k - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor up one line, same column<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> h - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor back one character<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> l - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor forward one character<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> RET - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor to beginning of next line (RET is the Return key)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> 0 - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor to beginning of current line<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> $ - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor to end of current line<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> SPACE - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor forward one character (SPACE is the Space bar)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> nG - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor to the beginning of line n (Default is the last line of the file)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> :n - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor to the beginning of line n<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> b - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move the cursor backward to the beginning of the previous word<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> e - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move the cursor backward to the end of the previous word<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> w - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move the cursor forward to the next word<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> /pattern - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor forward to the next occurrence of a pattern<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> ?pattern - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">move cursor backward to the next occurrence of a pattern<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> n - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">repeats the last / or ? pattern search.<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> TEXT INSERTION COMMANDS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> a - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">append text after the cursor (press ESC key to terminate the command)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> A - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">append text at the end of the line (press ESC key to terminate the command)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> i - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">insert text before the cursor (press ESC key to terminate the command)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;"> <b>I - </b>insert text at the beginning of the line (press ESC key to terminate the command)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> o - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">open a new line below the current line for text insertion (press ESC key to terminate the command)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> O - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">open a new line above the current line for text insertion (press ESC key to terminate the command)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> <st1:state st="on">DEL</st1:state> - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">overwrite the last character during text insertion (<st1:place st="on"><st1:state st="on">DEL</st1:state></st1:place> is the Delete key)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> ESC - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">stop text insertion. (ESC is the Escape key, on a DEC station this is the F11 key)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> TEXT DELETION COMMANDS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> x - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">delete the current character<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> dd - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">delete the current line<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> dw - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">delete the current word<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> d) - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">delete the rest of the current sentence<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> D </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">or<b> d$ - </b>delete from cursor to end of line<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> P - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">put text back from previous delete<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> TEXT MODIFICATION COMMANDS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> cw - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">change characters of current word (until terminated with the ESC key)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> c$ - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">change text up to the end of the line<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> C </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">or<b> cc - </b>change remaining text on current line (until terminated with the ESC key)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> ~ - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">change case of the current character<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> xp - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">transpose current and following characters<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> J - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">join current line with next line<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> s - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">delete the current character and go into insertion mode<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> r<i>x - </i></span></b><span style="font-size: 10pt; font-family: Arial; color: black;">replace the current character with <i>x</i><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> R - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">replace the following characters (until terminated with the ESC key)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> CUT AND PASTE COMMANDS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> yy - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">put the current line in a buffer (does not delete the line from its current position)<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> p - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">places the line in the buffer after the current position of the cursor<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> APPEND FILE COMMANDS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> :R <i>filename - </i></span></b><span style="font-size: 10pt; font-family: Arial; color: black;">insert the file <i>filename</i> where the cursor was before the : was typed<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> EXIT COMMANDS</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> ZZ - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">exit <b>vi</b> and save changes<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> :wq - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">write changes to current file and quit editing session<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;"> :q! - </span></b><span style="font-size: 10pt; font-family: Arial; color: black;">quit editing session (no changes are made)<o:p></o:p></span></p> </td> </tr> </tbody></table> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-17944979193765839152008-08-06T02:37:00.001-07:002008-12-23T00:12:05.691-08:00Untar a Unix / Linux file<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_filelist.xml"><title>Oracle Certification Program Candidate Guide</title><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>misebast</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????¡ì??????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Trebuchet MS"; panose-1:2 11 6 3 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:647 0 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {color:#0000A0; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:#606420; text-decoration:underline; text-underline:single;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <p class="MsoNormal" style=""><span style="font-size: 14pt; font-family: "Trebuchet MS"; color: rgb(204, 51, 51);">
<br /><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 99%;" width="99%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 1.5pt;" valign="top"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> How to untar a Unix / Linux file</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Unzipping files is an important part of downloading Linux files from the Internet. In Linux a majority of the files that are downloaded are in tgz format (a gnu zipped tar file), although there are other common extensions, as shown here:
<br />
<br /> [filename].tgz
<br /> [filename].tar
<br /> [filename].tar.gz
<br /> [filename].tar.z
<br /> [filename].z<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">Extraction</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">First you upload the .tgz, .tar .tar.gz or .tar.z file to the directory on your web server designated for public Internet use. Typically this directory is named 'www', 'htdocs' or 'web'. The file should be uploaded in BINARY format using any <a href="http://simplythebest.net/shareware/web_utilities/ftp.html"><span style="color: navy;">FTP</span></a> program.
<br />
<br /> Once the installation file has been uploaded, connect to your web server using a terminal emulation program. One of the most popular of these programs is <a href="http://simplythebest.net/info/servers/telnet.html"><span style="color: navy;">Telnet</span></a>. Enter your username and password when prompted, then change to the directory on your web server designated for Internet use. If this directory is named 'www', you should type the following command at the prompt:
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: navy;">
<br /> <b>cd /usr/dom/www</b> </span><span style="font-size: 10pt; font-family: Arial; color: black;">or </span><b><span style="font-size: 10pt; font-family: Arial; color: navy;">cd /home/sites/me/web</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Always start from the root directory (/).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">With files that have the .tgz, tar.gz, or tar.z extension use this command:
<br />
<br /> </span><b><span style="font-size: 10pt; font-family: Arial; color: navy;">tar -zxvf [filename with all extensions]</span></b><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> <i>example</i>: </span><span style="font-size: 10pt; font-family: Arial; color: navy;">tar -zxvf yourfile.tar.gz</span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> This will extract the file for you in the directory you are currently in. Using the above command will save you from having to redirect the output for gzip or anything else (because the z option automatically decompresses the file for you), otherwise without the z argument, you would have to do a command like this:
<br />
<br /> </span><b><span style="font-size: 10pt; font-family: Arial; color: navy;">uncompress [filename with all extensions]</span></b><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> </span><b><span style="font-size: 10pt; font-family: Arial; color: navy;">tar -xvf [filename with only tar extension]</span></b><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> Other ways to decompress files are to use:
<br />
<br /> </span><b><span style="font-size: 10pt; font-family: Arial; color: navy;">gunzip [filename with .gz extension]</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - f.e. </span><span style="font-size: 10pt; font-family: Arial; color: navy;">gunzip yourfile.gz</span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> </span><b><span style="font-size: 10pt; font-family: Arial; color: navy;">zcat [filename with .gz extension]</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - f.e. </span><span style="font-size: 10pt; font-family: Arial; color: navy;">zcat yourfile.gz</span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> </span><b><span style="font-size: 10pt; font-family: Arial; color: navy;">uncompress [filename with .z extension]</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> - f.e. </span><span style="font-size: 10pt; font-family: Arial; color: navy;">uncompress yourfile.z</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Not all Unix systems extract archive files with all the necessary permissions intact, therefore you should set the proper permissions on the program as required.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Using Telnet type the following at the prompt:
<br />
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: navy;">chmod -R 777 "directoryname"
<br /> cd "directoryname"
<br /> chmod 755 cgi-bin
<br /> cd cgi-bin
<br /> chmod 755 *.cgi
<br /> chmod 755 *.pl</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">You can also use most FTP clients to change the file attributes. 777 (RWX-RWX-RWX) and 755 (RWX-RX-RX) are the most widely used attributes for files relating to running most CGI scripts on a server.<o:p></o:p></span></p> </td> </tr> </tbody></table> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-59433363008645269302008-08-06T02:34:00.000-07:002008-12-23T00:12:05.691-08:00Unix & Linux folder & file permissions<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><title>Oracle Certification Program Candidate Guide</title><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="time"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="date"></o:smarttagtype><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>misebast</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-alt:Symbol; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????¡ì??????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Trebuchet MS"; panose-1:2 11 6 3 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:647 0 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {color:#0000A0; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:#606420; text-decoration:underline; text-underline:single;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:1747024031; mso-list-template-ids:2018286150;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.5in; mso-level-number-position:left; text-indent:-.25in; mso-ansi-font-size:10.0pt; font-family:Symbol;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <p class="MsoNormal" style=""><span style="font-size: 14pt; font-family: "Trebuchet MS"; color: rgb(204, 51, 51);">
<br /><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 99%;" width="99%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 1.5pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> As a webmaster you need to know how to use the CHMOD command to set folder and file permissions (also referred to as 'file attributes') on UNIX and Linux web servers. You need to set the correct file permissions especially with CGI script files when you install them. <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">On a UNIX web server, every file and folder stored on the hard drive have a set of permissions associated with it, which says who is allowed to do what with the file. Every file (and folder) also has an "owner" and a "group" associated with it. If you created the file, then you are the owner of that file, and your group, or the group associated with the folder you created the file in, will be associated with that file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">There are three types of people that can do things to files - the Owner of the file, anyone in the Group that the file belongs to, and Others (everyone else). In UNIX they are referred to using the letters <b>U</b> (for Owner or User), <b>G</b> (for Group), and <b>O</b> (for Others).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">There are three things that can be done to files or folders:<o:p></o:p></span></p> <ul type="disc"><li class="MsoNormal" style="color: black;"><span style="font-size: 10pt; font-family: Arial;">read the file or folder (this means listing the contents of the file or folder)<o:p></o:p></span></li><li class="MsoNormal" style="color: black;"><span style="font-size: 10pt; font-family: Arial;">write to the file. For folders this means creating and deleting files in the folder.<o:p></o:p></span></li><li class="MsoNormal" style="color: black;"><span style="font-size: 10pt; font-family: Arial;">execute (run) the file if it's a program or script. For folders this means accessing files in the folder.<o:p></o:p></span></li></ul> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Therefore there are three types of permissions: <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>r<span style=""> </span>- read the file or directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>w<span style=""> </span>- write to the file or directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>x<span style=""> </span>- execute the file or search the directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Each of these permissions can be set for any one of three types of user: <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>u<span style=""> </span>- the user who owns the file (you)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>g<span style=""> </span>- members of the group to which the owner belongs<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>o<span style=""> </span>- all other users<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CGI script installation pages will tell you to 'CHMOD 755' or 'Set the file to executable'. This all refers to setting the file permissions or attributes. When you use FTP or Telnet, you'll notice some letters next to the file listings. These letters are the current settings for the file or folder permissions. The details look like this:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;"><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"> <v:f eqn="sum @0 1 0"> <v:f eqn="sum 0 0 @1"> <v:f eqn="prod @2 1 2"> <v:f eqn="prod @3 21600 pixelWidth"> <v:f eqn="prod @3 21600 pixelHeight"> <v:f eqn="sum @0 0 1"> <v:f eqn="prod @6 1 2"> <v:f eqn="prod @7 21600 pixelWidth"> <v:f eqn="sum @8 21600 0"> <v:f eqn="prod @7 21600 pixelHeight"> <v:f eqn="sum @10 21600 0"> </v:formulas> <v:path extrusionok="f" gradientshapeok="t" connecttype="rect"> <o:lock ext="edit" aspectratio="t"> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style="'width:35.25pt;"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image001.gif" href="http://simplythebest.net/info/unix/images/attrib.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image001.gif" shapes="_x0000_i1025" width="47" height="17" /><!--[endif]-->15Kb <st1:date month="2" day="1" year="2002" st="on">02/01/02</st1:date> <st1:time hour="22" minute="45" st="on">22:45</st1:time> drwxrwxrwx<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">The string of letters, </span><span style="font-size: 10pt; font-family: Arial; color: navy;">drwxrwxrwx, </span><span style="font-size: 10pt; font-family: Arial; color: black;">represents the permissions that are set for this folder.<o:p></o:p></span></p> <table class="MsoNormalTable" style="" border="0" cellpadding="0"> <tbody><tr style=""> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">d</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">r</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">w</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">x</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">r</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">w</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">x</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">r</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">w</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><b><span style="font-size: 10pt; font-family: Arial; color: black;">x</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td colspan="3" style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><i><span style="font-size: 10pt; font-family: Arial; color: black;">Owner</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td colspan="3" style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><i><span style="font-size: 10pt; font-family: Arial; color: black;">Group</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td colspan="3" style="padding: 1.5pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><i><span style="font-size: 10pt; font-family: Arial; color: black;">Other</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Directory<o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Read<o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Write<o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Execute<o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Read<o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Write<o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Execute<o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Read<o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Write<o:p></o:p></span></p> </td> <td style="padding: 1.5pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Execute<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">
<br />
<br /> The string of letters breaks down into 3 sections of 3 letters each, representing each of the types of users (the owner, members of the group, and everyone else). There is a 'd' attribute on the left, which tells us if this is a file or a folder (directory). If any of these letters is replaced with a hyphen (-), it means that permission is <i>not</i> granted. <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: red;">For example:</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <table class="MsoNormalTable" style="" border="0" cellpadding="0"> <tbody><tr style=""> <td style="padding: 3.75pt;" valign="top"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;">drwxrwxrwx</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">A folder which has read, write and execute permissions for the owner, the group and for other users.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;" valign="top"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;">-rwxr--r--</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">A file that can be read and written by the user, but only read and executed by the group, and only read by everyone else.<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> <b>Using numbers</b> <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">You can also use numbers for setting file and folder permissions. Each of the three numbers corresponds to each of the three sections of letters. The first number determines the <b>owner</b> permissions, the second number determines the <b>group</b> permissions and the third number determines the <b>other</b> permissions. Each number can have one of eight values ranging from 0 to 7. Each value corresponds to a certain setting of the <b>read</b>, <b>write</b> and <b>execute</b> permissions.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">These values are added together for any one user category: <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>1<span style=""> </span>=<span style=""> </span>execute only<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>2<span style=""> </span>=<span style=""> </span>write only<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>3<span style=""> </span>=<span style=""> </span>write and execute (1+2)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>4<span style=""> </span>=<span style=""> </span>read only<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>5<span style=""> </span>=<span style=""> </span>read and execute (4+1)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>6<span style=""> </span>=<span style=""> </span>read and write (4+2)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>7<span style=""> </span>=<span style=""> </span>read and write and execute (4+2+1)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;">or in a table format, it would look like this:<o:p></o:p></span></p> <table class="MsoNormalTable" style="" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="padding: 3.75pt;"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;">Number</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;">Read (R)</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;">Write (W)</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;">Execute (X)</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">0<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">1<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">2<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">3<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">4<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">5<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">6<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">No<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">7<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> <td style="padding: 3.75pt;"> <p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Yes<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: red;">For example:</span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> <o:p></o:p></span></p> <table class="MsoNormalTable" style="" border="0" cellpadding="0"> <tbody><tr style=""> <td style="padding: 0.75pt;"> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">777</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> is the same as <b>rwxrwxrwx</b><o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">755</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"> is the same as <b>rwxr-xr-x</b><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">Setting permissions using FTP</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Your FTP program will most likely allow you to set file and folder permissions by selecting the file or folder in the remote window and either right-clicking on it and selecting an option such as <b>CHMOD</b> or <b>Set permissions</b>, or by selecting <b>CHMOD</b> / <b>Set permissions</b> from a menu option. Once you've selected the appropriate menu option, you'll see a dialog box similar to the following (this one is from <a href="http://simplythebest.net/shareware/web_utilities/ftp.html"><span style="color: navy;">CuteFTP</span></a> for Windows):<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;"><!--[if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" alt="" style="'width:195pt;height:239.25pt;"> <v:imagedata src="file:///D:\DOCUME~1\shesu04\LOCALS~1\Temp\msohtml1\06\clip_image002.gif" href="http://simplythebest.net/info/unix/images/chmod.gif"> </v:shape><![endif]--><!--[if !vml]--><img src="file:///D:/DOCUME%7E1/shesu04/LOCALS%7E1/Temp/msohtml1/06/clip_image002.gif" shapes="_x0000_i1026" vspace="10" width="260" border="0" height="319" /><!--[endif]--><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Using the screen of your FTP client, it should be easy to set the read, write and execute permissions for the owner, group and others using the check boxes. If you already know which numbers are needed, you can type the 3 digit number. The FTP client will change (chmod) the permissions for you. The above example of CHMOD 755 will be the one used most, since almost all CGI scripts need to be 755.<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">Setting permissions using Telnet</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">The other way to set permissions on your files is using Telnet (or a standard shell). Once you're connected to the server and have logged in, change to the folder containing the files you want to change (<b>cd yourdomain/cgi-bin), </b>You can then use the command <b>chmod</b> to set permissions on your files and folders. You can use the number notation described above, or you can use the letters.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">To set permissions with numbers, use the following syntax: </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">chmod xxx filename</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">where "xxx" is the 3 digit number representing the permissions, and filename is the file you want to change.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">chmod 755 mailform.pl</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">You can use the letters <b>u</b> (owner/user), <b>g</b> (group) and <b>o</b> (other) to set permissions for each of the user types, and <b>r</b> (read), <b>w</b> (write) and <b>x</b> (execute) to represent the permissions to set. You can also use <b>a</b> instead of u, g, and o, to mean all users (u,g,o).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">You assign permissions using either the plus sign (+), which means add these permissions, the minus sign (-), which means remove these permissions, or the equals sign (=), which means change the permissions to exactly these.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: red;">For example:</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">chmod a+x mailform.pl </span><span style="font-size: 10pt; font-family: Arial; color: black;">adds execute permissions for all users to the file mailform.pl (makes the file executable).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">chmod u=rwx mailform.pl </span><span style="font-size: 10pt; font-family: Arial; color: black;">sets read, write and execute permission just for the owner (the permissions for the group and for others remain unchanged).<o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">Checking your folder and file permissions</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">To display the access permissions of a file or directory use the command: <o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: navy;"><span style=""> </span>ls -l <i>filename </i>(<i>directory</i>)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">This displays a one line summary for each file or directory. <o:p></o:p></span></p> <p class="MsoNormal" style=""><b><span style="font-size: 10pt; font-family: Arial; color: black;">Changing group ownership of files and directories</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">Every user is a member of one or more groups. To find out which groups you belong to use the command: </span><span style="font-size: 10pt; font-family: Arial; color: navy;">groups</span><span style="font-size: 10pt; font-family: Arial; color: black;">. To find out which groups another user belongs to, use the command: </span><span style="font-size: 10pt; font-family: Arial; color: navy;">groups <i>username. </i></span><span style="font-size: 10pt; font-family: Arial; color: black;">Your files and directories are owned by the group (or one of the groups) that you belong to. This is known as group ownership. To list the group ownership of your files, use the command: </span><span style="font-size: 10pt; font-family: Arial; color: navy;">ls -gl. </span><span style="font-size: 10pt; font-family: Arial; color: black;">You can change the group ownership of a file or directory with the command: </span><span style="font-size: 10pt; font-family: Arial; color: navy;">chgrp <i>group_name file/directory_name. </i></span><span style="font-size: 10pt; font-family: Arial; color: black;">You must be a member of the group to which you are changing ownership to.
<br /> <o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-76142524850558503122008-08-06T02:33:00.000-07:002008-12-23T00:12:05.691-08:00Unix / Linux commands<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C06%5Cclip_editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><title>Oracle Certification Program Candidate Guide</title><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="country-region"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"></o:smarttagtype><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>misebast</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????¡ì??????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Trebuchet MS"; panose-1:2 11 6 3 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:647 0 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} a:link, span.MsoHyperlink {color:#0000A0; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:#606420; text-decoration:underline; text-underline:single;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <p class="MsoNormal" style=""><span style="font-size: 14pt; font-family: "Trebuchet MS"; color: rgb(204, 51, 51);">
<br /><o:p></o:p></span></p> <table class="MsoNormalTable" style="width: 99%;" width="99%" border="1" cellpadding="0" cellspacing="1"> <tbody><tr style=""> <td style="padding: 1.5pt;" valign="top"> <table class="MsoNormalTable" style="width: 99%;" width="99%" border="0" cellpadding="0" cellspacing="0"> <tbody><tr style="height: 1.5pt;"> <td colspan="5" style="padding: 2.25pt; height: 1.5pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 8pt; font-family: Arial; color: black;"> <o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;">Unix command</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;">Description</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: Arial; color: black;">Details</span></b><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">ALIAS<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Create abbreviations (aliases) for commands<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">alias <i>abbreviation=command</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Displays a list of all aliases, standard arguments can be used (-a, -l, etc.). To cancel the alias use the </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">unalias</span><span style="font-size: 10pt; font-family: Arial; color: black;"> command. F.e. </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">alias my_command='ls -al'</span><span style="font-size: 10pt; font-family: Arial; color: black;">.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">ARCHIE<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Change the current directory<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">archie <i>filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Search the Archie database for a file on a FTP site.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">AT<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Execute a command at a specified time<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">at <i>[-filename][-m] time</i>
<br /> -filename</span><span style="font-size: 10pt; font-family: Arial; color: black;"> - Read the command(s) from the file specified.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-m = </span><span style="font-size: 10pt; font-family: Arial; color: black;">Notify the user by mail when the job is completed.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">time</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = The time when the commands are going to be executed.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">BC<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Use the calculator<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">bc
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">To use decimals, type </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">scale =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">number</span><span style="font-size: 10pt; font-family: Arial; color: black;"> (of decimal digits). End the calculator with </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">Ctrl-D</span><span style="font-size: 10pt; font-family: Arial; color: black;">.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">BG<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Execute processes in the background<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">bg <i>[%n]</i>
<br /> %n = </span><span style="font-size: 10pt; font-family: Arial; color: black;">Without this parameter it displays the jobs that are currently executed in the background. With a number the process with the given number is executed in the background.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">& = </span><span style="font-size: 10pt; font-family: Arial; color: black;">At the end of a command starts the process in the background.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><st1:place st="on"><st1:state st="on"><span style="font-size: 10pt; font-family: Arial; color: black;">CAL</span></st1:state></st1:place><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Display the calendar of the current month<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">cal <i>[month][year]</i></span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CANCEL<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Cancel requests for printing<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">cancel <i>[ -u user] print-request</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Requests can be cancelled by using the printer-id or by specifying the printer name.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-u user</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = Cancel print jobs that are queued for the specified user.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CAT<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Display one or more files<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">cat <i>[-sn] [filenames]</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> If more than one filename is supplied, it is added at the end of the previous file and displayed.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-n</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = Display numbers in ascending order in front of each line.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-s</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = Do not comment about nonexistent files.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">filenames = </span><span style="font-size: 10pt; font-family: Arial; color: black;">The filename(s) in the order that you want them to be displayed.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CD<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Change the current directory<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">cd <i>[pathname]</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Change the current directory to </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">pathname</span><span style="font-size: 10pt; font-family: Arial; color: black;"> or to root directory if no </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">pathname</span><span style="font-size: 10pt; font-family: Arial; color: black;"> is given.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CHGRP<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Change group name <o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">chgrp <i>groupname filename(s) | directory name(s)</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Change group of the named file or directory.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CHMOD<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Set file access permissions<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">chmod <i>[ugo,+-,rwx] filename | directory name</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Change mode permissions of the named file(s) or directory(ies).
<br /> See <a href="http://simplythebest.net/info/unix/unix_permissions.html"><span style="">File permissions</span></a> for detailed information.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CHOWN<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Change owner<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">chown <i>username filename | directoryname</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Change the owner of a file or directory.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CHSH<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Change shell<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">chsh
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Change the Unix shell you log into.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CLEAR<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Clears display<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">clear
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Clears the display. Only the prompt is displayed.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CMP<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Compare files<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">cmp <i>filename filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Compares the named files. If they are equal nothing is returned, otherwise it returns the first character and line where the two files differ.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">COMPRESS<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Compress file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">compress <i>[-v] filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Compress the named file. The compressed file gets .Z appended to the filename.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-v</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = Ask for verification after compressing the file.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CP<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Copy a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">cp <i>oldname newname [-r][-i] pathname (</i></span><i><span style="font-size: 10pt; font-family: Arial; color: black;">cp index.html index1.html)</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> The </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">cp</span><span style="font-size: 10pt; font-family: Arial; color: black;"> command allows you to copy files to new files, or copy files and directories to new directories. The command line </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">cp index.html otherdir</span><span style="font-size: 10pt; font-family: Arial; color: black;"> will copy the file index.html to the directory otherdir.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-i = </span><span style="font-size: 10pt; font-family: Arial; color: black;">Ask before updating a file or directory that exists in the destination with the same name.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-r</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = To copy a directory including its contents to a new directory, recursive.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">CRONTAB<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Scheduled files<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">crontab <i>filename [-r][-l][-e] pathname</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> The </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">crontab</span><span style="font-size: 10pt; font-family: Arial; color: black;"> command allows you to run, delete or edit scheduled tasks.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-l = </span><span style="font-size: 10pt; font-family: Arial; color: black;">lists your currently scheduled tasks.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-r</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = deletes all currently scheduled tasks.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-e</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = edit your scheduled tasks.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">DATE<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">List current date and time<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">date</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">DF<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Disk space info<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">df <i>[-k] [filesystem]</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Shows disk space available on the system.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-k</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = Use 1024 byte blocks instead of the default 512.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">filesystem</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = If omitted displays the amount of disk space used and available on all mounted filesystems.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">DU<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Disk space info<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">du <i>[-aks] [filename | directoryname]</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Shows how much disk space is being used up by folders.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-a</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = Shows counts for all files encountered, not only directories.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-k</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = Use 1024 byte blocks instead of the default 512.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-s</span><span style="font-size: 10pt; font-family: Arial; color: black;"> = Don't display space usage of subdirectories.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">DIFF<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Display the differences between two text files<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">diff <i>textfile1 textfile2</i></span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">ECHO<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Output string<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">echo <i>characterstring</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Displays the character string to the standard output device.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">EXIT<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Exit system<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">exit
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Exit the system or logout.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">FG<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Execute processes in the foreground<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">fg <i>[%n]</i>
<br /> %n = </span><span style="font-size: 10pt; font-family: Arial; color: black;">Without this parameter it restarts the job that is currently executed in the background. With a number the process with the given number is restarted in the foreground.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">& = </span><span style="font-size: 10pt; font-family: Arial; color: black;">At the end of a command starts the process in the foreground.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">FILE<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">File classification<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">file <i>filename(s)</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Shows information about the file type of the filename(s).<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">FIND<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Search command<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">find <i>directorypath(s) searchpattern action(s)</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Search the specified directorie(s) for files that satisfy the search pattern and act on them according to the action(s) parameter.
<br /> <u>Search-patterns</u>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-name <i>filename =</i></span><i><span style="font-size: 10pt; font-family: Arial; color: black;"> s</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">earch for files with the specified filename.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">- size <i>n =</i></span><i><span style="font-size: 10pt; font-family: Arial; color: black;"> s</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">earch for files of <i>n </i>blocks (usually 512 or 1024 bytes).
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">- links <i>n =</i></span><i><span style="font-size: 10pt; font-family: Arial; color: black;"> </span></i><span style="font-size: 10pt; font-family: Arial; color: black;">search for files with <i>n </i>links.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">- atime <i>n = </i></span><span style="font-size: 10pt; font-family: Arial; color: black;">search for files that have been last accessed before <i>n</i> days.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">- mtime <i>n =</i></span><span style="font-size: 10pt; font-family: Arial; color: black;"> search for files that have been last modified before <i>n</i> days.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">- newer <i>filename =</i></span><span style="font-size: 10pt; font-family: Arial; color: black;"> search for files that have been modified more recently than the specified file.
<br /> <u>Actions</u>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">- print =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> display the path(s) of the files found.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">- exec <i>command =</i></span><span style="font-size: 10pt; font-family: Arial; color: black;"> run command for each file found
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">- ok <i>command =</i></span><i><span style="font-size: 10pt; font-family: Arial; color: black;"> a</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">s </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">exec</span><span style="font-size: 10pt; font-family: Arial; color: black;">, but it asks for approval before the action.
<br /> <u>Notes</u>
<br /> Search patterns can be combined.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">! =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> negation
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-o =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> logical OR
<br /> One or more search patterns are combined using logical <st1:place st="on"><st1:country-region st="on">AND.</st1:country-region></st1:place>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">( ) </span><span style="font-size: 10pt; font-family: Arial; color: black;">or</span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);"> \ \ =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> these can be used to define groups of search patterns.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">FINGER<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">User info<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">finger <i>emailaddress</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Shows more information about a user.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">FTP<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">FTP to a site<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">ftp <i>hostname </i></span><i><span style="font-size: 10pt; font-family: Arial; color: black;">(or IP address)</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Connects to a FTP site.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">GCC<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Compile source code<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">gcc <i>option filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Compile source code into a file.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">GOPHER<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Connect to Gopher<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">gopher
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Use the Gopher database browser.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">GREP<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Search in a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">grep <i>[-c,-n,-i,-v,-w,-y] pattern [filename(s)]</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Search for a string in a file or files.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-c =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> displays only the number of lines that match.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-n =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> displays the line number in front of every displayed line.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-i =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> ignore case.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-v =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> displays all other lines except those lines that match.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-w =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> matches whole words only.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-y =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> case independent pattern matching, lower case letters in </span><i><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">pattern</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> will also match upper case letters in the input.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">GZIP<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Compress a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">gzip <i>filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Compress a file.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">HEAD<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Display head of a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">head<i> [-n] filename(s)</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Display the first </span><i><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">n</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"> lines of the named file(s). If no number is given the first 10 lines are displayed.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-<i>n =</i></span><span style="font-size: 10pt; font-family: Arial; color: black;"> the number of lines to display from the top of the file.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">HOSTNAME<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Display hostname<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">hostname </span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Display the name of the host machine.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">IRC<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Connect to IRC<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">irc <i>hostname </i></span><i><span style="font-size: 10pt; font-family: Arial; color: black;">(or IP address)</span></i><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Connect to an Internet Relay Chat host.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">JOBS<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Display active processes<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">jobs</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">KILL<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Terminate process<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">kill <i>[-signr] process_ID</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Terminate the process with the specified process ID.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-9 = s</span><span style="font-size: 10pt; font-family: Arial; color: black;">end a definite kill signal.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">LOGOUT<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Logs off the system<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">logout</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">lprint Print a file lprintd Abort a print job lprintq List the print queue<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">LS<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">List files in the current directory<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">ls <i>[-CFRR*acdglrstu] [list of filenames or directories]</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> The -</span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">a</span><span style="font-size: 10pt; font-family: Arial; color: black;"> switch will include hidden files (hidden files in UNIX begin with a dot (<b>.</b>)), the current directory and parent directory entries (<b>.</b> and <b>..</b> respectively). You can combine switches by placing them one after the other (</span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">ls -la</span><span style="font-size: 10pt; font-family: Arial; color: black;">, etc..)
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-C =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list entries in columns.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-F =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list directories with /.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-R =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list subdirectories as well.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-R* =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list subdirectories 2 levels below current directory.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-a =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list all entries, including files with a dot (.htaccess, etc..).
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-c =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> sort entries by last modified date.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-d =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list directories only.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-g =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list hidden files and directories.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-l =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list in long format (mode, no of links, owner, group, size, and modified date).
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-r =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list in reverse order.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-s =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> list size in 1024 byte blocks.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-t =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> sort contents by time of last modified date.
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-u =</span><span style="font-size: 10pt; font-family: Arial; color: black;"> use time of last access (not last modified date) for sorting (with </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-t</span><span style="font-size: 10pt; font-family: Arial; color: black;">) or printing onscreen (with </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">-l</span><span style="font-size: 10pt; font-family: Arial; color: black;">).<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">MAKE<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Compile source code<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">make <i>command</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Compile a source code.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">MAKEFILE<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Compile source code file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">make <i>filename</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Compile a source code into a file.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">MAN<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Read the help<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">man <i>command</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> Shows the help on the entered command, f.e. </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">man ls</span><span style="font-size: 10pt; font-family: Arial; color: black;">, </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">man chmod,</span><span style="font-size: 10pt; font-family: Arial; color: black;"> etc.
<br /> To search for some text, press the forward-slash (<b>/</b>) key and type the text you want to search for. If you want to run a program that's in your current directory, you'll need to put a dot-slash (./) in front of the program name.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">MKDIR<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Create a directory<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">mkdir <i>directoryname, mkdir -i directoryname</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> To create a directory in the current directory, type </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">mkdir</span><span style="font-size: 10pt; font-family: Arial; color: black;"> followed by the directory name. To delete a directory and all its contents, use </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">rm -r directoryname. </span><span style="font-size: 10pt; font-family: Arial; color: black;">The -i parameter will make the system prompt you before deleting a file or directory. If the directory is empty, you can also delete it using the </span><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">rmdir </span><span style="font-size: 10pt; font-family: Arial; color: black;">command.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">MORE<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">List a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">more <i>filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">View a file with a pause after every full screen.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">MV<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Rename a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">mv <i>oldname newname</i></span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">PASSWORD<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Change password<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">password
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Change the administrator password.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">PICO<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Edit a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">pico <i>filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">An easy to use text editor.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">PINE<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">A mailer program<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">pine
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">An easy to use mailer program.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">PWD<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">What is the current directory<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">pwd</span><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">RM<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Delete/remove a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">rm <i>filename</i></span><span style="font-size: 10pt; font-family: Arial; color: black;">
<br /> To delete a single file, use rm filename.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">RMDIR<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Remove a directory<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">rmdir <i>directoryname</i></span><i><span style="font-size: 10pt; font-family: Arial; color: black;">, </span></i><i><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">rm -r directoryname </span></i><i><span style="font-size: 10pt; font-family: Arial; color: black;">( to delete folders with its files).</span></i><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">RZ<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Receive a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">rz
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Receive a file using Zmodem.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">SZ<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Send a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">sz <i>filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Send a file using Zmodem.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">TAIL<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Show last lines of a file<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">tail <i>filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Show the last few lines of a file.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">TALK<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Page user to chat<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">talk <i>username</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Pages the user for a chat, the user is an e-mail address.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">TAR<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Archive files<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">tar <i>filename</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Create or extract multiple file archives. Other methods are lharc, lzh, and lha, but these methods may not be present on your system.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">TIN, TRN<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Connect to Usenet<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">tin, trn
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Connect to Usenet newsgroups.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">TELNET<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Connect<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">telnet <i>hostname </i></span><i><span style="font-size: 10pt; font-family: Arial; color: black;">(or IP address)</span></i><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Connect to an Internet web site.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">DOS2UNIX<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Conversion of text files<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">dos2unix <i>filename newname</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Strips the carriage returns (CR) from the DOS text file.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">UNIX2DOS<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Conversion of text files<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">unix2dos <i>filename newname</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Adds the carriage returns (CR) to the Unix text file.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">WHO<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Who is logged in?<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">who
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Shows who is logged into the local system.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">W<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Who is logged in and what are they doing?<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">w
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Shows who is logged into the local system and what they are doing.<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">WRITE<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Write to a user<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">write <i>username</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Write to a user on the local system (CTRL-C to end it).<o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td colspan="4" style="padding: 2.25pt;" valign="top"> <div class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"> <hr size="2" width="100%" align="center"> </span></div> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> <tr style=""> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: Arial; color: black;">ZIP<o:p></o:p></span></p> </td> <td style="padding: 2.25pt; width: 7.5pt;" valign="top" width="10"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p> </o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;">Compress to zip<o:p></o:p></span></p> </td> <td style="padding: 2.25pt;" valign="top"> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: rgb(0, 0, 160);">zip <i>username</i>
<br /> </span><span style="font-size: 10pt; font-family: Arial; color: black;">Compress to zip for IBM files.<o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><span style="font-size: 10pt; font-family: Arial; color: black;"><o:p></o:p></span></p> </td> </tr> </tbody></table> <p class="MsoNormal"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-63185944380931488292008-08-05T20:29:00.001-07:002008-12-23T00:12:05.691-08:00What's the difference between fork() and vfork()?Some systems have a system call `vfork()', which was originally designed as<br />a lower-overhead version of `fork()'. Since `fork()' involved copying the<br />entire address space of the process, and was therefore quite expensive, the<br />`vfork()' function was introduced (in 3.0BSD).<br /><br />*However*, since `vfork()' was introduced, the implementation of `fork()'<br />has improved drastically, most notably with the introduction of<br />`copy-on-write', where the copying of the process address space is<br />transparently faked by allowing both processes to refer to the same<br />physical memory until either of them modify it. This largely removes the<br />justification for `vfork()'; indeed, a large proportion of systems now lack<br />the original functionality of `vfork()' completely. For compatibility,<br />though, there may still be a `vfork()' call present, that simply calls<br />`fork()' without attempting to emulate all of the `vfork()' semantics.<br /><br />As a result, it is *very* unwise to actually make use of any of the<br />differences between `fork()' and `vfork()'. Indeed, it is probably unwise<br />to use `vfork()' at all, unless you know exactly *why* you want to.<br /><br />The basic difference between the two is that when a new process is created<br />with `vfork()', the parent process is temporarily suspended, and the child<br />process might borrow the parent's address space. This strange state of<br />affairs continues until the child process either exits, or calls<br />`execve()', at which point the parent process continues.<br /><br />This means that the child process of a `vfork()' must be careful to avoid<br />unexpectedly modifying variables of the parent process. In particular, the<br />child process must *not* return from the function containing the `vfork()'<br />call, and it must *not* call `exit()' (if it needs to exit, it should use<br />`_exit()'; actually, this is also true for the child of a normal `fork()').<br /><br />1.1.3 Why use _exit rather than exit in the child branch of a fork?<br />-------------------------------------------------------------------<br /><br />There are a few differences between `exit()' and `_exit()' that become<br />significant when `fork()', and especially `vfork()', is used.<br /><br />The basic difference between `exit()' and `_exit()' is that the former<br />performs clean-up related to user-mode constructs in the library, and calls<br />user-supplied cleanup functions, whereas the latter performs only the<br />kernel cleanup for the process.<br /><br />In the child branch of a `fork()', it is normally incorrect to use<br />`exit()', because that can lead to stdio buffers being flushed twice, and<br />temporary files being unexpectedly removed. In C++ code the situation is<br />worse, because destructors for static objects may be run incorrectly.<br />(There are some unusual cases, like daemons, where the *parent* should call<br />`_exit()' rather than the child; the basic rule, applicable in the<br />overwhelming majority of cases, is that `exit()' should be called only once<br />for each entry into `main'.)<br /><br />In the child branch of a `vfork()', the use of `exit()' is even more<br />dangerous, since it will affect the state of the *parent* process.Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-90110675860095545552008-08-05T20:28:00.000-07:002008-12-23T00:12:05.691-08:00What does fork() do?#include <sys/types.h><br /> #include <unistd.h><br /> <br /> pid_t fork(void);<br /><br />The `fork()' function is used to create a new process from an existing<br />process. The new process is called the child process, and the existing<br />process is called the parent. You can tell which is which by checking the<br />return value from `fork()'. The parent gets the child's pid returned to<br />him, but the child gets 0 returned to him. Thus this simple code<br />illustrate's the basics of it.<br /><br /> pid_t pid;<br /> <br /> switch (pid = fork())<br /> {<br /> case -1:<br /> /* Here pid is -1, the fork failed */<br /> /* Some possible reasons are that you're */<br /> /* out of process slots or virtual memory */<br /> perror("The fork failed!");<br /> break;<br /> <br /> case 0:<br /> /* pid of zero is the child */<br /> /* Here we're the child...what should we do? */<br /> /* ... */<br /> /* but after doing it, we should do something like: */<br /> _exit(0);<br /> <br /> default:<br /> /* pid greater than zero is parent getting the child's pid */<br /> printf("Child's pid is %d\n",pid);<br /> }<br /><br />Of course, one can use `if()... else...' instead of `switch()', but the<br />above form is a useful idiom.<br /><br />Of help when doing this is knowing just what is and is not inherited by the<br />child. This list can vary depending on Unix implementation, so take it<br />with a grain of salt. Note that the child gets *copies* of these things,<br />not the real thing.<br /><br />Inherited by the child from the parent:<br /><br /> * process credentials (real/effective/saved UIDs and GIDs)<br /><br /> * environment<br /><br /> * stack<br /><br /> * memory<br /><br /> * open file descriptors (note that the underlying file positions are<br /> shared between the parent and child, which can be confusing)<br /><br /> * close-on-exec flags<br /><br /> * signal handling settings<br /><br /> * nice value<br /><br /> * scheduler class<br /><br /> * process group ID<br /><br /> * session ID<br /><br /> * current working directory<br /><br /> * root directory<br /><br /> * file mode creation mask (umask)<br /><br /> * resource limits<br /><br /> * controlling terminal<br /><br />Unique to the child:<br /><br /> * process ID<br /><br /> * different parent process ID<br /><br /> * Own copy of file descriptors and directory streams.<br /><br /> * process, text, data and other memory locks are NOT inherited.<br /><br /> * process times, in the tms struct<br /><br /> * resource utilizations are set to 0<br /><br /> * pending signals initialized to the empty set<br /><br /> * timers created by timer_create not inherited<br /><br /> * asynchronous input or output operations not inheritedSumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-69688699331515894772008-07-31T02:18:00.001-07:002008-12-23T00:12:05.691-08:00 Vi Text Editing<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>support</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????????¡ì????????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Trebuchet MS"; panose-1:2 11 6 3 2 2 2 2 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:647 0 0 0 159 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:T8; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T1; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T21; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T20; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T19; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T18; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T17; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T16; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T15; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T14; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T13; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T12; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T11; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T9; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:SimSun;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">
<br /><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">(o_cially pronounced 'vee-eye'/uno_cially pronounced 'six' because of the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">feeling one gets when using </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">that it may be the text editor of the antichrist)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">is a display oriented interactive text editor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Vi</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">15 </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">makes one major philosophical deviation from every other text editor<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">I have come in contact with. The basic idea is that your hands don't have any<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">business straying from the home row keys. This can be an advantage for the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">touch typist, but the guy who needs to see the letter on the key before pushing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">it down tends to be less enamored with this characteristic. Since your _ngers<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">can only reach about _fty (50) keys without moving your hands, and since </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">has in excess of 100 commands, something drastic must be done in order to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">designate all the functions a decent text editor must have. Rather than relying<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">on extra keys on your keyboard that seem a little too far away or special key<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">combinations that involve keys that your keyboard may or may not have, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">simply assigns a couple functions to the keys in reach.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">operates in two modes</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">16 </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">(</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">insert </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">command</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">) in order to determine<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">which function should be performed when a key is pressed. This two mode<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">novelty, in my opinion, is what causes some to confuse </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">with the devil himself<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">and causes others to place </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">equal with God. Although I _nd it hard to justify<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">worshiping a text editor, I can (after much e_ort) appreciate the utility of </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Why </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">? </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is the default editor for Unix. It is possible to use other editors,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">but if you learn </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">you can be con_dent that it will be on any Unix machine<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">you use. However, the same level of con_dence with another editor may be<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">shortlived. It would be to your advantage to learn at least the basics of </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. For<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">those who use a text editor on a daily basis, particularly for programming, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">will become a joy to use after a few months of friendship building.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">As with any friendship, an emphasis must be placed on quality time, not just<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">quantity. Those who have little use for a text editor may be satis_ed with a cold<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">professional relationship with conversations limited to a few basic commands.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">The rest of us would certainly bene_t from a little quality time with </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. By<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">quality time, I don't mean merely having the same conversations over and over<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">(repeating commands you already know). I don't mean just reading about what<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">makes </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">tick. Although these are important activities, I mean telling </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">things<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">you've never told it before and observing its response. Don't discuss important<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">issues with </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">until you're pretty sure you know how it will react. Make sure<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">you make a backup copy of the _le you experiment with.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">15</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Short for </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">visual</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, but in keeping with the Unix mentality that any command longer than<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">_ve characters isn't worth using, the command has been truncated to the _rst two letters.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">16</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Technically, there are three modes, but I have chosen to treat the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">command </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">line editor<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">modes as one mode. The </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">line editor </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">commands are a carry-over from the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">ex </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">line editor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">30<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.2 Starting vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">To start </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">just type </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">at the operating system prompt. You will see a screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">with a column of tildes (</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">~</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">) down the left side of the screen. This signi_es<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">an empty workspace. To edit a _le, just include the _lename after it, e.g. </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">filename</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. You will see the text of the _le you included.</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">17 </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is now in command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">mode. The most basic command to enter insert mode is </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">i </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">which lets you insert<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">text to the left of the cursor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.3 Insert mode<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">I begin with a brief description of the insert mode because it is very straight<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">forward. In insert mode the characters you type are inserted into your document.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">You can use the backspace key to delete any typing mistakes you have made on<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">the current input line. The escape key (</span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">esc</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">></span><span style="font-size: 9pt; font-family: "Trebuchet MS";">) takes you out of insert mode<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">and back to the command mode. If you are ever in doubt about what mode you<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">are in, just press </span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">esc</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">> </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">a few times until </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">starts complaining. You will then<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">know that you are in the command mode.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.4 Command mode<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Command mode is where you do everything that isn't done in insert mode. In<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">command mode the same keys that caused letters to appear on your screen in<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">insert mode now represent totally di_erent functions. Rather than go into a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">detailed discussion of the 100 or so commands, this section contains a list of the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">more popular commands. The next section contains a more comprehensive list<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">of </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">commands.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.4.1 Moving around<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">h move the cursor one character to the left<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">j move the cursor one character down<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">k move the cursor one character up<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">l move the cursor one character to the right<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">0 move to the beginning of a line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">$ move to the end of a line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">G move to the end of a file<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">1G move to the first line of a file<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><ctrl-f> move down one screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><ctrl-b> move up one screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">If you try to move somewhere that </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">doesn't want to go, e.g. pressing </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">h<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">when the cursor is in the left-most column, your terminal will complain by either<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">beeping or ashing the screen.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">17</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">If the _le does not exist, it will be created.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">31<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.4.2 Deleting text<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">x delete the character under the cursor<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">dd delete a line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.4.3 Saving and quitting<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:w write to disk<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ZZ write to disk and exit<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:q! exit without writing to disk<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Actually, the command for quitting </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:q</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. You can save and quit by<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">typing </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:wq </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">but </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">ZZ </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">does the same thing</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">18 </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and takes one less keystroke. If there<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">are unsaved changes to the text and you try to quit using </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:q</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">will warn you<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">that you have unsaved changes and will prevent you from quitting. In order to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">quit without saving the changes you must use the override switch, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">!</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.4.4 Copy, delete, and moving text<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Knowing how to copy, delete, and move text is a prerequisite to any serious<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">text editing task. If you have a small amount of text to delete or copy you may<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">_nd it convenient to use </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">dd </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">or </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">yy</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. These commands delete or yank the line of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">text that the cursor is on. </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">dd </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">deletes the current line of text and places it in a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">bu_er. </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">yy </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">copies the current line of text to a bu_er while leaving the original<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">text unaltered. Many commands can be preceded by a number. This number<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">indicates the number of times the command is repeated. These commands are<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">no exception, e.g. </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">3dd </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">deletes the line the cursor is on as well as the two lines<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">below it and places them in a bu_er. Text can be retrieved from the text bu_er<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">by typing </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">p</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. The \pull" command inserts the text from the bu_er into the text<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">_le beginning on the line below the cursor. This method of deleting and yanking<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">works well for text blocks of known length or an easily countable number of lines,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">but is less satisfactory of large blocks of text.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">As a result, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">has another method of text manipulation that involves marking<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">text. </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is capable of marking 26 di_erent locations in a _le. To mark a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">location in a text _le move the cursor to the desired location and type </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">m </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">followed<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">by the name you want to use. Each lowercase letter of the alphabet is a name.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Suppose we have a portion of text we wish to move from one location to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">another. We can do this by marking the beginning of the text block with the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">name </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">q</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, i.e. </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">mq </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">will give the current cursor location the name </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">q</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. Then we move<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">to the end of the portion of text we wish to move and type </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">d'q</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. This command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">deletes everything from the marked position to the cursor position and places<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">it in a bu_er. Text in the bu_er is retrieved using the \pull" command already<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">described. The \yank" command allows you to copy the text to the bu_er<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">18</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">For the pureist, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:wq </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">ZZ </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">are not exactly the same. </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:wq </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">always saves, whereas </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">ZZ </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">saves<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">only if changes have been made since the last save.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">32<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">instead of deleting it. Typing </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">y'q </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">instead of </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">d'q </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">will place a copy of the text<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">in the bu_er and leave the original text unaltered.</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">19<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.4.5 Search and replace<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">The search command is </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">/</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. To search for </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">polite </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">type </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">/polite</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">repeats the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">search in the same direction, and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">N </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">repeats the search in the opposite direction.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">The search option accepts most of the standard Unix pattern matching language.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">(See section 2.7.1.) Suppose I had a _le that contained the following<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">text:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">There was a young man of Milan<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Whose poems, they never would scan;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">When asked why it was,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">He said, `It's because<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">I always try to get as many words into the last line as I possibly can'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">|anonymous<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Here are a few examples (using this text) that you will probably never use<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">but may _nd inspiring:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">/[a-z]as<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">will search for any lowercase letter followed by </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">as</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. In this example, it would<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">_nd </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">was </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">last </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">but not </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">as </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">or </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">asked</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">/[^c]an<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">will search for any </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">an </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">preceded by any character other than a </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">c</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. In our text it<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">would _nd </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Milan </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">but not </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">scan </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">or </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">can</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">/^[A-Z].*\. *$<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">will search for any line that begins with a capital letter and ends with a period<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">and any number of blanks. Our only match in the example text would be with<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">the last line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">All of these search patterns can be used in the search and replace command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">that takes on the following structure:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:s/search_string/replacement_string/g<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">This command replaces every </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">search string </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">on the current line with </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">replace-<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ment string</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. Omitting the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">g </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">(global) ag at the end of the command will cause<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">only the _rst occurrence of </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">search string </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">to be altered. Often you may wish<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">to con_rm each replacement. This can be done with the con_rm ag </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">c</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. The<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">con_rm ag should be placed after or in place of the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">g </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">ag. Suppose I had the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">following line:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">19</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Using </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">' </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">in </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">d'q </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">begins deleting text at the beginning of the line that the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">q </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">mark is on.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Using </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">` </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">instead, i.e. </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">d`q </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">begins deleting text at the exact location of the mark. This holds<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">for the yank command as well.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">33<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Give a skeptic and inch... and he'll take a mile.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">and typed<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:s/take a mile/measure it/<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">I would be left with<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Give a skeptic and inch... and he'll measure it.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Any command that begins with a \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" is called a line mode command and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">performs its duty on the line the cursor is currently on. However, you can<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">override </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">'s default of operating only on the current line by preceding them<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">with a range of line numbers. For example, if I wanted to replace </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">guy </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">with </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">gal<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">on lines 32 through 56 I would type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:32,56s/guy/gal/g<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Omitting the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">g </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">would cause only the _rst occurrence of </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">guy </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">in each line to be<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">replaced. The \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" and \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">$</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" play a special role in this sort of designation. \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">"<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">indicates the current line, and \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">$</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" indicates the last line of the _le. Therefore, if<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">I wanted to delete</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">20 </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">from the current line to the end of the _le I would enter:</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">21<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:.,$d<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">I could even do something like:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:.,/Edison/d<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">which would delete from the current line to the next line that contained </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Edison</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">One other shortcut that might be worth mentioning is that </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">1,$ </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">% </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">both<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">indicate all the lines in the _le. Therefore,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:1,$s/search_string/replacement_string/g<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:%s/search_string/replacement_string/g<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">do exactly the same thing.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.4.6 Undo<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">The undo command, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">u</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, is another feature that has saved me many times. Pressing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">u </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">undoes the last command you told </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">to perform. Another form of the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">undo command is </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">U </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">which undoes all the changes made to the current line since<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">you moved there.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">20</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">This works because </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:d </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is a line mode command that deletes the current line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">21</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">The same could be accomplished by typing </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">dG</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">34<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.4.7 Repeat<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Often times you may desire to repeat the last command performed. This can<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">be done with the \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" command. Place the cursor in the appropriate position<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">and press \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" to repeat the most recent command. Suppose I had a C program<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">in which I wished to switch a variable name from </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">no way </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">to </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">yes way </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">in two<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">di_erent places. One way I could accomplish this would be to place my cursor<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">on the beginning of the _rst </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">no way </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and type </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">cw </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">(change word) and then type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">yes way </span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">esc</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">></span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. This would accomplish my task for the _rst case. Now all I<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">would need to do to change the second </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">no way </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">would be to place my cursor at<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">the beginning of it and type \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" to repeat the last command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5 Vi reference<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Here is a more comprehensive list of </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">commands in command mode.</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">22 23<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.1 Notation for this reference<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">default values : 1<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><*> : `*' must not be taken literally<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*] : `*' is optional<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^X : <ctrl-x><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><sp> : Space<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><cr> : Carriage return<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><lf> : Linefeed<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><ht> : Horizontal tab<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><esc> : Escape<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><erase> : Your erase character<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><kill> : Your kill character<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><intr> : Your interrupt character<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><a-z> : An element in the range<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">N : Number (`*' = allowed, `-' = not appropriate)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">CHAR : Char unequal to <ht>|<sp><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">WORD : Word followed by <ht>|<sp>|<lf><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.2 Move commands (See also Display commands)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">N | Command | Meaning<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">---+--------------------+-----------------------------------------------<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | h | ^H | <erase> | <*> chars to the left.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | j | <lf> | ^N | <*> lines downward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | l | <sp> | <*> chars to the right.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | k | ^P | <*> lines upward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | $ | To the end of line <*> from the cursor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | ^ | To the first CHAR of the line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | _ | To the first CHAR <*> - 1 lines lower.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | - | To the first CHAR <*> lines higher.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">22</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Heavily borrowed from </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Vi Reference </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">by Maarten Litmaath.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">23</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Warning: some </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">versions don't support the more esoteric features described in this<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">document.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">35<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | + | <cr> | To the first CHAR <*> lines lower.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | 0 | To the first char of the line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | | | To column <*> (<ht>: only to the endpoint).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | f<char> | <*> <char>s to the right (find).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | t<char> | Till before <*> <char>s to the right.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | F<char> | <*> <char>s to the left.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | T<char> | Till after <*> <char>s to the left.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | ; | Repeat latest `f'|`t'|`F'|`T' <*> times.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | , | Idem in opposite direction.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | w | <*> words forward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | W | <*> WORDS forward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | b | <*> words backward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | B | <*> WORDS backward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | e | To the end of word <*> forward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | E | To the end of WORD <*> forward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | G | Go to line <*> (default EOF).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | H | To line <*> from top of the screen (home).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | L | To line <*> from bottom of the screen (last).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | M | To the middle line of the screen.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | ) | <*> sentences forward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | ( | <*> sentences backward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | } | <*> paragraphs forward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | { | <*> paragraphs backward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | ]] | To the next section (default EOF).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | [[ | To the previous section (default begin of file).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | `<a-z> | To the mark.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | '<a-z> | To the first CHAR of the line with the mark.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | `` | To the cursor position before the latest absolute<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| jump (of which are examples `/' and `G').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | '' | To the first CHAR of the line on which the cursor<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| was placed before the latest absolute jump.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | /<string> | To the next occurrence of <string>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | /<string>/+n | To the next nth occurrence of <string>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | ?<string> | To the previous occurrence of <string>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | n | Repeat latest `/'|`?' (next).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | N | Idem in opposite direction.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | % | Find the next bracket and go to its match<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (also with `{'|`}' and `['|`]').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Entries in this table that have an \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">*</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" are repeatable commands whereas<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">entries with a \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">-</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" are not. For example, if I type </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">4w </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">my cursor will travel four<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">words farther into my document.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.3 Searching<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:ta <name> | Search in the tags file[s] where <name> is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| defined (file, line), and go to it.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^] | Use the name under the cursor in a `:ta' command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^T | Pop the previous tag off the tagstack and return<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| to its position.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:[x,y]g/<string>/<cmd> | Search globally [from line x to y] for <string><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| and execute the `ex' <cmd> on each occurrence.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:[x,y]v/<string>/<cmd> | Execute <cmd> on the lines that don't match.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">36<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.4 Undoing changes<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">u | Undo the latest change.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">U | Undo all changes on a line, while not having<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| moved off it (unfortunately).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:q! | Quit vi without writing.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:e! | Re-edit a messed-up file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.5 Inserting text<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">End inserting text with </span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">esc</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | a | <*> times after the cursor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | A | <*> times at the end of line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | i | <*> times before the cursor (insert).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | I | <*> times before the first CHAR of the line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | o | On a new line below the current (open).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| The count is only useful on a slow terminal.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | O | On a new line above the current.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| The count is only useful on a slow terminal.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | ><move> | Shift the lines described by <*><move> one<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| shiftwidth to the right.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | >> | Shift <*> lines one shiftwidth to the right.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | ["<a-za-z1-9>]p | Put the contents of the (default undo) buffer<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <*> times after the cursor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| A buffer containing lines is put only once,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| below the current line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | ["<a-za-z1-9>]P | Put the contents of the (default undo) buffer<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <*> times before the cursor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| A buffer containing lines is put only once,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| above the current line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | . | Repeat previous command <*> times. If the last<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| command before a `.' command references a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| numbered buffer, the buffer number is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| incremented first (and the count is ignored):<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">|<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| "1pu.u.u.u.u - `walk through' buffers 1<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| through 5<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| "1P.... - restore them<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.6 Deleting text<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Everything deleted can be stored into a bu_er. This is achieved by putting a </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">"<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">and a lowercase letter before the delete command. The deleted text will be in<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">the bu_er with the used letter. If an uppercase letter is used as bu_er name,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">the the corresponding bu_er will be augmented instead of overwritten with the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">text. The undo bu_er always contains the latest change. Bu_ers </span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">1-9</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">> </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">contain<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">the latest 9 </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">line </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">deletions (</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">"1 </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is most recent).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | x | Delete <*> chars under and after the cursor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | X | <*> chars before the cursor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | d<move> | From begin to endpoint of <*><move>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | dd | <*> lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">37<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | D | The rest of the line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | <<move> | Shift the lines described by <*><move> one<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| shiftwidth to the left.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | << | Shift <*> lines one shiftwidth to the left.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | . | Repeat latest command <*> times.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.7 Changing text<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">End changing text with </span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">esc</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | r<char> | Replace <*> chars by <char> - no <esc>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | R | Overwrite the rest of the line,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| appending change <*> - 1 times.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | s | Substitute <*> chars.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | S | <*> lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | c<move> | Change from begin to endpoint of <*><move>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | cc | <*> lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | C | The rest of the line and <*> - 1 next lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | =<move> | If the option `lisp' is set, this command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| will realign the lines described by <*><move><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| as though they had been typed with the option<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `ai' set too.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | ~ | Switch lower and upper cases<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (should be an operator, like `c').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | J | Join <*> lines (default 2).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | . | Repeat latest command <*> times (`J' only once).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";" lang="FR">- | & | Repeat latest `ex' substitute command, e.g.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `:s/wrong/good'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | :[x,y]s/<p>/<r>/<f>| Substitute (on lines x through y) the pattern <p><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default the last pattern) with <r>. Useful<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| flags <f> are `g' for `global' (i.e. change<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| every non-overlapping occurrence of <p>) and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `c' for `confirm' (type `y' to confirm a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| particular substitution, else <cr>). Instead<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| of `/' any punctuation CHAR unequal to <lf><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| can be used as delimiter.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.8 Substitute replacement patterns<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">The basic meta-characters for the replacement pattern are \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">&</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" and \~ "; these<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">are given as </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">& </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">~ when nomagic is set. Each instance of \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">&</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" is replaced<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">by the characters which the regular expression matched. The meta-character<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">\ ~ " stands, in the replacement pattern, for the de_ning text of the previous<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">replacement pattern. Other meta-sequences possible in the replacement pattern<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">are always introduced by the escaping character \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">". The sequence </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">(where<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">n </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is an integer between 1 and 9) is replaced by the text matched by the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">th<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">regular subexpression enclosed between </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">( </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">)</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. The sequences </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">u </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">l<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">cause the immediately following character in the replacement to be converted to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">uppercase or lowercase respectively if this character is a letter. The sequences<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">U </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">L </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">turn such conversion on, either until </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">E </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">or </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">e </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is encountered, or until<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">the end of the replacement pattern.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">38<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.9 Remembering text (yanking)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">With yank commands you can put </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">"</span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">a--zA--Z</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">> </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">before the command, just as<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">with delete commands. Otherwise you only copy to the undo bu_er.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | y<move> | Yank from begin to endpoint of <*><move>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | yy | <*> lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">* | Y | Idem (should be equivalent to `y$' though).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">- | m<a-z> | Mark the cursor position with a letter.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.10 Commands while in insert or change mode<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^@ | If typed as the first character of the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| insertion, it is replaced with the previous<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| text inserted (max. 128 chars), after which<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| the insertion is terminated.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^V | Deprive the next char of its special meaning<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (e.g. <esc>).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^D | One shiftwidth to the left.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">0^D | Remove all indentation on the current line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (there must be no other chars on the line).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^^D | Idem, but it is restored on the next line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^T | One shiftwidth to the right<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^H | <erase> | One char back.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^W | One word back.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><kill> | Back to the begin of the change on the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| current line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><intr> | Like <esc> (but you get a beep as well).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.11 Display commands (See also Move commands)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^G | Give file name, status, current line number<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| and relative position.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^L | Refresh the screen (sometimes `^P' or `^R').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^R | Sometimes vi replaces a deleted line by a `@',<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| to be deleted by `^R' (see option `redraw').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]^E | Expose <*> more lines at bottom, cursor stays<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| put (if possible).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]^Y | Expose <*> more lines at top, cursor stays put<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (if possible).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]^D | Scroll <*> lines downward<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default the number of the previous scroll;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| initialization: half a page).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]^U | Scroll <*> lines upward<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default the number of the previous scroll;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| initialization: half a page).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]^F | <*> pages forward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]^B | <*> pages backward (in older versions `^B'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| only works without count).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">z- | Move current line to bottom of the screen.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">z. | Move current line to the center of the screen.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">/string/z- | Move line with string in it to the bottom of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| the screen.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">39<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">If in the next commands the _eld </span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">wi</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">> </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is present, the windowsize will<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">change to </span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">wi</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">></span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. The window will always be displayed at the bottom of the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">screen.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]z[wi]<cr> | Put line <*> at the top of the window<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default the current line).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]z[wi]+ | Put line <*> at the top of the window<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default the first line of the next page).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]z[wi]- | Put line <*> at the bottom of the window<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default the current line).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]z[wi]^ | Put line <*> at the bottom of the window<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default the last line of the previous page).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]z[wi]. | Put line <*> in the center of the window<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default the current line).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.12 Writing, editing other _les, and quitting vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">In \:" \ex" commands \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">%</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" denotes the current _le, \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">#</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">" is a synonym for the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">alternate _le (which normally is the previous _le). Marks can be used for line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">numbers too: </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">'</span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">a-z</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">></span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. In the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:w</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:f </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:cd</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:e</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:n </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">commands, shell metacharacters<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">can be used.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:q | Quit vi, unless the buffer has been changed.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:q! | Quit vi without writing.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^Z | Suspend vi.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:w | Write the file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:w <name> | Write to the file <name>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:w >> <name> | Append the buffer to the file <name>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:w! <name> | Overwrite the file <name>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:x,y w <name> | Write lines x through y to the file <name>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:wq | Write the file and quit vi; some versions quit<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| even if the write was unsuccessful!<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| Use `ZZ' instead.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ZZ | Write if the buffer has been changed, and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| quit vi. If you have invoked vi with the `-r'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| option, you'd better write the file<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| explicitly (`w' or `w!'), or quit the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| editor explicitly (`q!') if you don't want<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| to overwrite the file - some versions of vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| don't handle the `recover' option very well.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:x [<file>] | Idem [but write to <file>].<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:x! [<file>] | `:w![<file>]' and `:q'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:pre | Preserve the file - the buffer is saved as if<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| the system had just crashed; for emergencies,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| when a `:w' command has failed and you don't<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| know how to save your work (see `vi -r').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:f <name> | Set the current filename to <name>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:cd [<dir>] | Set the working directory to <dir><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default home directory).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:cd! [<dir>] | Idem, but don't save changes.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:e [+<cmd>] <file> | Edit another file without quitting vi - the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| buffers are not changed (except the undo<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| buffer), so text can be copied from one file to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">40<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| another this way. [Execute the `ex' command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <cmd> (default `$') when the new file has been<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| read into the buffer.] <cmd> must contain no<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <sp> or <ht>. See `vi startup'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:e! [+<cmd>] <file> | Idem, without writing the current buffer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">^^ | Edit the alternate (normally the previous) file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:rew | Rewind the argument list, edit the first file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:rew! | Idem, without writing the current buffer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:n [+<cmd>] [<files>] | Edit next file or specify a new argument list.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:n! [+<cmd>] [<files>] | Idem, without writing the current buffer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:args | Give the argument list, with the current file<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| between `[' and `]'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.13 Macros<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">When mapping take a look at the options </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">to </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">remap </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">(below).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:map <string> <seq> | <string> is interpreted as <seq>, e.g.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `:map ^C :!cc %^V<cr>' to invoke `cc' (the C<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| compiler) from within the editor<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (vi replaces `%' with the current file name).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:map | Show all mappings.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:unmap <string> | Deprive <string> of its mapping. When vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| complains about non-mapped macros (whereas no<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| typos have been made), first do something like<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `:map <string> Z', followed by<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `:unmap <string>' (`Z' must not be a macro<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| itself), or switch to `ex' mode first with `Q'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:map! <string> <seq> | Mapping in append mode, e.g.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `:map! \be begin^V<cr>end;^V<esc>O<ht>'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| When in append mode <string> is preceded by<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `^V', no mapping is done.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:map! | Show all append mode mappings.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:unmap! <string> | Deprive <string> of its mapping (see `:unmap').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:ab <string> <seq> | Whenever in append mode <string> is preceded and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| followed by a breakpoint (e.g. <sp> or `,'), it<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| is interpreted as <seq>, e.g.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `:ab ^P procedure'. A `^V' immediately<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| following <string> inhibits expansion.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:ab | Show all abbreviations.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:unab <string> | Do not consider <string> an abbreviation<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| anymore (see `:unmap').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">@<a-z> | Consider the contents of the named register a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| command, e.g.:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| o0^D:s/wrong/good/<esc>"zdd<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| Explanation:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| o - open a new line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| 0^D - remove indentation<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| :s/wrong/good/ - this input text is an<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `ex' substitute command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <esc> - finish the input<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| "zdd - delete the line just<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| created into register `z'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">41<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| Now you can type `@z' to replace `wrong'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| with `good' on the current line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">@@ | Repeat last register command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.14 Switch and shell commands<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Q | ^\ | <intr><intr> | Switch from vi to `ex'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">: | An `ex' command can be given.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:vi | Switch from `ex' to vi.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:sh | Execute a subshell, back to vi by `^D'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:[x,y]!<cmd> | Execute a shell <cmd> [on lines x through y;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| these lines will serve as input for <cmd> and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| will be replaced by its standard output].<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:[x,y]!! [<args>] | Repeat last shell command [and append <args>].<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:[x,y]!<cmd> ! [<args>] | Use the previous command (the second `!') in a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| new command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]!<move><cmd> | The shell executes <cmd>, with as standard<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| input the lines described by <*><move>,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| next the standard output replaces those lines<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (think of `cb', `sort', `nroff', etc.).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]!<move>!<args> | Append <args> to the last <cmd> and execute it,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| using the lines described by the current<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <*><move>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]!!<cmd> | Give <*> lines as standard input to the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| shell <cmd>, next let the standard output<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| replace those lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">[*]!!! [<args>] | Use the previous <cmd> [and append <args> to it].<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:x,y w !<cmd> | Let lines x to y be standard input for <cmd><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (notice the <sp> between the `w' and the `!').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:r!<cmd> | Put the output of <cmd> onto a new line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:r <name> | Read the file <name> into the buffer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.15 Vi startup<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">As discussed earlier </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">is started by simply typing </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi filename </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">where the _lename<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">is optional. It is possible to include a list of _lenames instead of just the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">one. This tells </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">to edit the _rst _le. After you are _nished with the _le it<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">edits the second and continues this process until all the _les in the list have<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">been edited.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">The editor can be initialized by the shell variable </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">EXINIT</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, which looks like:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">EXINIT='<cmd>|<cmd>|...'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";"><cmd>: set options<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">map ...<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ab ...<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">export EXINIT (in the Bourne shell)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">However, a better way is to put the list of initializations into a _le. If this _le<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">is located in your home directory, and is named </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.exrc </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">and the variable </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">EXINIT<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">is not set, the list will be executed automatically at startup time. However, </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">will always execute the contents of a </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.exrc </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">in the current directory, if you own<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">the _le. Otherwise you have to type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">42<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:so file<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">to </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">source </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">_le </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">yourself.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">In a </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.exrc </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">_le a comment is introduced with a double quote character: the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">rest of the line is ignored.</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">24<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">On-line initializations can be given with </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">+ </span><span style="font-size: 9pt; font-family: "Trebuchet MS";"><</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">cmd</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">> </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">file</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, e.g.:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi +x file | The cursor will immediately jump to line x<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default last line).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi +/<string> file | Jump to the first occurrence of <string>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">You can start at a particular tag with:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi -t <tag> | Start in the right file in the right place.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Sometimes, e.g. if the system crashed while you were editing, it is possible<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">to recover _les lost in the editor by typing </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi -r file</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">. Typing </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi -r </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">shows<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">the _les you can recover. The </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">readonly </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">ag allows you to view a _le with </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">without the danger of accidentally saving changes. However, if you do make<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">changes that you decide you want to save, typing </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">:w! </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">will override the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">readonly<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.5.16 The most important options<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ai | autoindent - In append mode after a <cr> the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| cursor will move directly below the first<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| CHAR on the previous line. However, if the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| option `lisp' is set, the cursor will align<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| at the first argument to the last open list.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">aw | autowrite - Write at every shell escape<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (useful when compiling from within vi).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">dir=<string> | directory - The directory for vi to make<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| temporary files (default `/tmp').<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">eb | errorbells - Beeps when you goof<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (not on every terminal).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ic | ignorecase - No distinction between upper and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| lower cases when searching.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">lisp | Redefine the following commands:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `(', `)' - move backward (forward) over<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| S-expressions<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `{', `}' - idem, but don't stop at atoms<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `[[', `]]' - go to previous (next) line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| beginning with a `('<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| See option `ai'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">list | <lf> is shown as `$', <ht> as `^I'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">magic | If this option is set (default), the chars `.',<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `[' and `*' have special meanings within search<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| and `ex' substitute commands. To deprive such<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| a char of its special function it must be<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">24</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">An exception to this is if the last command on the line is a </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">map[!] </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">or </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">ab </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">command or a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">shell escape, a trailing comment is not recognized, but considered part of the command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">43<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| preceded by a `\'. If the option is turned off<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| it's just the other way around. Meta-chars:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| ^<string> - <string> must begin the line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <string>$ - <string> must end the line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| . - matches any char<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| [a-z] - matches any char in the range<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| [^a-z] - any char not in the range<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| [<string>] - matches any char in <string><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| [^<string>] - any char not in <string><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <char>* - 0 or more <char>s<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| \<<string> - <string> must begin a word<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <string>\> - <string> must end a word<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">modeline | When you read an existing file into the buffer,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| and this option is set, the first and last 5<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| lines are checked for editing commands in the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| following form:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">|<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| <sp>vi:set options|map ...|ab ...|!...:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">|<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| Instead of <sp> a <ht> can be used, instead of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `vi' there can be `ex'. Warning: this option<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| could have nasty results if you edit a file<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| containing `strange' modelines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">nu | number - Numbers before the lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">para=<string> | paragraphs - Every pair of chars in <string> is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| considered a paragraph delimiter nroff macro<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (for `{' and `}'). A <sp> preceded by a `\'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| indicates the previous char is a single letter<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| macro. `:set para=P\ bp' introduces `.P' and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `.bp' as paragraph delimiters. Empty lines and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| section boundaries are paragraph boundaries<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| too.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">redraw | The screen remains up to date.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">remap | If on (default), macros are repeatedly<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| expanded until they are unchanged.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| Example: if `o' is mapped to `A', and `A'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| is mapped to `I', then `o' will map to `I'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| if `remap' is set, else it will map to `A'.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">report=<*> | Vi reports whenever e.g. a delete<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| or yank command affects <*> or more lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ro | readonly - The file is not to be changed.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| However, `:w!' will override this option.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">sect=<string> | sections - Gives the section delimiters (for `[['<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| and `]]'); see option `para'. A `{' beginning a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| line also starts a section (as in C functions).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">sh=<string> | shell - The program to be used for shell escapes<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (default `$SHELL' (default `/bin/sh')).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">sw=<*> | shiftwidth - Gives the shiftwidth (default 8<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| positions).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">sm | showmatch - Whenever you append a `)', vi shows<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| its match if it's on the same page; also with<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| `{' and `}'. If there's no match at all, vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| will beep.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">taglength=<*> | The number of significant characters in tags<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (0 = unlimited).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">44<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">tags=<string> | The space-separated list of tags files.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">terse | Short error messages.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">to | timeout - If this option is set, append mode<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| mappings will be interpreted only if they're<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| typed fast enough.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ts=<*> | tabstop - The length of a <ht>; warning: this is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| only IN the editor, outside of it <ht>s have<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| their normal length (default 8 positions).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">wa | writeany - No checks when writing (dangerous).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">warn | Warn you when you try to quit without writing.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">wi=<*> | window - The default number of lines vi shows.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">wm=<*> | wrapmargin - In append mode vi automatically<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| puts a <lf> whenever there is a <sp> or <ht><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| within <wm> columns from the right margin<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| (0 = don't put a <lf> in the file, yet put it<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| on the screen).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ws | wrapscan - When searching, the end is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">| considered `stuck' to the begin of the file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:set <option> | Turn <option> on.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:set no<option> | Turn <option> off.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:set <option>=<value> | Set <option> to <value>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:set | Show all non-default options and their values.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:set <option>? | Show <option>'s value.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:set all | Show all options and their values.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.6 Miscellaneous tips<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Although you should be able to come up with all of the following commands by<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">studying the tables of </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">commands, I have included a few examples that I have<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">found useful.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.6.1 Line deletions<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:g/string/d<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">deletes every line that contains </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">string</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, while<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:v/string/d<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">deletes every line that does </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">not </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">contain </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">string</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.6.2 Switching cases<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">In the replacement part of a substitution command, i.e. between the second \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">/</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">"<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">and third \</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">/</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">",<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">\u means make the following character upper case<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">\l means make the following character lower case<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">\U means make the rest of the replacement upper case<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">\L means make the rest of the replacement lower case<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">How about a few examples?<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">45<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">1. Make the _rst letter of every word from line 18 to 43 uppercase.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:18,43s/\<./\u&/g<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">2. Change \uPPeR" and \LoweR" in any mixture of cases to lowercase.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:s/[UuLl][PpOo][PpWw][Ee][Rr]/\L&/<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3. Make the whole _le uppercase.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:%s/.*/\U&/<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">4. Make the region from line </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">m </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">to line </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">n </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">all uppercase.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:'m,'ns/.*/\U&/<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">5. Make a paragraph all lowercase.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:?^$?,/^$/s/.*/\L&/<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">6. Make the _rst letter of every word in a paragraph uppercase.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:?^$?,/^$/s/\([^ ][^ ]*\)/\u&/g<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">7. Make the second word of each line uppercase.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:1,$s/^\([^ ]*\) \([^ ]*\) \(.*\)/\1 \U\2\e \3/<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.6.3 Spell checking in vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">To check the spelling of your document without exiting out of </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:!spell % > %.sp<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:e %.sp<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:e# (To get back to your document)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.6.4 Additional search and replace<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">To change </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Gravity isn't just a "good idea." It's the "law." </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">to </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">Gravity<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">isn't just a ``good idea.'' It's the ``law.'' </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:g/$/s/"\([^"]*\)"/``\1''/g<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">The following will _nd words that begin and end with a vowel:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">/\<[aeiouAEIOU][a-zA-Z']*[aeiouAEIOU]\><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">46<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.6.5 Removing blank lines<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Blank lines can be removed from a _le with any of the following:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:v/./d<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">or<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:g/^$/d<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">or<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:%!/usr/ucb/cat -s<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">or<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:%!sed /./,/^$/!d<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">Be aware that you may need to get rid of trailing whitespace _rst. This can be<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">accomplished with<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:%s/[ ^I]*$/!d<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.6.6 Writing from bu_ers<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">To save the contents of the </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">a </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">bu_er to </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">_lename</span><span style="font-size: 9pt; font-family: "Trebuchet MS";">, type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:e filename<return>"ap (to edit a new file and put 'a's contents in it)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:w (to save it)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">To save a portion of a _le to another _le you could type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">ma (mark text at the top of the region to be saved)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">mb (mark text at the bottom of the region to be saved)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">:'a,'b w filename<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">3.7 Further reading<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">A number of other </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">vi </span><span style="font-size: 9pt; font-family: "Trebuchet MS";">documents can be found via anonymous ftp in: /pub/vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">at cs.uwp.edu<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: "Trebuchet MS";">47<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 9pt; font-family: "Trebuchet MS";"><o:p> </o:p></span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-59184206252034808912008-07-31T02:14:00.000-07:002008-12-23T00:12:05.691-08:00Unix and Vi<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PlaceType"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PlaceName"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="country-region"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="City"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"></o:smarttagtype><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="State"></o:smarttagtype><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>support</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><!--[if !mso]><object classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id="ieooui"></object> <style> st1\:*{behavior:url(#ieooui) } </style> <![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????????¡ì????????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:T8; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T7; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T6; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T5; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T4; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T3; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T2; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T21; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T20; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T19; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T17; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T15; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T14; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T13; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T12; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T11; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T10; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} @font-face {font-family:T9; panose-1:0 0 0 0 0 0 0 0 0 0; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-format:other; mso-font-pitch:auto; mso-font-signature:3 0 0 0 1 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:SimSun;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.1.2 The shell<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">There are a number of di_erent \avors" of Unix available today. By di_erent<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">\avors" I mean di_erent command interpreters (called shells) which handle<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">your input in their own unique way. This manual covers the C shell only. Many<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of the things found here will be identical with other shells, but don't count on<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">it. It is possible to determine which shell is in use by typing </span><span style="font-size: 9pt; font-family: T9;">echo $SHELL</span><span style="font-size: 9pt; font-family: T21;">. The<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">response for the C shell is </span><span style="font-size: 9pt; font-family: T19;">/bin/csh </span><span style="font-size: 9pt; font-family: T21;">which is what you should get. One other<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">popular shell is the Bourne shell which would respond with </span><span style="font-size: 9pt; font-family: T19;">/bin/sh</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.1.3 Command syntax<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Unix commands begin with a command name, often followed by ags and arguments<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">some of which are optional. The generic syntax is:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">command [flags] argument1 argument2 ...<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Normally the ags are preceded by a hyphen to prevent them from being interpreted<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">as a _lename. For example, in the command line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ls -l avhrr<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">ls </span><span style="font-size: 9pt; font-family: T21;">is the program called, </span><span style="font-size: 9pt; font-family: T19;">-l </span><span style="font-size: 9pt; font-family: T21;">is the ag, and </span><span style="font-size: 9pt; font-family: T19;">avhrr </span><span style="font-size: 9pt; font-family: T21;">is the argument. This command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">tells the computer to list (in long format) the _le called </span><span style="font-size: 9pt; font-family: T19;">avhrr </span><span style="font-size: 9pt; font-family: T21;">or, if </span><span style="font-size: 9pt; font-family: T19;">avhrr </span><span style="font-size: 9pt; font-family: T21;">is a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">directory, to list all the _les in the directory </span><span style="font-size: 9pt; font-family: T19;">avhrr</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.1.4 Correcting typos<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">There are three tools to destroy typos that occur on the command line. </span><span style="font-size: 9pt; font-family: T15;">5<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"><<st1:state st="on"><st1:place st="on">DEL</st1:place></st1:state>> Erases the previous character.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"><ctrl-w> Erases the previous word.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"><ctrl-u> Erases the whole command line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.1.5 Controlling your terminal output<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">If output scrolls up on your terminal screen faster than you can read it, you can<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">suspend it by typing </span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">ctrl </span><span style="font-size: 9pt; font-family: T21;">-</span><span style="font-size: 9pt; font-family: T9;">S</span><span style="font-size: 9pt; font-family: T11;">></span><span style="font-size: 9pt; font-family: T21;">. To resume the display, type </span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">ctrl </span><span style="font-size: 9pt; font-family: T21;">-</span><span style="font-size: 9pt; font-family: T9;">S</span><span style="font-size: 9pt; font-family: T11;">></span><span style="font-size: 9pt; font-family: T21;">. Again<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">section 2.4.6 will discuss how to pass output through a paging program that will<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">automatically display only one screen at a time. While I'm at it, </span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">ctrl </span><span style="font-size: 9pt; font-family: T21;">-</span><span style="font-size: 9pt; font-family: T9;">C</span><span style="font-size: 9pt; font-family: T11;">> </span><span style="font-size: 9pt; font-family: T21;">will<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">abort a process, and </span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">ctrl </span><span style="font-size: 9pt; font-family: T21;">-</span><span style="font-size: 9pt; font-family: T9;">O</span><span style="font-size: 9pt; font-family: T11;">> </span><span style="font-size: 9pt; font-family: T21;">will discard the output until another </span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">ctrl </span><span style="font-size: 9pt; font-family: T21;">-</span><span style="font-size: 9pt; font-family: T9;">O</span><span style="font-size: 9pt; font-family: T11;">> </span><span style="font-size: 9pt; font-family: T21;">is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">entered. Be sure to note that although the output doesn't appear, the process<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">is still running. </span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">ctrl </span><span style="font-size: 9pt; font-family: T21;">-</span><span style="font-size: 9pt; font-family: T9;">Z</span><span style="font-size: 9pt; font-family: T11;">> </span><span style="font-size: 9pt; font-family: T21;">suspends the current program. You can see its job<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">number by typing </span><span style="font-size: 9pt; font-family: T19;">jobs</span><span style="font-size: 9pt; font-family: T21;">. You can resume the suspended program by giving the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">fg </span><span style="font-size: 9pt; font-family: T21;">(foreground) command, or resume it in the background with </span><span style="font-size: 9pt; font-family: T19;">bg</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">5</span><span style="font-size: 9pt; font-family: T13;">A couple notes on notation here. The delete key varies from keyboard to keyboard. Your<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T13;">delete key may be labeled </span><st1:state st="on"><st1:place st="on"><span style="font-size: 9pt; font-family: T8;">DEL</span></st1:place></st1:state><span style="font-size: 9pt; font-family: T8;">, DELETE, BACKSPACE, RUB, </span><span style="font-size: 9pt; font-family: T13;">or </span><span style="font-size: 9pt; font-family: T8;">RUBOUT</span><span style="font-size: 9pt; font-family: T13;">. Also, </span><span style="font-size: 9pt; font-family: T7;"><</span><span style="font-size: 9pt; font-family: T8;">ctrl</span><span style="font-size: 9pt; font-family: T13;">-<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">W</span><span style="font-size: 9pt; font-family: T7;">> </span><span style="font-size: 9pt; font-family: T13;">means holding down the </span><span style="font-size: 9pt; font-family: T7;"><</span><span style="font-size: 9pt; font-family: T8;">ctrl</span><span style="font-size: 9pt; font-family: T7;">> </span><span style="font-size: 9pt; font-family: T13;">key and pressing </span><span style="font-size: 9pt; font-family: T10;">W</span><span style="font-size: 9pt; font-family: T13;">. Control </span><span style="font-size: 9pt; font-family: T7;"><</span><span style="font-size: 9pt; font-family: T8;">ctrl</span><span style="font-size: 9pt; font-family: T7;">> </span><span style="font-size: 9pt; font-family: T13;">character commands<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T13;">are not case sensitive, i.e. </span><span style="font-size: 9pt; font-family: T7;"><</span><span style="font-size: 9pt; font-family: T8;">ctrl</span><span style="font-size: 9pt; font-family: T13;">-</span><span style="font-size: 9pt; font-family: T10;">w</span><span style="font-size: 9pt; font-family: T7;">> </span><span style="font-size: 9pt; font-family: T13;">is equivalent to </span><span style="font-size: 9pt; font-family: T7;"><</span><span style="font-size: 9pt; font-family: T8;">ctrl</span><span style="font-size: 9pt; font-family: T13;">-</span><span style="font-size: 9pt; font-family: T10;">W</span><span style="font-size: 9pt; font-family: T7;">></span><span style="font-size: 9pt; font-family: T13;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">2<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T17;">2.2 Files and directories<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">When you start a Unix session on a computer, you are placed in a directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">that contains your _les. This directory is called your </span><span style="font-size: 9pt; font-family: T19;">home </span><span style="font-size: 9pt; font-family: T21;">directory. My home<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">directory is </span><span style="font-size: 9pt; font-family: T19;">/home/cernan/<st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city></span><span style="font-size: 9pt; font-family: T21;">. You can create, copy, move, and remove _les<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">as well as create subdirectories from here (see section 2.4).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.2.1 Pathnames<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">There are a number of methods for specifying which directory and _le you<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">are interested in. Pathnames (the directory speci_cation) can be relative or<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">absolute. Absolute pathnames begin with a slash, </span><span style="font-size: 9pt; font-family: T9;">/</span><span style="font-size: 9pt; font-family: T21;">, and start at the root<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">directory. Successive directories down the path are also separated by a slash.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">In the previous paragraph I gave the absolute pathname of my home directory.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Each subdirectory is a branch in the directory tree.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">A relative pathname begins with the directory you are in (commonly referred<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to as </span><span style="font-size: 9pt; font-family: T19;">working </span><span style="font-size: 9pt; font-family: T21;">directory) and moves downward to a lower directory. Relative<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">pathnames begin with the name of the _rst directory below the working<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">directory. Each lower directory down the path should have a slash in front of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">it. Assuming I was in the </span><span style="font-size: 9pt; font-family: T19;">/home </span><span style="font-size: 9pt; font-family: T21;">directory, </span><span style="font-size: 9pt; font-family: T19;">cernan/taylor </span><span style="font-size: 9pt; font-family: T21;">would be the relative<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">pathname to my home directory. A \." indicates the working directory, while<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">\.." indicates the directory one level up (known as the </span><span style="font-size: 9pt; font-family: T19;">parent </span><span style="font-size: 9pt; font-family: T21;">directory). If<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">I were in my home directory, the relative pathname for the </span><span style="font-size: 9pt; font-family: T19;">/home </span><span style="font-size: 9pt; font-family: T21;">directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">would be </span><span style="font-size: 9pt; font-family: T19;">../.. </span><span style="font-size: 9pt; font-family: T21;">which says go to the \grandparent" directory two directories<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">higher than you are now.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.2.2 Naming _les and directories<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">In general, _le and directory names should be composed only of letters of the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">alphabet, digits, \." 's, and \ " 's. Be aware that _les that begin with a \." do<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">not appear in the directory list unless a special ag has been set when doing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the list command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The period is often used to add a su_x on to a base _lename. For example,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the source code for C programs have a </span><span style="font-size: 9pt; font-family: T19;">.c </span><span style="font-size: 9pt; font-family: T21;">su_x added to them, e.g. </span><span style="font-size: 9pt; font-family: T19;">prog.c</span><span style="font-size: 9pt; font-family: T21;">. Separating<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">a _lename by a \." is particularly useful when using wildcard selections<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">(see section 2.7.1).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T17;">2.3 Online manual<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">All of the commands in Unix are described online in a collection of _les. They<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">are known as </span><span style="font-size: 9pt; font-family: T19;">man pages </span><span style="font-size: 9pt; font-family: T21;">because they were originally pages of the </span><span style="font-size: 9pt; font-family: T19;">UNIX Pro-<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">grammer's Manual</span><span style="font-size: 9pt; font-family: T21;">. There are eight sections of the man pages:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">1. Commands<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">2. System calls<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">3<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">3. Library functions<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">4. Devices and device drivers<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">5. File formats<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">6. Games<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">7. Miscellaneous<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">8. System maintenance<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">If you know the name of a command, you can view its man pages by typing</span><span style="font-size: 9pt; font-family: T15;">6<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">man [section] name<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">A program called </span><span style="font-size: 9pt; font-family: T19;">apropos</span><span style="font-size: 9pt; font-family: T15;">7 </span><span style="font-size: 9pt; font-family: T21;">is available for those who don't know the name<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of the command they want. The </span><span style="font-size: 9pt; font-family: T19;">apropos </span><span style="font-size: 9pt; font-family: T21;">program searches through the header<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">lines of the man pages for whatever keyword you supply and displays a list of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the man pages containing it. For example,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">apropos copy<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">produces a list of all the man pages that contain </span><span style="font-size: 9pt; font-family: T19;">copy </span><span style="font-size: 9pt; font-family: T21;">in their header lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The list will contain commands followed by a number in parentheses, i.e. </span><span style="font-size: 9pt; font-family: T19;">cp<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">(1)</span><span style="font-size: 9pt; font-family: T21;">. The number in parentheses is the section number. If the section number is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">omitted when doing a </span><span style="font-size: 9pt; font-family: T19;">man </span><span style="font-size: 9pt; font-family: T21;">command, the </span><span style="font-size: 9pt; font-family: T19;">man </span><span style="font-size: 9pt; font-family: T21;">program searches through each<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">section until it _nds the named man page. This works _ne if the name is unique,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">but a few names exist in more than one section. One example of this is </span><span style="font-size: 9pt; font-family: T19;">intro</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">There is an </span><span style="font-size: 9pt; font-family: T19;">intro </span><span style="font-size: 9pt; font-family: T21;">man page for each section. Typing </span><span style="font-size: 9pt; font-family: T9;">man intro </span><span style="font-size: 9pt; font-family: T21;">would get you<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the </span><span style="font-size: 9pt; font-family: T19;">intro </span><span style="font-size: 9pt; font-family: T21;">man page for the _rst section, but the only way to get the </span><span style="font-size: 9pt; font-family: T19;">intro </span><span style="font-size: 9pt; font-family: T21;">man<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">page for section 5 is to type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">man 5 intro<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">When the man pages are being displayed on your terminal, it pauses after<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">each screen full and displays a </span><span style="font-size: 9pt; font-family: T9;">--More-- </span><span style="font-size: 9pt; font-family: T21;">on the bottom line. This give you a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">chance to read the information before you go on to the next screen full. Press<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the space bar to scroll an entire screen forward.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T17;">2.4 Basic commands<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The following few sections are devoted to many of the commands available in<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Unix. The descriptions are by no means complete. The most useful commands<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">(at least to me) have descriptions that should su_ce for the average user. However,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">less useful commands have rather terse summaries. If more information is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">desired for any of the commands, check the man pages. See section 2.3 on how<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to use the man pages.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">6</span><span style="font-size: 9pt; font-family: T13;">Portions of commands that are in square brackets, [ ], are optional.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">7</span><span style="font-size: 9pt; font-family: T13;">Typing </span><span style="font-size: 9pt; font-family: T10;">apropos </span><span style="font-size: 9pt; font-family: T13;">or </span><span style="font-size: 9pt; font-family: T10;">man -k </span><span style="font-size: 9pt; font-family: T13;">do the same thing.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">4<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.1 Logging on (rlogin)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">In order to use a computer operating under Unix you need to \log on". This<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">attempts to protect against unauthorized use of the computer equipment. It also<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">lets each user de_ne their own personalized working environment on the same<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">computer and even work on the same computer at the same time. The basic<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Unix command for remotely logging onto a computer is </span><span style="font-size: 9pt; font-family: T19;">rlogin </span><span style="font-size: 9pt; font-family: T21;">(remote login).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">To log onto a computer type </span><span style="font-size: 9pt; font-family: T9;">rlogin computername</span><span style="font-size: 9pt; font-family: T21;">. You are then asked to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">enter your account name, password, and then your charge code. Workstation<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">consoles, as well as x-terminals, are ready for your account name, password, and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">charge code. The </span><span style="font-size: 9pt; font-family: T19;">rlogin </span><span style="font-size: 9pt; font-family: T21;">command is not needed. The characters do not appear<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">when you type your password to promote con_dentiality.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.2 Changing your password (passwd)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Passwords are an important security measure. Don't neglect creating a \good"<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">password. A good password should be easy to remember for you but hard for<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">others to guess. Words in the dictionary, nicknames, and common chemical<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">compound names are poor choices for a password. One way of generating a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">password is to use the _rst letter of each word in a strange yet memorable<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">sentence. For example, </span><span style="font-size: 9pt; font-family: T19;">fatIwrnf </span><span style="font-size: 9pt; font-family: T21;">could be my password based on the sentence:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">For a time I would recommend no forgery</span><span style="font-size: 9pt; font-family: T21;">.</span><span style="font-size: 9pt; font-family: T15;">8<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">When you _rst receive your account you will probably be given a temporary<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">password. You should change your password to something else. This is done<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">with the </span><span style="font-size: 9pt; font-family: T19;">passwd </span><span style="font-size: 9pt; font-family: T21;">command. After typing </span><span style="font-size: 9pt; font-family: T9;">passwd</span><span style="font-size: 9pt; font-family: T21;">, you will be prompted _rst<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">for your current password and then twice for a new password. Please note that<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">this only e_ects the computer you are logged onto. You will need to repeat this<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">ritual on every computer you have an account on.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.3 Getting out (exit)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The command for ending a Unix session is </span><span style="font-size: 9pt; font-family: T19;">exit</span><span style="font-size: 9pt; font-family: T21;">. Another way to log out is to type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">ctrl</span><span style="font-size: 9pt; font-family: T21;">-D</span><span style="font-size: 9pt; font-family: T11;">></span><span style="font-size: 9pt; font-family: T21;">. To avoid accidentally ending your Unix session with an inadvertent<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">ctrl</span><span style="font-size: 9pt; font-family: T21;">-D</span><span style="font-size: 9pt; font-family: T11;">></span><span style="font-size: 9pt; font-family: T21;">, type the command </span><span style="font-size: 9pt; font-family: T9;">set ignoreeof </span><span style="font-size: 9pt; font-family: T21;">at the beginning of each Unix<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">session. Most lazy, or should I say e_cient, people don't like doing this every<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">time they log in. In section 2.6 we will discuss how to get around this threat to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">our slothfulness.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.4 Listing _les (ls)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The names of _les and subdirectories can be displayed with the </span><span style="font-size: 9pt; font-family: T19;">ls </span><span style="font-size: 9pt; font-family: T21;">(list) command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Typing </span><span style="font-size: 9pt; font-family: T9;">ls </span><span style="font-size: 9pt; font-family: T21;">lists the _les and subdirectories located in the working direc-<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">8</span><span style="font-size: 9pt; font-family: T13;">This sentence is especially interesting because the number of letters in each word make<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T13;">up the constant pi to eight signi_cant digits.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">5<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">tory that don't begin with a \.". To see all the names, use the all ag, i.e. </span><span style="font-size: 9pt; font-family: T9;">ls<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T9;">-a</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Other interesting ags for the </span><span style="font-size: 9pt; font-family: T19;">ls </span><span style="font-size: 9pt; font-family: T21;">command are:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-F Marks directories with a trailing slash and executable files with<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">a trailing asterisk.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-l Lists in long format. Gives all sorts of information.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-R Recursively lists subdirectories encountered.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-s Gives the size of each file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-t Sorts by time modified instead of by name.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">It is possible to limit the scope of the _les and subdirectories by using the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">wildcard characters discussed in section 2.7.1. For example, I would type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ls q*<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">if I wanted to list all the _les and subdirectories that began with a </span><span style="font-size: 9pt; font-family: T19;">q</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Note that the </span><span style="font-size: 9pt; font-family: T19;">ls </span><span style="font-size: 9pt; font-family: T21;">command lists _les in the working directory only, unless you<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">include the pathname to another directory whose _lenames you want to list.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.5 Catenate (cat)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Catenate means \to connect in a series." The </span><span style="font-size: 9pt; font-family: T19;">cat </span><span style="font-size: 9pt; font-family: T21;">command displays the contents<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of a _le. If more than one _le is placed in the command line, i.e. </span><span style="font-size: 9pt; font-family: T9;">cat yellow<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T9;">blue</span><span style="font-size: 9pt; font-family: T21;">, the _les are displayed in succession. It is here that </span><span style="font-size: 9pt; font-family: T19;">cat </span><span style="font-size: 9pt; font-family: T21;">derives its name.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">With the use of the redirection operator (see section 2.7.2) two _les can be<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">placed into a single _le. Typing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cat yellow blue > green<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">will cause </span><span style="font-size: 9pt; font-family: T19;">green </span><span style="font-size: 9pt; font-family: T21;">to contain the contents of </span><span style="font-size: 9pt; font-family: T19;">yellow </span><span style="font-size: 9pt; font-family: T21;">followed by the contents of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">blue</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.6 Paging display system (more)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">more </span><span style="font-size: 9pt; font-family: T21;">command provides a convenient alternative to displaying text on<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">your terminal. The </span><span style="font-size: 9pt; font-family: T19;">more </span><span style="font-size: 9pt; font-family: T21;">program takes the input text and displays one screen<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">full worth. The last line of the screen contains </span><span style="font-size: 9pt; font-family: T9;">--More--</span><span style="font-size: 9pt; font-family: T21;">. To scroll an entire<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">screen forward, press the space bar. To scroll forward one line at a time, press<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">return</span><span style="font-size: 9pt; font-family: T11;">></span><span style="font-size: 9pt; font-family: T21;">. To enter the </span><span style="font-size: 9pt; font-family: T19;">vi </span><span style="font-size: 9pt; font-family: T21;">text editor (see section 3), type </span><span style="font-size: 9pt; font-family: T9;">v</span><span style="font-size: 9pt; font-family: T21;">. To quit reading,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">type </span><span style="font-size: 9pt; font-family: T9;">q</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">More </span><span style="font-size: 9pt; font-family: T21;">can be used on a text _le by typing </span><span style="font-size: 9pt; font-family: T9;">more filename </span><span style="font-size: 9pt; font-family: T21;">or can be used to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">display the output from another program with the use of the pipe symbol (see<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">section 2.7.3) by typing </span><span style="font-size: 9pt; font-family: T9;">command | more</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">6<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.7 Copying _les (cp)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">cp </span><span style="font-size: 9pt; font-family: T21;">(copy) command lets you duplicate a _le of choice. Here is an explanation<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">by examples:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cp cocoon butterfly<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">makes a duplicate of the _le </span><span style="font-size: 9pt; font-family: T19;">cocoon </span><span style="font-size: 9pt; font-family: T21;">and gives it the name </span><span style="font-size: 9pt; font-family: T19;">buttery</span><span style="font-size: 9pt; font-family: T21;">. Note that<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the _lenames can include pathnames as well.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cp /home/cernan/taylor/tex/contract ../contract.bak<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">makes a copy of the _le </span><span style="font-size: 9pt; font-family: T19;">contract </span><span style="font-size: 9pt; font-family: T21;">found in the </span><span style="font-size: 9pt; font-family: T19;">/home/cernan/<st1:city st="on">taylor</st1:city>/<st1:state st="on"><st1:place st="on">tex</st1:place></st1:state> </span><span style="font-size: 9pt; font-family: T21;">directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and places it one directory level above the working directory in a _le called<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">contract.bak</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">If </span><span style="font-size: 9pt; font-family: T19;">/home/cernan/<st1:city st="on">taylor</st1:city>/<st1:state st="on"><st1:place st="on">tex</st1:place></st1:state> </span><span style="font-size: 9pt; font-family: T21;">is a directory, then<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cp report /home/cernan/taylor/tex<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">will place a copy of </span><span style="font-size: 9pt; font-family: T19;">report </span><span style="font-size: 9pt; font-family: T21;">in the </span><span style="font-size: 9pt; font-family: T19;">/home/cernan/<st1:city st="on">taylor</st1:city>/<st1:state st="on"><st1:place st="on">tex</st1:place></st1:state> </span><span style="font-size: 9pt; font-family: T21;">directory with the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">name </span><span style="font-size: 9pt; font-family: T19;">report</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cp /home/cernan/taylor/tex/headlines .<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">will copy the _le </span><span style="font-size: 9pt; font-family: T19;">headlines </span><span style="font-size: 9pt; font-family: T21;">in the </span><span style="font-size: 9pt; font-family: T19;">/home/cernan/<st1:city st="on">taylor</st1:city>/<st1:state st="on"><st1:place st="on">tex</st1:place></st1:state> </span><span style="font-size: 9pt; font-family: T21;">directory into the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">working directory. The name will remain unchanged.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cp /home/cernan/<st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city>/tex/* .<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">will copy all the _les (but not the subdirectories) in </span><span style="font-size: 9pt; font-family: T19;">/home/cernan/taylor/tex<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">into the working directory. You can copy all the subdirectories in the directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and _les contained in them by using the </span><span style="font-size: 9pt; font-family: T19;">-r </span><span style="font-size: 9pt; font-family: T21;">(recursive) ag as follows:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cp -r /home/cernan/taylor/tex/* .<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Another useful ag is the </span><span style="font-size: 9pt; font-family: T19;">-i </span><span style="font-size: 9pt; font-family: T21;">(interactive) ag which prompts you if you are<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">about to overwrite an existing _le.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.8 Removing _les (rm)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">rm </span><span style="font-size: 9pt; font-family: T21;">(remove) command deletes _les that you no longer want. Just type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T9;">rm filename </span><span style="font-size: 9pt; font-family: T21;">to remove the _le </span><span style="font-size: 9pt; font-family: T19;">_lename</span><span style="font-size: 9pt; font-family: T21;">. If more than one _lename is on the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">command line, i.e. </span><span style="font-size: 9pt; font-family: T9;">rm archaeologists date anything</span><span style="font-size: 9pt; font-family: T21;">, then the _les </span><span style="font-size: 9pt; font-family: T19;">archae-<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">ologists</span><span style="font-size: 9pt; font-family: T21;">, </span><span style="font-size: 9pt; font-family: T19;">date</span><span style="font-size: 9pt; font-family: T21;">, and </span><span style="font-size: 9pt; font-family: T19;">anything </span><span style="font-size: 9pt; font-family: T21;">are removed.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">7<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.9 Renaming and moving _les and directories (mv)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">mv </span><span style="font-size: 9pt; font-family: T21;">(move) command moves a _le from the _rst argument to the second<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">argument, e.g.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">mv neatguy tidyguy<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">moves the contents of </span><span style="font-size: 9pt; font-family: T19;">neatguy </span><span style="font-size: 9pt; font-family: T21;">to the contents of </span><span style="font-size: 9pt; font-family: T19;">tidyguy</span><span style="font-size: 9pt; font-family: T21;">. This commandreminds<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">me of the time Chicago Bulls forward Stacey King said:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T6;">I'll always remember this as the night that Michael Jordan and I combined<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T6;">to score 70 points.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">after scoring one point in a game in which <st1:country-region st="on"><st1:place st="on">Jordan</st1:place></st1:country-region> scored sixty-nine. All that<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">really happened was that the _le's name was changed. The reason it is called<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the </span><span style="font-size: 9pt; font-family: T19;">move </span><span style="font-size: 9pt; font-family: T21;">instead of </span><span style="font-size: 9pt; font-family: T19;">rename </span><span style="font-size: 9pt; font-family: T21;">or something like that is that you can include<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">pathnames (just like you have done before in </span><span style="font-size: 9pt; font-family: T19;">cp </span><span style="font-size: 9pt; font-family: T21;">and </span><span style="font-size: 9pt; font-family: T19;">rm</span><span style="font-size: 9pt; font-family: T21;">). Including pathnames<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">allows you to move a _le into a di_erent directory, hence the name. The </span><span style="font-size: 9pt; font-family: T19;">mv<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">command works on both _lenames and directory names exactly the same way.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">-i </span><span style="font-size: 9pt; font-family: T21;">ag works here just like it worked with </span><span style="font-size: 9pt; font-family: T19;">cp</span><span style="font-size: 9pt; font-family: T21;">. Setting this ag will<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">prompt you before it moves a _le on top of one that already exists.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">WARNING: for (</span><span style="font-size: 9pt; font-family: T11;">i </span><span style="font-size: 9pt; font-family: T21;">= 0 ; </span><span style="font-size: 9pt; font-family: T11;">i <</span><span style="font-size: 9pt; font-family: T21;">= 50 ; </span><span style="font-size: 9pt; font-family: T11;">i</span><span style="font-size: 9pt; font-family: T21;">++) printf(\Don't "); don't use wildcards<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">(see section 2.7.1) with the </span><span style="font-size: 9pt; font-family: T19;">mv </span><span style="font-size: 9pt; font-family: T21;">command unless the destination is a directory.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">mv </span><span style="font-size: 9pt; font-family: T21;">command doesn't know what to do if you tell it to move a bunch of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">_les into a single _lename and so it will move all the _les you selected on top of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">each other.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.10 Navigating the directory tree (cd)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">cd </span><span style="font-size: 9pt; font-family: T21;">(change directory) command does just what it says. It changes your<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">working directory. The command syntax is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cd pathname<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where the </span><span style="font-size: 9pt; font-family: T19;">pathname </span><span style="font-size: 9pt; font-family: T21;">can be either relative or absolute.</span><span style="font-size: 9pt; font-family: T15;">9<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.4.11 Directory creation and destruction (mkdir and rmdir)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">New directories are created with the </span><span style="font-size: 9pt; font-family: T19;">mkdir </span><span style="font-size: 9pt; font-family: T21;">(make directory) command and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">removed with the </span><span style="font-size: 9pt; font-family: T19;">rmdir </span><span style="font-size: 9pt; font-family: T21;">(remove directory) command. The syntax is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">mkdir directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">9</span><span style="font-size: 9pt; font-family: T13;">If these words don't make sense to you, you are either not paying attention or aren't<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T13;">reading this in order. I don't have a problem if you aren't reading this sequentially if you are<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T13;">willing to deal with some of this terminology ambiguity, but if you are struggling with the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T13;">_rst problem, go back and reread section 1.2.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">8<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">rmdir directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">pwd </span><span style="font-size: 9pt; font-family: T21;">(print working directory) command displays the absolute pathname<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of your working directory.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T17;">2.5 Additional commands<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">A number of additional commands are listed in this section. If you have forgotten<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">what is in section 2.3, see section 1.2 and then section 2.3 for advice on how<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to get more information about the commands in this section.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.1 alias<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">alias </span><span style="font-size: 9pt; font-family: T21;">command allows you to de_ne shortcuts to save yourself time. In a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">sense, </span><span style="font-size: 9pt; font-family: T19;">alias </span><span style="font-size: 9pt; font-family: T21;">creates a link between a requested set of keystrokes and another<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">set of keystrokes. For example, to use the </span><span style="font-size: 9pt; font-family: T19;">rm </span><span style="font-size: 9pt; font-family: T21;">command in interactive mode I<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">would type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">rm -i<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">By typing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias rm 'rm -i'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the alias command would allow me to avoid typing the interactive ag, </span><span style="font-size: 9pt; font-family: T19;">-i </span><span style="font-size: 9pt; font-family: T21;">,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">every time a called the </span><span style="font-size: 9pt; font-family: T19;">rm </span><span style="font-size: 9pt; font-family: T21;">command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">alias </span><span style="font-size: 9pt; font-family: T21;">command de_nes a link between the _rst and the second arguments<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">following the command. Whenever the _rst argument is entered at the command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">prompt, the Unix shell substitutes it with the second argument. An </span><span style="font-size: 9pt; font-family: T19;">alias </span><span style="font-size: 9pt; font-family: T21;">link<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">stays in e_ect until the Unix session is ended or the link is \</span><span style="font-size: 9pt; font-family: T19;">unalias</span><span style="font-size: 9pt; font-family: T21;">ed". To<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">destroy the link in my previous example I would type </span><span style="font-size: 9pt; font-family: T9;">unalias x</span><span style="font-size: 9pt; font-family: T21;">. The power of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">this command is more easily realized when used in a login _le (see section 2.6).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.2 ap<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">(auto pilot) command has a deceptive name. It doesn't actually place<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the computer on auto pilot. The </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">command reads your mind and attempts<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to perform the commands you want done. For example, thinking \I really wish<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">I had a backup copy of the </span><span style="font-size: 9pt; font-family: T19;">tanana </span><span style="font-size: 9pt; font-family: T21;">image." will cause </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">to input<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cp tanana.* tanana_bak.*<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to the Unix shell. Preceding a thought with \ignore" will cause </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">to ignore<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">your next thought. Although, with enough practice, the </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">command can be a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">signi_cant time saver, there are a few unresolved problems with this command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">9<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">1. I often change my mind while in the thinking process. In the previous<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">example I may have decided later that I wanted to call the backup copy<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">something else. No big deal here, </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">just changes the _lename but it isn't<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the most e_cient use of computer resources.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">2. All of the commands are echoed to the screen so that you know exactly<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">what is going on. This is great as long as you remember to think \ignore"<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">before you read each command. If you forget, the command will<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">be executed again. This will continue until you remember to include the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">\ignore" ag or you think, \What is going on here?" which will cause the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">man pages for the particular command you are repeating to be displayed.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">3. The </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">command reads the strongest mind waves (known as </span><span style="font-size: 9pt; font-family: T19;">grey waves</span><span style="font-size: 9pt; font-family: T21;">)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">that it _nds. If you have weak grey waves or your monitor is closer to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">someone else in your o_ce, </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">may listen to someone else's mind instead<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of yours. Also, walls do not provide insulation from grey waves, so if your<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">monitor is near a wall, be prepared for some grey waves from minds on<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the other side of the wall to occasionally sneak in.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">4. As you probably know, humans (you included) don't use their brains to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">their highest potential. In fact, many believe that we use as little as 5%<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of our brain's capacity. The problem here is that </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">is only able to read<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">around 80% of your mind. Unfortunately, many people use the 5% of their<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">mind that </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">can't read. When </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">is called it scans your mind for activity,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">if none is found it prints the following cryptic error message:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ap: Command not found.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">This indicates that it couldn't _nd a command in your head. Don't worry,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">this doesn't mean that you aren't thinking, it just means that you use the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">part of your brain that </span><span style="font-size: 9pt; font-family: T19;">ap </span><span style="font-size: 9pt; font-family: T21;">can't access.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.3 bi_<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">bi_ </span><span style="font-size: 9pt; font-family: T21;">command runs in the background and lets you know when electronic<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">mail arrives. It was named after a dog at <st1:city st="on"><st1:place st="on">Berkeley</st1:place></st1:city> that was known for barking<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">at the mailman. To tell </span><span style="font-size: 9pt; font-family: T19;">bi_ </span><span style="font-size: 9pt; font-family: T21;">to bark at the mailman, type </span><span style="font-size: 9pt; font-family: T9;">biff y</span><span style="font-size: 9pt; font-family: T21;">. To tell </span><span style="font-size: 9pt; font-family: T19;">bi_<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">not to bark at the mailman, type </span><span style="font-size: 9pt; font-family: T9;">biff n</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.4 chmod<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Your _les and directories have a number of attributes that are set when they<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">are created. Listing the _les with the </span><span style="font-size: 9pt; font-family: T19;">-l </span><span style="font-size: 9pt; font-family: T21;">ag, i.e. </span><span style="font-size: 9pt; font-family: T9;">ls -l</span><span style="font-size: 9pt; font-family: T21;">, displays the attributes<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of each _le and directory in the working directory. Here is an example listing:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">10<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">total 3<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">drwxr-xr-x 2 <st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city> 512 Aug 2 08:41 .<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">drwxrwxr-x 12 <st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city> 1024 Aug 2 08:41 ..<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-rw-r--r-- 1 <st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city> 5 Aug 2 08:41 blue<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-rw-r--r-- 1 <st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city> 12 Aug 2 08:41 green<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-rw-r--r-- 1 <st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city> 7 Aug 2 08:41 yellow<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">To the far left of each _le or directory name are ten characters which show<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the attributes. The _rst column indicates whether the entry is a directory (</span><span style="font-size: 9pt; font-family: T9;">d</span><span style="font-size: 9pt; font-family: T21;">)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">or not (</span><span style="font-size: 9pt; font-family: T9;">-</span><span style="font-size: 9pt; font-family: T21;">). The other nine characters are organized into three groups of the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">three. The _rst group pertains to the owner (that would be you for your _les).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The second group pertains to people in your group, if you are in a group. The<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">third group pertains to everyone else. Within each group of three are three<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">characters. The _rst indicates read (</span><span style="font-size: 9pt; font-family: T9;">r</span><span style="font-size: 9pt; font-family: T21;">) permission. The second indicates write<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">(</span><span style="font-size: 9pt; font-family: T9;">w</span><span style="font-size: 9pt; font-family: T21;">) permission. The third indicates execute (</span><span style="font-size: 9pt; font-family: T9;">x</span><span style="font-size: 9pt; font-family: T21;">) permission. If the permission is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">not present, a \</span><span style="font-size: 9pt; font-family: T9;">-</span><span style="font-size: 9pt; font-family: T21;">" will replace the </span><span style="font-size: 9pt; font-family: T19;">r</span><span style="font-size: 9pt; font-family: T21;">, </span><span style="font-size: 9pt; font-family: T19;">w</span><span style="font-size: 9pt; font-family: T21;">, or </span><span style="font-size: 9pt; font-family: T19;">x</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">chmod </span><span style="font-size: 9pt; font-family: T21;">(change mode) command lets you change the attributes on a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">_le or directory. There are a number of forms, but I have chosen to cover the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">following syntax because of its similarity with </span><span style="font-size: 9pt; font-family: T19;">umask</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">chmod mode filename<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T19;">mode </span><span style="font-size: 9pt; font-family: T21;">is a three digit octal number. The _rst digit pertains to the owners<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">privileges. The second pertains to the groups privileges, and the third pertains<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to everyone elses privileges. Each octal digit is composed of the addition of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">three components. The read component is worth 4, the write component worth<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">2, and the execute component worth 1. Suppose I wanted the owner to have<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">read, write, and execute privileges, the group to have read and write privileges,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and everyone else to have read privileges only. The octal number I would use<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">with </span><span style="font-size: 9pt; font-family: T19;">chmod </span><span style="font-size: 9pt; font-family: T21;">would be </span><span style="font-size: 9pt; font-family: T9;">764</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.5 compress/uncompress<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">compress </span><span style="font-size: 9pt; font-family: T21;">and </span><span style="font-size: 9pt; font-family: T19;">uncompress </span><span style="font-size: 9pt; font-family: T21;">commands compress a selected _le using adaptive<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Lempel-Ziv coding to help conserve disk space. This technique almost always<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">does a better job than the Hu_man coding technique used by the </span><span style="font-size: 9pt; font-family: T19;">pack</span><span style="font-size: 9pt; font-family: T21;">/</span><span style="font-size: 9pt; font-family: T19;">unpack<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">commands. Typing </span><span style="font-size: 9pt; font-family: T9;">compress <st1:place st="on">edison</st1:place> </span><span style="font-size: 9pt; font-family: T21;">would create a compressed _le called<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">edison.Z </span><span style="font-size: 9pt; font-family: T21;">which could be resorted to its original condition by typing </span><span style="font-size: 9pt; font-family: T9;">uncompress<o:p></o:p></span></p> <p class="MsoNormal" style=""><st1:place st="on"><span style="font-size: 9pt; font-family: T9;">edison</span></st1:place><span style="font-size: 9pt; font-family: T9;"> </span><span style="font-size: 9pt; font-family: T21;">or </span><span style="font-size: 9pt; font-family: T9;">uncompress edison.Z</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.6 df<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">df </span><span style="font-size: 9pt; font-family: T21;">(disk free) command displays the amount of free disk space. This is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">often quite handy when determining if there is enough space to store an image<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">on a particular hard drive. A quick glance at the man pages should indicate<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">what ags should be set for the computer you are on.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">11<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.7 di_<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">This program is useful in determining di_erences between two _les or directories.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">It produces a list of lines that must be changed (c), appended (a), or deleted<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">(d) to make the _rst _le match the second. Lines from the _rst _le are pre_xed<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">by \</span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T21;">" and lines from the second are pre_xed by \</span><span style="font-size: 9pt; font-family: T11;">></span><span style="font-size: 9pt; font-family: T21;">".<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">-b </span><span style="font-size: 9pt; font-family: T21;">option ignores trailing blanks and treats all other strings of blanks<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">as equivalent. The </span><span style="font-size: 9pt; font-family: T19;">-i </span><span style="font-size: 9pt; font-family: T21;">option removes case sensitivity so that uppercase and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">lowercase letters match.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.8 du<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">du </span><span style="font-size: 9pt; font-family: T21;">(disk usage) command displays the number of kilobytes consumed by<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">each _le and recursively provides results on directories. This can be useful for<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">determining who the big disk space hogs are when you need more room. Typing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">du -s *<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">from the parent directory of your home directory, e.g. </span><span style="font-size: 9pt; font-family: T19;">/home/cernan</span><span style="font-size: 9pt; font-family: T21;">, gives a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">grand total of the kilobytes consumed by each user.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.9 echo<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">echo </span><span style="font-size: 9pt; font-family: T21;">command echos a string to the terminal. One use for this command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">is in determining the contents of environment variables. Environment variables<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">are variables that Unix keeps track of at the shell level. Two common examples<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">are TERM and PATH. The TERM variable identi_es what kind of terminal you<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">are using. The PATH variable contains a list of pathnames to search through<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">when looking for commands. More information on environment variables can<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">be found in section 2.6.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">To see the contents of the TERM variable type </span><span style="font-size: 9pt; font-family: T9;">echo $TERM</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.10 _nd<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">_nd </span><span style="font-size: 9pt; font-family: T21;">command recursively descends through the directory tree looking for<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">_les that match a logical expression. The </span><span style="font-size: 9pt; font-family: T19;">_nd </span><span style="font-size: 9pt; font-family: T21;">command has many options and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">is very powerful. Rather than go into detail here, I encourage you to take a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">look at the man pages for </span><span style="font-size: 9pt; font-family: T19;">_nd</span><span style="font-size: 9pt; font-family: T21;">. The </span><span style="font-size: 9pt; font-family: T19;">_nd </span><span style="font-size: 9pt; font-family: T21;">command does have a rather contorted<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">syntax which is not easily mastered, and if truth be written, that's why I'm not<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">spending more paper on it here.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.11 _nger<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">_nger </span><span style="font-size: 9pt; font-family: T21;">command displays information about users. It can be used both<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">locally and across the internet. For example,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">finger taylor@en.ecn.purdue.edu<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">12<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">will display information about me from my computer account at <st1:place st="on"><st1:placename st="on">Purdue</st1:placename> <st1:placetype st="on">University</st1:placetype></st1:place>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.12 ftp<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The easiest way to copy _les from one disk to another is to use the </span><span style="font-size: 9pt; font-family: T19;">cp </span><span style="font-size: 9pt; font-family: T21;">command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">However, often I am interested in copying _les from one computer to another.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">ftp </span><span style="font-size: 9pt; font-family: T21;">command uses the File Transfer Protocol (</span><span style="font-size: 9pt; font-family: T5;">ftp</span><span style="font-size: 9pt; font-family: T21;">) to transfer data over a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">network connection.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">To use </span><span style="font-size: 9pt; font-family: T19;">ftp </span><span style="font-size: 9pt; font-family: T21;">you open a connection to a remote computer and log onto that<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">computer that can't access each others hard drives. The remote computer runs<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">its own version of </span><span style="font-size: 9pt; font-family: T19;">ftp</span><span style="font-size: 9pt; font-family: T21;">, but you are in control of it. Within the </span><span style="font-size: 9pt; font-family: T19;">ftp </span><span style="font-size: 9pt; font-family: T21;">program<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">you can list the _les in your remote computer's directory, get copies of _les on<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the remote computer, put copies of _les from your computer onto the remote<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">computer, and even delete _les on the remote computer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Here is an example of a </span><span style="font-size: 9pt; font-family: T5;">ftp </span><span style="font-size: 9pt; font-family: T21;">session:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ftp baboon (1)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">Connected to baboon.ecn.purdue.edu.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">220 baboon.ecn.purdue.edu FTP server (Version 4.178 Tue Jun 18 13:30:39<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">EST 1991) ready.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">Name (baboon:<st1:city st="on">taylor</st1:city>): <st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city> (2)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">331 Password required for <st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city>.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">Password: xxxxx<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">230 User <st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city> logged in.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ftp> cd tex/manual (3)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">250 CWD command successful.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ftp> get chap1.tex chap1.tex.bak (4)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">200 PORT command successful.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">150 ASCII data connection for chap1.tex (8612 bytes).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">226 ASCII Transfer complete.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">local: chap1.tex.bak remote: chap1.tex<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">8848 bytes received in 0.45 seconds (19 Kbytes/s)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ftp> quit (5)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">221 Goodbye.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">1. This starts the </span><span style="font-size: 9pt; font-family: T19;">ftp </span><span style="font-size: 9pt; font-family: T21;">program and tells it to open a connection with the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">computer called </span><span style="font-size: 9pt; font-family: T19;">baboon</span><span style="font-size: 9pt; font-family: T21;">.</span><span style="font-size: 9pt; font-family: T15;">10<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">2. Here you need to type in the name of your account on the remote computer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">If the name of your account on the remote computer is the same as<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the account on your local computer, you don't need to type in the account<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">name but can just hit </span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">enter</span><span style="font-size: 9pt; font-family: T11;">></span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">3. The </span><span style="font-size: 9pt; font-family: T19;">cd </span><span style="font-size: 9pt; font-family: T21;">command works like it does in Unix with one exception that we<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">won't go into here.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">10</span><span style="font-size: 9pt; font-family: T13;">If you are attempting to open a connection with a computer outside of the Engineering<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T13;">Computer Network (</span><span style="font-size: 9pt; font-family: T4;">ecn</span><span style="font-size: 9pt; font-family: T13;">), you will need to include the entire internet address. In this case it<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T13;">would be </span><span style="font-size: 9pt; font-family: T8;">baboon.ecn.purdue.edu</span><span style="font-size: 9pt; font-family: T13;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">13<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">4. This copies the _le </span><span style="font-size: 9pt; font-family: T19;">chap1.tex </span><span style="font-size: 9pt; font-family: T21;">from the remote computer to </span><span style="font-size: 9pt; font-family: T19;">chap1.bak<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">in your local working directory. If no destination _le is given the </span><span style="font-size: 9pt; font-family: T19;">get<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">command gives the _le the same name on the local computer. The </span><span style="font-size: 9pt; font-family: T19;">put<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">command will send a _le from the local computer to the remote computer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">get </span><span style="font-size: 9pt; font-family: T21;">and </span><span style="font-size: 9pt; font-family: T19;">put </span><span style="font-size: 9pt; font-family: T21;">commands don't like wildcards. (See section 2.7.1 for<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">a discussion of wildcards.) If you want to copy a number of _les that<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">have similar names but don't have the energy to type in all the names<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">individually the suggestion of </span><span style="font-size: 9pt; font-family: T19;">mget </span><span style="font-size: 9pt; font-family: T21;">and </span><span style="font-size: 9pt; font-family: T19;">mput </span><span style="font-size: 9pt; font-family: T21;">may make you very happy<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">that you read this manual.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">5. Typing </span><span style="font-size: 9pt; font-family: T9;">quit </span><span style="font-size: 9pt; font-family: T21;">gets you out of the </span><span style="font-size: 9pt; font-family: T19;">ftp </span><span style="font-size: 9pt; font-family: T21;">program.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">A short explanation of the available commands can be coaxed onto your<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">screen by typing </span><span style="font-size: 9pt; font-family: T9;">help </span><span style="font-size: 9pt; font-family: T21;">at the </span><span style="font-size: 9pt; font-family: T9;">ftp</span><span style="font-size: 9pt; font-family: T11;">> </span><span style="font-size: 9pt; font-family: T21;">prompt.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.13 grep<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">grep </span><span style="font-size: 9pt; font-family: T21;">(get regular expression) program searches for an expression in a _le<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">or group of _les. There are three versions: </span><span style="font-size: 9pt; font-family: T19;">grep</span><span style="font-size: 9pt; font-family: T21;">, </span><span style="font-size: 9pt; font-family: T19;">egrep </span><span style="font-size: 9pt; font-family: T21;">(extended grep), and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">fgrep </span><span style="font-size: 9pt; font-family: T21;">(_xed-string </span><span style="font-size: 9pt; font-family: T19;">grep</span><span style="font-size: 9pt; font-family: T21;">). The </span><span style="font-size: 9pt; font-family: T19;">grep </span><span style="font-size: 9pt; font-family: T21;">program expands wildcard characters in<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the given expression. The </span><span style="font-size: 9pt; font-family: T19;">egrep </span><span style="font-size: 9pt; font-family: T21;">program searches for the expression including<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">alternations. The </span><span style="font-size: 9pt; font-family: T19;">fgrep </span><span style="font-size: 9pt; font-family: T21;">program searches for _xed-strings only and does not<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">expand wildcard characters. The </span><span style="font-size: 9pt; font-family: T19;">egrep </span><span style="font-size: 9pt; font-family: T21;">program has more sophisticated internal<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">algorithms, and is usually faster than </span><span style="font-size: 9pt; font-family: T19;">grep </span><span style="font-size: 9pt; font-family: T21;">or </span><span style="font-size: 9pt; font-family: T19;">fgrep</span><span style="font-size: 9pt; font-family: T21;">. The syntax for all three<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">versions is:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">command [options] expression [file] ...<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">I have found these Unix commands to be very useful when programming.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Suppose I had a C program with a number of subroutines and a global variable<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">labeled </span><span style="font-size: 9pt; font-family: T19;">chuck wivell</span><span style="font-size: 9pt; font-family: T21;">. Suppose further that Chuck found out about this and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">didn't like it. Of course I would change it immediately.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">egrep chuck_wivell *.c<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">would give me a list of all _les where the o_ensive variable manifested itself. By<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">placing a </span><span style="font-size: 9pt; font-family: T9;">-n </span><span style="font-size: 9pt; font-family: T21;">option in the command line I could also obtain the line numbers<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of the o_enses.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The wildcard characters that </span><span style="font-size: 9pt; font-family: T19;">grep </span><span style="font-size: 9pt; font-family: T21;">handles are<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">\ [ ] . ^ * $<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and a delimiter used to mark the beginning and end of an expression. Delimiters<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">are necessary only if the expression contains blanks or wildcard characters. Here<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">are a few examples to help solidify this potential mumbo-jumbo:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">grep 'Nostalgia is not what it used to be' fft.c<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">14<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">searches through the _le </span><span style="font-size: 9pt; font-family: T19;">_t.c </span><span style="font-size: 9pt; font-family: T21;">for the expression </span><span style="font-size: 9pt; font-family: T19;">Nostalgia is not what it used to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">be</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The wildcard character \." matches any character. Therefore,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">grep 'eur.' fft.c<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">would _nd </span><span style="font-size: 9pt; font-family: T19;">eureka</span><span style="font-size: 9pt; font-family: T21;">, </span><span style="font-size: 9pt; font-family: T19;">amateur</span><span style="font-size: 9pt; font-family: T21;">, </span><span style="font-size: 9pt; font-family: T19;">chau_eur</span><span style="font-size: 9pt; font-family: T21;">, etc</span><span style="font-size: 9pt; font-family: T11;">: : : </span><span style="font-size: 9pt; font-family: T21;">in the _le </span><span style="font-size: 9pt; font-family: T19;">_t.c</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Characters placed inside square brackets are each compared when searching.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">grep '[cm]an' fft.c<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">would _nd any words with the sequence </span><span style="font-size: 9pt; font-family: T19;">can </span><span style="font-size: 9pt; font-family: T21;">or </span><span style="font-size: 9pt; font-family: T19;">man</span><span style="font-size: 9pt; font-family: T21;">, but would not locate<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">sequences like </span><span style="font-size: 9pt; font-family: T19;">ran </span><span style="font-size: 9pt; font-family: T21;">or </span><span style="font-size: 9pt; font-family: T19;">and</span><span style="font-size: 9pt; font-family: T21;">. More can be found on the wildcard characters in<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">section 2.7.1.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Preceding a wildcard character by a \</span><span style="font-size: 9pt; font-family: T20;">n</span><span style="font-size: 9pt; font-family: T21;">" turns o_ the wildcard character<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">feature and the character is treated normally, i.e. the expression </span><span style="font-size: 9pt; font-family: T9;">eddie</span><span style="font-size: 9pt; font-family: T20;">n</span><span style="font-size: 9pt; font-family: T9;">. </span><span style="font-size: 9pt; font-family: T21;">would<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">yield all the </span><span style="font-size: 9pt; font-family: T19;">eddie.</span><span style="font-size: 9pt; font-family: T21;">'s but not </span><span style="font-size: 9pt; font-family: T19;">eddies </span><span style="font-size: 9pt; font-family: T21;">or </span><span style="font-size: 9pt; font-family: T19;">eddieboy</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Here are some useful options for all three of the </span><span style="font-size: 9pt; font-family: T19;">grep</span><span style="font-size: 9pt; font-family: T21;">s:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-f Matches all the expressions in a given file as opposed to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">the one typed in the command line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-i Removes case sensitivity so that uppercase and lowercase<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">letters match.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-n Displays the line numbers containing a match.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-l Displays the names of the files that contain a match but<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">not the lines that contained a match.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">-v Displays the lines that don't match as opposed to those that do.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.14 history<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">history </span><span style="font-size: 9pt; font-family: T21;">command displays a list of commands you have previously typed.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">For this command to work correctly you must _rst type </span><span style="font-size: 9pt; font-family: T9;">set history=n </span><span style="font-size: 9pt; font-family: T21;">where<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">n </span><span style="font-size: 9pt; font-family: T21;">is the letter before </span><span style="font-size: 9pt; font-family: T19;">o </span><span style="font-size: 9pt; font-family: T21;">and the number of commands that should be saved. A<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">peek at section 2.7.5 may help explain this.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.15 kill<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">At times you may _nd that you have a job running that you don't want to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">continue. It is at this point that your thoughts may turn to murder. </span><span style="font-size: 9pt; font-family: T19;">Kill </span><span style="font-size: 9pt; font-family: T21;">is the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">hitman of choice for Unix users. </span><span style="font-size: 9pt; font-family: T19;">Kill </span><span style="font-size: 9pt; font-family: T21;">is quick and cheap (roughly 13 keystrokes).<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">To put </span><span style="font-size: 9pt; font-family: T19;">kill </span><span style="font-size: 9pt; font-family: T21;">to work just type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">kill -9 processid<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where the </span><span style="font-size: 9pt; font-family: T19;">processid </span><span style="font-size: 9pt; font-family: T21;">can be found with the </span><span style="font-size: 9pt; font-family: T19;">ps </span><span style="font-size: 9pt; font-family: T21;">command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">If the process was created by the current interactive shell, you can type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">kill -9 %n<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T19;">n </span><span style="font-size: 9pt; font-family: T21;">is the process index indicated by the </span><span style="font-size: 9pt; font-family: T19;">jobs </span><span style="font-size: 9pt; font-family: T21;">command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">15<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.16 look<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">look </span><span style="font-size: 9pt; font-family: T21;">command searches through the system dictionary or lines in some other<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">sorted list for a word. I often use </span><span style="font-size: 9pt; font-family: T19;">look </span><span style="font-size: 9pt; font-family: T21;">to check my spelling of a word. Suppose<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">I want to know if </span><span style="font-size: 9pt; font-family: T19;">inoculate </span><span style="font-size: 9pt; font-family: T21;">is spelled correctly. I would type </span><span style="font-size: 9pt; font-family: T9;">look inoculate</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">If </span><span style="font-size: 9pt; font-family: T19;">inoculate </span><span style="font-size: 9pt; font-family: T21;">is in the system dictionary (which it is) it is echoed to the terminal,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and I know that the spelling is correct. If it is not in the system dictionary, it<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">is not echoed to the terminal.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.17 mail<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Most users with access to computer accounts in a higher education setting and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">many in a corporate environment have access to internet. Your email address is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">your account name</span><span style="font-size: 9pt; font-family: T21;">@</span><span style="font-size: 9pt; font-family: T19;">hostname.domain </span><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T19;">hostname </span><span style="font-size: 9pt; font-family: T21;">is the name of the local<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">computer and </span><span style="font-size: 9pt; font-family: T19;">domain </span><span style="font-size: 9pt; font-family: T21;">is the name of the \system" you are on. For example,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">taylor@sunp.cr.usgs.gov </span><span style="font-size: 9pt; font-family: T21;">was my email address this past summer. In this case,<o:p></o:p></span></p> <p class="MsoNormal" style=""><st1:city st="on"><st1:place st="on"><span style="font-size: 9pt; font-family: T19;">taylor</span></st1:place></st1:city><span style="font-size: 9pt; font-family: T19;"> </span><span style="font-size: 9pt; font-family: T21;">was my account name, </span><span style="font-size: 9pt; font-family: T19;">sunp </span><span style="font-size: 9pt; font-family: T21;">was the local computer name, and </span><span style="font-size: 9pt; font-family: T19;">cr.usgs.gov<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">was the name of the \system" I was on. I can read mail sent to me by logging<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">on to the sunp computer and typing </span><span style="font-size: 9pt; font-family: T9;">mail</span><span style="font-size: 9pt; font-family: T21;">. Mail is sent to others by typing:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">mail internet_address<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T19;">internet address </span><span style="font-size: 9pt; font-family: T21;">is the address of the person you wish to send a message<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to. You are then thrown into a very crude line editor that lets you type your<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">message. Remember to hit </span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">return</span><span style="font-size: 9pt; font-family: T11;">> </span><span style="font-size: 9pt; font-family: T21;">at the end of each line because it can't<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">handle word wrapping. Typing a \</span><span style="font-size: 9pt; font-family: T9;">.</span><span style="font-size: 9pt; font-family: T21;">" or a </span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T19;">ctrl -</span><span style="font-size: 9pt; font-family: T9;">D</span><span style="font-size: 9pt; font-family: T11;">> </span><span style="font-size: 9pt; font-family: T21;">on a line all by itself will<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">signal the computer that you are _nished with the message. The computer will<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">then send the message you just wrote. If you wish to send a _le rather than<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">typing the message, use the following command:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">mail internet_address <></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T19;">_lename </span><span style="font-size: 9pt; font-family: T21;">is the name of the _le containing the message you wish to send.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Section 2.7.2 covers the redirection (</span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T21;">) operator in more detail.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.18 ps<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">ps </span><span style="font-size: 9pt; font-family: T21;">(process status) command displays the status of current processes. If<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">no ags are set, the command displays only your processes. Take a look a the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">man pages to see what ags might be of interest to you. I usually use </span><span style="font-size: 9pt; font-family: T19;">-aux</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.19 script<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">script </span><span style="font-size: 9pt; font-family: T21;">command records, in a speci_ed _le, everything you type and every<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">response you receive during your terminal session. To save the contents of your<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">session in a _le called </span><span style="font-size: 9pt; font-family: T19;">logsession</span><span style="font-size: 9pt; font-family: T21;">, type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">script logsession<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">16<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.20 setenv<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">setenv </span><span style="font-size: 9pt; font-family: T21;">(set environment variable) command assigns values to environment<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">variables. Many environment variables are used by di_erent Unix programs.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">We will see some of these in section 2.6. It is also possible to de_ne your own<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">variables. To either de_ne a new environment variable or change the value of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">an existing variable type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv variablename newvalue<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">For example, </span><span style="font-size: 9pt; font-family: T9;">setenv TERM vt100 </span><span style="font-size: 9pt; font-family: T21;">assigns </span><span style="font-size: 9pt; font-family: T19;">vt100 </span><span style="font-size: 9pt; font-family: T21;">to the variable </span><span style="font-size: 9pt; font-family: T19;">TERM</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.21 source<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">source </span><span style="font-size: 9pt; font-family: T21;">command sends the contents of a text _le to the Unix shell. Suppose<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">I have (and I do) a number of </span><span style="font-size: 9pt; font-family: T19;">alias </span><span style="font-size: 9pt; font-family: T21;">commands that I want typed in. Rather<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">than typing them all in, I keep them stored in a _le called (oddly enough) </span><span style="font-size: 9pt; font-family: T19;">.alias</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">All I need to do is type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">source .alias<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and I have all my </span><span style="font-size: 9pt; font-family: T19;">alias </span><span style="font-size: 9pt; font-family: T21;">commands executed as if I had typed each one in<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">separately.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.22 spell<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">spell </span><span style="font-size: 9pt; font-family: T21;">command checks the spelling of all the words in a desired _le against<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">those in the system dictionary or some other _le and outputs all the words<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">that it couldn't _nd in the system dictionary. To check the spelling of the _le<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">holy cow </span><span style="font-size: 9pt; font-family: T21;">type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">spell holy_cow<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.23 tar<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">tar </span><span style="font-size: 9pt; font-family: T21;">(tape archiver) program is useful for storing a bunch of _les in one _le<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">(usually on a magnetic tape, but it doesn't have to be). The syntax for this<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">command is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">tar [key] [name ...]<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T19;">key </span><span style="font-size: 9pt; font-family: T21;">is speci_ed by a plethora of options (see abridged list below and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">unabridged list in the man pages) and </span><span style="font-size: 9pt; font-family: T19;">name </span><span style="font-size: 9pt; font-family: T21;">is either the _le name or device<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">name.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Here are some of the more commonly used keys:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">17<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">c Creates a new tape.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">f Used for taring to a tape.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">t Lists the contents of a tar file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">v Turns verification on.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">x Extracts selected files. If no file argument is given,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">the entire contents of the tar file is extracted.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Here is the syntax I use to create and read tar _les:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">tar cvf /dev/drivename directoryname <-- creates<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">tar xvf /dev/drivename directoryname <-- reads<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.24 telnet<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">telnet </span><span style="font-size: 9pt; font-family: T21;">command opens a connection to another computer via the internet<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">network. This command allows you to log onto machines around the world that<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">you have accounts on or that allow public access. For example, the University<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of <st1:state st="on"><st1:place st="on">Michigan</st1:place></st1:state> o_ers public telnet access to weather information. To access this<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">information type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">telnet madlab.sprl.umich.edu 3000<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.25 umask<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">umask </span><span style="font-size: 9pt; font-family: T21;">command displays or sets the creation mask setting. The creation<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">mask setting de_nes the default attributes for new _les (see section 2.5.4). If<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">no argument is included, </span><span style="font-size: 9pt; font-family: T19;">umask </span><span style="font-size: 9pt; font-family: T21;">displays the current setting. To change the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">creation mask setting type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">umask value<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T19;">value </span><span style="font-size: 9pt; font-family: T21;">is a three digit octal number similar to the one de_ned in section<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">2.5.4. It is important to note that this is a mask. This means that a </span><span style="font-size: 9pt; font-family: T19;">umask<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">setting of </span><span style="font-size: 9pt; font-family: T9;">022 </span><span style="font-size: 9pt; font-family: T21;">would give the owner full privileges while the group and all others<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">would not have write privileges. This is exactly opposite of what we saw in<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">section 2.5.4 on </span><span style="font-size: 9pt; font-family: T19;">chmod</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.26 who<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">who </span><span style="font-size: 9pt; font-family: T21;">command simply tells you who is on the computer. Just type </span><span style="font-size: 9pt; font-family: T9;">who</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.5.27 A bunch more commands<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The rest of the this subsection is a terse description of a few more Unix commands<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">that you may _nd occasion to use.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">awk </span><span style="font-size: 9pt; font-family: T21;">| A pattern scanning and processing language.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">bar </span><span style="font-size: 9pt; font-family: T21;">| Creates a tape archive. (Similar to </span><span style="font-size: 9pt; font-family: T19;">tar</span><span style="font-size: 9pt; font-family: T21;">)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">18<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">bg </span><span style="font-size: 9pt; font-family: T21;">| Moves a job into the background.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">cal </span><span style="font-size: 9pt; font-family: T21;">| Displays a calendar.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">cc </span><span style="font-size: 9pt; font-family: T21;">| Compiles C code.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">chfn </span><span style="font-size: 9pt; font-family: T21;">| Changes _nger information.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">clear </span><span style="font-size: 9pt; font-family: T21;">| Clears your terminal's screen.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">cmp </span><span style="font-size: 9pt; font-family: T21;">| Preforms a byte-by-byte comparison of two _les.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">cut </span><span style="font-size: 9pt; font-family: T21;">| Removes selected _elds from each line of a _le.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">date </span><span style="font-size: 9pt; font-family: T21;">| Displays or sets the date.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">ed </span><span style="font-size: 9pt; font-family: T21;">| The most basic line editor.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">ex </span><span style="font-size: 9pt; font-family: T21;">| A simple line editor. Also know as </span><span style="font-size: 9pt; font-family: T19;">e </span><span style="font-size: 9pt; font-family: T21;">or </span><span style="font-size: 9pt; font-family: T19;">edit</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">fg </span><span style="font-size: 9pt; font-family: T21;">|Moves a job into the foreground.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">_le </span><span style="font-size: 9pt; font-family: T21;">| Determines the type of a _le by examining its contents.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">fmt </span><span style="font-size: 9pt; font-family: T21;">| Formats text.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">hostname </span><span style="font-size: 9pt; font-family: T21;">| Sets or prints the name of the current host computer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">jobs </span><span style="font-size: 9pt; font-family: T21;">| Lists the current jobs in the shell.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">make </span><span style="font-size: 9pt; font-family: T21;">| Maintains, updates, and regenerates related programs and _les.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">mesg </span><span style="font-size: 9pt; font-family: T21;">| Permits or denies messages on your terminal.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">mt </span><span style="font-size: 9pt; font-family: T21;">| Provides magnetic tape control.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">od </span><span style="font-size: 9pt; font-family: T21;">| Dumps octal, decimal, hexadecimal, or ascii representations of _les.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">pack/unpack </span><span style="font-size: 9pt; font-family: T21;">| Similar to compress/uncompress, but uses Hu_man coding.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">paste </span><span style="font-size: 9pt; font-family: T21;">| Joins corresponding lines of several _les.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">rev </span><span style="font-size: 9pt; font-family: T21;">| Reverses the order of characters in each line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">rcp </span><span style="font-size: 9pt; font-family: T21;">| Copies a _le from a remote computer to the local computer.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">rsh </span><span style="font-size: 9pt; font-family: T21;">| Execute a remote shell command.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">sed </span><span style="font-size: 9pt; font-family: T21;">| A stream editor{quite powerful.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">sort </span><span style="font-size: 9pt; font-family: T21;">| Sorts and collates lines.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">split </span><span style="font-size: 9pt; font-family: T21;">| Splits a _le into pieces.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">19<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">stty </span><span style="font-size: 9pt; font-family: T21;">| Sets or alters the options for a terminal.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">tr </span><span style="font-size: 9pt; font-family: T21;">| Translates characters.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">uname </span><span style="font-size: 9pt; font-family: T21;">| Displays the name of the current system.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">units </span><span style="font-size: 9pt; font-family: T21;">| Converts a number into di_erent units.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">uuencode/uudecode </span><span style="font-size: 9pt; font-family: T21;">| Encodes/decodes a binary _le into strictly ascii characters.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">(Useful for transmission via electronic mail)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">write </span><span style="font-size: 9pt; font-family: T21;">|Write a message to another user.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">xget/xsend </span><span style="font-size: 9pt; font-family: T21;">| Commands for sending/receiving secret mail.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T17;">2.6 Login _les<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Every time you log in, the Unix shell searches your home directory for certain<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">_les and executes the commands in them. This allows you to customize your<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Unix session. There are two initialization _les that I will discuss here. The </span><span style="font-size: 9pt; font-family: T19;">.cshrc<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">(pronounced 'dot-see-shirk') _le and the </span><span style="font-size: 9pt; font-family: T19;">.login </span><span style="font-size: 9pt; font-family: T21;">(pronounced 'dot-login') _le. The<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">.cshrc </span><span style="font-size: 9pt; font-family: T21;">_le is executed every time a new C shell is started. The </span><span style="font-size: 9pt; font-family: T19;">.login </span><span style="font-size: 9pt; font-family: T21;">is executed<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">after the </span><span style="font-size: 9pt; font-family: T19;">.cshrc </span><span style="font-size: 9pt; font-family: T21;">_le only when you initially log in. Generally, environment<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">variables should be set in the </span><span style="font-size: 9pt; font-family: T19;">.login </span><span style="font-size: 9pt; font-family: T21;">_le, and </span><span style="font-size: 9pt; font-family: T19;">alias </span><span style="font-size: 9pt; font-family: T21;">and </span><span style="font-size: 9pt; font-family: T19;">set </span><span style="font-size: 9pt; font-family: T21;">commands should be<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">in the </span><span style="font-size: 9pt; font-family: T19;">.cshrc </span><span style="font-size: 9pt; font-family: T21;">_le so that every new copy of the C shell will be able to use them.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.6.1 The .cshrc _le<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The following is an example </span><span style="font-size: 9pt; font-family: T19;">.cshrc </span><span style="font-size: 9pt; font-family: T21;">_le. The \</span><span style="font-size: 9pt; font-family: T9;">#</span><span style="font-size: 9pt; font-family: T21;">" character at the beginning<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">of a line tells the C shell to ignore the rest of the line. I don't expect you to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">understand every command in this _le or in the example </span><span style="font-size: 9pt; font-family: T19;">.login </span><span style="font-size: 9pt; font-family: T21;">_le found in<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the next section, but I don't care to explain them all either. This document is<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">getting too long as it is.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">###############################################################################<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Example .cshrc file #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># by Chris Taylor #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">###############################################################################<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Set path shell variable<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># (See description of path in the paragraph followin this example .cshrc)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set path = ( /usr/bin /usr/local /usr/local/bin /usr/bin/X11 \<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">/usr/ucb /usr/opt/bin ~ )<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Don't overwrite existing files with the redirection character ">"<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set noclobber<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">20<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Don't create core dump files when a program blows up.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">limit coredumpsize 0<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Check to see if this is an interactive shell.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># If not, skip the rest of this file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">if ($?USER == 0 || $?prompt == 0) exit<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">## Set C shell variables<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Remember my 40 most recent events<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set history=40<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Save the most recent 40 events when I log out<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set savehist=40<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Substitute the filename to be completed when I type an <esc> at<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># the command line<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set filec<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Tells the shell to ignore .o files when trying to complete filenames<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># when filec is set. (This doesn't hold if the .o file is the only<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># on that could be completed.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set fignore=.o<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Tells "filec" not to cry if it can't complete a file.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set nobeep<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Notify me when the status of background jobs change<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set notify<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Don't let me log out by pressing <ctrl-d><o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set ignoreeof<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Set TTY shell variable equal to the current terminal name<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set TTY=`who am i | awk '{print $2}'`<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Allow others to send messages directly to my terminal<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">mesg y<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Set prompt to have the following form: [cmd#]cpu[directory]:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set cpu=`hostname | awk '{FS = "."; print $1}'` # set cpu = computer name<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias sp set prompt='\[!\]$cpu\[$cwd\]:\ ' # set sp to set the prompt<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias cd 'chdir \!* ; sp' # redefine cd command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias pd 'pushd \!* ; sp' # redefine pd command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias pp 'popd \!* ; sp' # redefine pp command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">sp # set the prompt<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Shortcut aliases<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias c 'clear'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias dict 'vi /usr/dict/words'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias gv 'ghostview'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias h 'history !* | head -39 | more'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias laser 'lpr -Pmsa13 -h'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias line 'lpr -Ped3'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias ll 'ls -la'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">21<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias ls 'ls -x'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias mine 'chmod og-rwx'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias pwd 'echo $cwd' # This is faster than executing the pwd command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias safe 'chmod a-w'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">alias tmp 'cd /tmp/<st1:city st="on"><st1:place st="on">taylor</st1:place></st1:city>'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># end of .cshrc file<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">A number of commands, i.e. </span><span style="font-size: 9pt; font-family: T19;">history</span><span style="font-size: 9pt; font-family: T21;">, </span><span style="font-size: 9pt; font-family: T19;">set</span><span style="font-size: 9pt; font-family: T21;">, etc</span><span style="font-size: 9pt; font-family: T11;">: : : </span><span style="font-size: 9pt; font-family: T21;">are built in commands. The<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">rest of the commands must call an external program to execute it. Not all of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">these other commands are stored in the same directory. They are spread into<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">a bunch of di_erent directories. The </span><span style="font-size: 9pt; font-family: T19;">path </span><span style="font-size: 9pt; font-family: T21;">variable is a shell variable that tells<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the shell where to look for these commands. In the example </span><span style="font-size: 9pt; font-family: T19;">.cshrc </span><span style="font-size: 9pt; font-family: T21;">_le, the </span><span style="font-size: 9pt; font-family: T19;">path<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">variable is set to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">( . /usr/bin /usr/local /usr/local/bin /usr/bin/X11 /usr/ucb /usr/opt/bin ~ )<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">This tells the shell to look _rst in the working directory, then in the </span><span style="font-size: 9pt; font-family: T19;">/usr/bin<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">directory, next in the </span><span style="font-size: 9pt; font-family: T19;">/usr/local </span><span style="font-size: 9pt; font-family: T21;">directory, and so on until the _le has been found<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">or all directories have been looked at.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.6.2 The .login _le<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The following is an example </span><span style="font-size: 9pt; font-family: T19;">.login </span><span style="font-size: 9pt; font-family: T21;">_le. The same rules apply here as did with<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the </span><span style="font-size: 9pt; font-family: T19;">.cshrc </span><span style="font-size: 9pt; font-family: T21;">_le.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">###############################################################################<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Example .login file #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># by Chris Taylor #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">###############################################################################<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Set erase, kill, and interrupt keys<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">stty crt erase '^H' kill '^U' intr '^C'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Set the creation mask setting so that everyone can read my files<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># but can't write to them<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">umask 022<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">## Set environment variables<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Set my terminal type to xterm<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv TERM xterm<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Select vi as my editor of choice<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv EDITOR /usr/ucb/vi<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Show the path to my mailbox<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv MAIL /usr/spool/mail/$USER<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Set mail program<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">22<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv MAILER /usr/ucb/mail<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Set paging program<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv PAGER more<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Set default printer<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv PRINTER hp<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">if (-f /bin/sun != 0) then<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Using a Sun<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">if ("`tty`" == "/dev/console") then<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Using console<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv DISPLAY $cpu":0.0"<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Ask if I want to start X11<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">echo ""; echo -n "Start up X11? "<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set ans = $<<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">if ("$ans" != "n" && "$ans" != "N") then<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># Start X11<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv DISPLAY $HOST\:0<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">stty -tostop<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">exec xinit .xstartup ; kbd_mode -a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">clear<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">endif<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">unset ans<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">else<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">setenv DISPLAY `last | grep $USER | head -1 | \<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">awk '{print $3}' | awk '{FS=".";print $1 "." $2 ":0" }'`<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">endif<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">endif<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;"># end of .login file<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T17;">2.7 Special characters<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.7.1 Wildcards<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">A number of characters are interpreted by the Unix shell before any other action<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">takes place. These characters are known as wildcard characters. Usually these<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">characters are used in place of _lenames or directory names.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">* An asterisk matches any number of characters in a filename,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">including none.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">? The question mark matches any single character.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">[ ] Brackets enclose a set of characters, any one of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">which may match a single character at that position.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">- A hyphen used within [ ] denotes a range of characters.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">~ A tilde at the beginning of a word expands to the name<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">of your home directory. If you append another user's login<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">name to the character, it refers to that user's home directory.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Here are some examples:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">1. </span><span style="font-size: 9pt; font-family: T9;">cat c* </span><span style="font-size: 9pt; font-family: T21;">displays any _le whose name begins with </span><span style="font-size: 9pt; font-family: T19;">c </span><span style="font-size: 9pt; font-family: T21;">including the _le </span><span style="font-size: 9pt; font-family: T19;">c</span><span style="font-size: 9pt; font-family: T21;">, if<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">it exists.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">23<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">2. </span><span style="font-size: 9pt; font-family: T9;">ls *.c </span><span style="font-size: 9pt; font-family: T21;">lists all _les that have a </span><span style="font-size: 9pt; font-family: T19;">.c </span><span style="font-size: 9pt; font-family: T21;">extension.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">3. </span><span style="font-size: 9pt; font-family: T9;">cp ../rmt?. </span><span style="font-size: 9pt; font-family: T21;">copies every _le in the parent directory that is four characters<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">long and begins with </span><span style="font-size: 9pt; font-family: T19;">rmt </span><span style="font-size: 9pt; font-family: T21;">to the working directory. (The names will<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">remain the same.)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">4. </span><span style="font-size: 9pt; font-family: T9;">ls rmt[34567] </span><span style="font-size: 9pt; font-family: T21;">lists every _le that begins with </span><span style="font-size: 9pt; font-family: T19;">rmt </span><span style="font-size: 9pt; font-family: T21;">and has a </span><span style="font-size: 9pt; font-family: T19;">3</span><span style="font-size: 9pt; font-family: T21;">, </span><span style="font-size: 9pt; font-family: T19;">4</span><span style="font-size: 9pt; font-family: T21;">, </span><span style="font-size: 9pt; font-family: T19;">5</span><span style="font-size: 9pt; font-family: T21;">, </span><span style="font-size: 9pt; font-family: T19;">6</span><span style="font-size: 9pt; font-family: T21;">,<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">or </span><span style="font-size: 9pt; font-family: T19;">7 </span><span style="font-size: 9pt; font-family: T21;">at the end.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">5. </span><span style="font-size: 9pt; font-family: T9;">ls rmt[3-7] </span><span style="font-size: 9pt; font-family: T21;">does exactly the same thing as the previous example.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">6. </span><span style="font-size: 9pt; font-family: T9;">ls </span><span style="font-size: 9pt; font-family: T21;">~lists your home directory.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">7. </span><span style="font-size: 9pt; font-family: T9;">ls </span><span style="font-size: 9pt; font-family: T21;">~</span><span style="font-size: 9pt; font-family: T9;">hessen </span><span style="font-size: 9pt; font-family: T21;">lists the home directory of the guy</span><span style="font-size: 9pt; font-family: T15;">11 </span><span style="font-size: 9pt; font-family: T21;">with the user id </span><span style="font-size: 9pt; font-family: T19;">hessen</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.7.2 Redirecting output<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">A program that normally reads its input from the terminal (standard input)<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">or normally writes its output to the terminal (standard output) may become<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">annoying if you would rather send the input from a _le instead of the keyboard<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">or send the output to a _le instead of the terminal. This annoyance can be<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">avoided if you happen to be swift with the redirection operators. The redirection<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">operators are \</span><span style="font-size: 9pt; font-family: T11;"><</span><span style="font-size: 9pt; font-family: T21;">", \</span><span style="font-size: 9pt; font-family: T11;">></span><span style="font-size: 9pt; font-family: T21;">", and \</span><span style="font-size: 9pt; font-family: T11;">>></span><span style="font-size: 9pt; font-family: T21;">". The _rst is used to send input to a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">command. The second is used to create a _le and send the output to it. The<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">third is used to append the output to an existing _le.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">An example of the _rst redirection operator was already given in section 2.5.17<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">on electronic mail. Suppose you wanted to put a list of all the people logged on<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">into a _le called </span><span style="font-size: 9pt; font-family: T19;">neatguys </span><span style="font-size: 9pt; font-family: T21;">with the current time listed at the top of the _le.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">date > neatguys<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">would create a _le with the date and time in it, and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">who >> neatguys<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">would append the list of users logged on.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.7.3 Pipes<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">A pipeline is a convenient way to channel the output of one command into the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">input of another without creating an intermediate _le. Let's say we wanted to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">get an alphabetical listing of the current processes. From a thorough study of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the previous section and the man pages for </span><span style="font-size: 9pt; font-family: T19;">ps </span><span style="font-size: 9pt; font-family: T21;">and </span><span style="font-size: 9pt; font-family: T19;">sort</span><span style="font-size: 9pt; font-family: T21;">, we already know how<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to do this:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ps -aux > processes<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">sort processes<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">11</span><span style="font-size: 9pt; font-family: T13;">Throughout this paper </span><span style="font-size: 9pt; font-family: T8;">guy </span><span style="font-size: 9pt; font-family: T13;">is assumed to be gender neutral unless otherwise stated.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">24<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">This works, but it gives us a _le (namely </span><span style="font-size: 9pt; font-family: T19;">processes</span><span style="font-size: 9pt; font-family: T21;">) which we don't want. The<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">pipe symbol, \</span><span style="font-size: 9pt; font-family: T20;">j</span><span style="font-size: 9pt; font-family: T21;">" lets us bypass this intermediate _le. The above two commands<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">can be replace with the following:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ps -aux | sort<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">It is possible to connect a series of commands by additional pipe symbols.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">We could pass our previous output through the </span><span style="font-size: 9pt; font-family: T19;">more </span><span style="font-size: 9pt; font-family: T21;">paging program to obtain<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">a more pleasing display of the results. This is a accomplish by typing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ps -aux | sort | more<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">One important point to recognize is that if a command isn't capable of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">reading from standard input, it cannot be placed to the right of a pipe symbol.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.7.4 Quote characters<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Sometimes it is necessary to place wildcards in the command line without having<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the shell treat them as special characters. This can be done by either preceding a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">single wildcard character with a backslash, </span><span style="font-size: 9pt; font-family: T20;">n</span><span style="font-size: 9pt; font-family: T21;">, or enclosing a sequence of wildcard<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">characters in apostrophes, </span><span style="font-size: 9pt; font-family: T9;">' '</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">For example, if you wanted to set your C shell prompt to a question mark<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and typed<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set prompt=?<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the question mark would be expanded to be the _rst single-character _lename in<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the working directory. If one exists it will be your prompt. If no single-character<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">_lenames exist, you will get a \set: No match" error. You should have typed<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set prompt=\?<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.7.5 Other special characters<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">If you have set the history option (see section 2.6), you can use special characters<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to repeat those commands without retyping them. Here are some of them:</span><span style="font-size: 9pt; font-family: T15;">12<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">!! On a line by itself will repeat the most recent event.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">!com Will repeat the most recent event that begins with "com".<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">!?string Will repeat the most recent event that contained "string".<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">!-n Will repeat the nth previous event.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">!n Will repeat the nth event. Type "history" to see the events<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">numbered.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">^old^new^ Will substitute "new" for the first occurrence of "old" in the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">most recent event, and repeats that event.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">: Will select specific words from an event line so you<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">can repeat parts of an event, e.g.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">12</span><span style="font-size: 9pt; font-family: T13;">By event I mean one command line. This may be a single command, or it may include a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T13;">number of commands in a pipeline, or whatever.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">25<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">!?adam:s/adam/eve/<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">will substitute "eve" for "adam" and repeat the last event<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">with "adam" in it.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The semicolon, \</span><span style="font-size: 9pt; font-family: T9;">;</span><span style="font-size: 9pt; font-family: T21;">", separates commands. Typing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">clear ; ls<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">is equivalent to typing each command on a separate command line.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The \</span><span style="font-size: 9pt; font-family: T9;">&</span><span style="font-size: 9pt; font-family: T21;">" symbol tells the shell to execute the command in the background.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">For example, typing </span><span style="font-size: 9pt; font-family: T9;">xid & </span><span style="font-size: 9pt; font-family: T21;">would execute </span><span style="font-size: 9pt; font-family: T5;">xid </span><span style="font-size: 9pt; font-family: T21;">in the background and give my<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Unix commandline back so I could continue to use it even while </span><span style="font-size: 9pt; font-family: T5;">xid </span><span style="font-size: 9pt; font-family: T21;">was running.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The C shell also _nds special meaning in the following:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">" ` { } #<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Rather than explain the uses of these special characters, I caution you to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">avoid using them in _lenames.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T17;">2.8 Miscellaneous tips<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.8.1 Removing _les with strange names<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">There may come a time that you will discover that you have somehow created a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">_le with a strange name that cannot be removed through conventional means.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">This section contains some unconventional approaches that may aid in removing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">such _les.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Files that begin with a dash can be removed by typing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">rm ./-filename<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">A couple other ways that may work are<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">rm -- -filename<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">rm - -filename<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Now let's suppose that we an even nastier _lename. One that I ran across<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">this summer was a _le with no _lename. The solution I used to remove it was<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">rm -i *<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">26<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">This executes the </span><span style="font-size: 9pt; font-family: T19;">rm </span><span style="font-size: 9pt; font-family: T21;">command in interactive mode. I then answered \yes" to<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the query to remove the nameless _le and \no" to all the other queries about<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the rest of the _les.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Another method I could have used would be to obtain the </span><span style="font-size: 9pt; font-family: T19;">inode </span><span style="font-size: 9pt; font-family: T21;">number of<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the nameless _le with<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">ls -i<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">and then type<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">find . -inum number -ok rm '{}' \;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T19;">number </span><span style="font-size: 9pt; font-family: T21;">is the inode number.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The </span><span style="font-size: 9pt; font-family: T19;">-ok </span><span style="font-size: 9pt; font-family: T21;">ag causes a con_rmation prompt to be displayed. If you would<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">rather live on the edge and not be bothered with the prompting, you can use<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T19;">-exec </span><span style="font-size: 9pt; font-family: T21;">in place of </span><span style="font-size: 9pt; font-family: T19;">-ok</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Suppose you didn't want to remove the _le with the funny name, but wanted<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">to rename it so that you could access it more readily. This can be accomplished<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">by following the previous procedure with the following modi_cation to the </span><span style="font-size: 9pt; font-family: T19;">_nd<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">command:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">find . -inum number -ok mv '{}' new_filename \;<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.8.2 Wildcards beyond the working directory<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Let's say we want to perform some command on a set of _les in the working<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">directory and all the directories below it. What if there was a Hewlett-Packard<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">advertisement that asked, \What if I had a slew of subdirectories containing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">mounds of C source code, and I wanted to copy all of the library _les (_les<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">with a </span><span style="font-size: 9pt; font-family: T19;">.h </span><span style="font-size: 9pt; font-family: T21;">extension) into a separate directory called </span><span style="font-size: 9pt; font-family: T19;">library</span><span style="font-size: 9pt; font-family: T21;">. How could I do<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">it?" If you had read the next line, you would respond immediately with the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">following:</span><span style="font-size: 9pt; font-family: T15;">13<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cp `find . -name '*.h' -print` library<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.8.3 Terminal input in a shell script<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">To input text from your terminal into a C shell script use the following syntax:<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">while ( 1 )<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">set line = "$<"<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">if ( "$line" == "" ) break<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">...<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">end<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Also, be advised that the C shell has no way of distinguishing between a<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">blank line and an end-of-_le.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">13</span><span style="font-size: 9pt; font-family: T13;">That is, if you talk to your television.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">27<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.8.4 Remote shell trick<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Here is the proper syntax to use the </span><span style="font-size: 9pt; font-family: T19;">rsh </span><span style="font-size: 9pt; font-family: T21;">(remote shell) command without having<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the remote shell remain active until the remote command is completed.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">rsh machine -n 'command >&/dev/null </dev/null &'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T19;">machine </span><span style="font-size: 9pt; font-family: T21;">is the name of the remote computer and </span><span style="font-size: 9pt; font-family: T19;">command </span><span style="font-size: 9pt; font-family: T21;">is the remote<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">command to be performed.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">This works because the </span><span style="font-size: 9pt; font-family: T19;">-n </span><span style="font-size: 9pt; font-family: T21;">ag attaches the </span><span style="font-size: 9pt; font-family: T19;">rsh</span><span style="font-size: 9pt; font-family: T21;">'s standard input to </span><span style="font-size: 9pt; font-family: T19;">/dev/null<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">so you can execute the complete </span><span style="font-size: 9pt; font-family: T19;">rsh </span><span style="font-size: 9pt; font-family: T21;">command in the background of the local<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">computer. Also, the input/output redirections on the remote computer (the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">stu_ inside the single quotes) makes </span><span style="font-size: 9pt; font-family: T19;">rsh </span><span style="font-size: 9pt; font-family: T21;">think the session can be terminated<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">since there is no data ow. In all truth, you don't have to use </span><span style="font-size: 9pt; font-family: T19;">/dev/null</span><span style="font-size: 9pt; font-family: T21;">. Any<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">_lename will work.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.8.5 Loops in scripts<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Here is an example of a simple loop in a script. I use it to send out my biweekly<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">junkmail messages.</span><span style="font-size: 9pt; font-family: T15;">14<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">#!/bin/sh<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">for i in `cat $HOME/jm/list`<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">do<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">mail -s 'Junkmail message number '$1 $i <></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">done<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The script takes one line at a time from the _le </span><span style="font-size: 9pt; font-family: T3;">$</span><span style="font-size: 9pt; font-family: T19;">HOME/jm/list </span><span style="font-size: 9pt; font-family: T21;">and executes<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">the command<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">mail -s 'Junkmail message number '$1 $i <></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">where </span><span style="font-size: 9pt; font-family: T3;">$</span><span style="font-size: 9pt; font-family: T19;">1 </span><span style="font-size: 9pt; font-family: T21;">the the _rst argument on the command line calling the script and </span><span style="font-size: 9pt; font-family: T3;">$</span><span style="font-size: 9pt; font-family: T19;">i<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">is the line from the _le </span><span style="font-size: 9pt; font-family: T3;">$</span><span style="font-size: 9pt; font-family: T19;">HOME/jm/list</span><span style="font-size: 9pt; font-family: T21;">.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T12;">2.8.6 More tricks<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Every word of a _le can be placed on a separate line by typing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cat old_filename | tr -cs A-Za-z '\012' > new_filename<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">The following lists all words in </span><span style="font-size: 9pt; font-family: T19;">_lename </span><span style="font-size: 9pt; font-family: T21;">in alphabetical order.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">cat filename | tr -cs A-Za-z '\012' | tr A-Z a-z | sort | uniq<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">You can _nd out when the _le </span><span style="font-size: 9pt; font-family: T19;">.rhosts </span><span style="font-size: 9pt; font-family: T21;">was last modi_ed by typing<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T10;">echo .rhosts last modified on `/bin/ls -l .rhosts | cut -c33-44`<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Typing </span><span style="font-size: 9pt; font-family: T9;">head -n </span><span style="font-size: 9pt; font-family: T21;">displays the _rst </span><span style="font-size: 9pt; font-family: T19;">n </span><span style="font-size: 9pt; font-family: T21;">lines of a _le. And typing </span><span style="font-size: 9pt; font-family: T9;">last </span><span style="font-size: 9pt; font-family: T21;">lists the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">last logins.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T14;">14</span><span style="font-size: 9pt; font-family: T13;">Send me mail at </span><span style="font-size: 9pt; font-family: T8;">taylor@ecn.purdue.edu </span><span style="font-size: 9pt; font-family: T13;">for more information on this service.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">28<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T17;">2.9 Things to try<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">Just for kicks, I have included a few commands for you to try typing in at the<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">shell prompt. Make sure you type each line exactly as it appears here.<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">1. </span><span style="font-size: 9pt; font-family: T9;">If I had a ( for every $ Congress spent, what would I have?<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">2. </span><span style="font-size: 9pt; font-family: T9;">[Where are all those MIAs?<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">3. </span><span style="font-size: 9pt; font-family: T13;">echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq' |dc<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">4. </span><span style="font-size: 9pt; font-family: T9;">got a light?<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">5. </span><span style="font-size: 9pt; font-family: T9;">man: Why did you get a divorce?<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T21;">6. </span><span style="font-size: 9pt; font-family: T9;">make 'heads or tails of all this'<o:p></o:p></span></p> <p class="MsoNormal" style=""><span style="font-size: 9pt; font-family: T2;">Note: The auto pilot command found in section 2.5.2 doesn't exist.<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 9pt; font-family: T21;">29</span><span style="font-size: 9pt;"><o:p></o:p></span></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-32407929003309550002008-07-31T01:56:00.000-07:002008-12-23T00:12:05.692-08:00Running job on Unix server with lowest priority.<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>support</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????????¡ì????????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <div style=""> <table vspace="0" width="505" cellpadding="0" cellspacing="0" height="70" hspace="0"> <tbody><tr> <td style="padding: 0in 9.35pt;" valign="top" align="left" height="70"> <div style="border: 1.5pt solid windowtext; padding: 1pt; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">You can run a job<span style=""> </span>on unix server with lowest priority using nice –19 option.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">Suppose you wish to run some script which is going to take a longer time and the results are not<span style=""> </span>required immediately, you can<span style=""> </span>assign the lowest priority to the job using:<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;"><o:p> </o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;"><span style=""> </span>nice –19 script.sh<o:p></o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;"><o:p> </o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">If you have logged in as root:<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">You can also assign the highetst priority <span style=""> </span>to the job:<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;">nice -- 19 script.sh<o:p></o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">Note: Only the root user can run a job with highest priority.<span style=""> </span><o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;"><o:p> </o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;">(You can give the priority between <span style=""> </span>–19 to 19, with –19 having highest priority and 19 having lowest priority.)<o:p></o:p></span></b></p> </div> </td> </tr> </tbody></table> </div> <!--[if !supportTextWrap]-->
<br /> <!--[endif]-->Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-43883079464768001222008-07-31T01:17:00.000-07:002008-12-23T00:12:05.692-08:00Creating multi font string in Xmotif.<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>support</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????????¡ì????????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <div style=""> <table vspace="0" width="505" cellpadding="0" cellspacing="0" height="70" hspace="0"> <tbody><tr> <td style="padding: 0in 9.35pt;" valign="top" align="left" height="70"> <div style="border: 1.5pt solid windowtext; padding: 1pt; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">In Xmotif the strings created are compound string i.e. they themselves carry some more information such as font, font size with the text. So to create the multifont string what you have to do is actually concatenate strings of different fonts to form a single multi font string.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">In this exapmle we will create a string as shown.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">At <b style="">Larsen & Toubro Infotech Limited </b>we strive to achieve.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>XmString s1,s2,s3,text,tmp;<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>String string1 = “At ",<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span><span style=""> </span><span style=""> </span><span style=""> </span>string2 = "Larsen & Toubro Infotech Limited<span style=""> </span>",<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span><span style=""> </span>string3 = "we strive to achieve";<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>//Create compound strings with different fonts.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>s1 = XmStringCreate(string1,"NORMALFONT");<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>s2 = XmStringCreate(string2,"BOLDFONT");<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>s3 = XmStringCreate(string3,"NORMALFONT");<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">//Now concatenate the strings to form a single string.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>tmp = XmStringConcat(s1,s2);<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>text= XmStringConcat(tmp,s3);<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">Now the multi font compound string “text” is created which can be used for a label.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>XtVaSetValues(label,XmNlabelString,text,NULL) ;<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">For this you have to mention the font list to be used. You can use the “fontlist” property of the widget in which this multifont list is to be displayed, or you can mention it in the .Xdefaults file. I’ll suggest to use the .Xdefaults file for this purpopse as the fonts then can be changed without recompilation of the program.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">Just add this to your .Xdefaults file.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">Nameof the application*fontList:<span style=""> </span>-*-courier-bold-r-*--12-*=BOLDFONT,\<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span><span style=""> </span><span style=""> </span>-*-courier-medium-r-*--12-*=NORMALFONT<o:p></o:p></span></p> </div> </td> </tr> </tbody></table> </div> <!--[if !supportTextWrap]-->
<br /> <!--[endif]-->Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-22111142904755724492008-07-31T01:16:00.001-07:002008-12-23T00:12:05.692-08:00Mapping of key for vi editor<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>support</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????????¡ì????????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <div style=""> <table vspace="0" width="505" cellpadding="0" cellspacing="0" height="70" hspace="0"> <tbody><tr> <td style="padding: 0in 9.35pt;" valign="top" align="left" height="70"> <div style="border: 1.5pt solid windowtext; padding: 1pt; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">Any key can be<span style=""> </span>mapped for vi editor to perform any of the editor commands. For this the map command is to be used. <o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">for mapping<span style=""> </span>“ctrl+s” to save file and quit which is nothing but “wq”<span style=""> </span>in terms of editor commands. On command line of vi editor in escape mode write,<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;"><o:p> </o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;">:map ctrl+s<span style=""> </span>:wq^M<o:p></o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;">Here you will actually press ctrl+s, and to produve ctrl M character use ctrl+v and then perss m.<o:p></o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;">The ^M character is required to act as enter key, without this the “wq” will appear at the command line of vi editor.<o:p></o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">Now as you have run this command in a particular vi session, next time you open vi you will again have to map it. Instead you can write the command in .exrc file in your home directory.<o:p></o:p></span></p> </div> </td> </tr> </tbody></table> </div> <!--[if !supportTextWrap]-->
<br /> <!--[endif]-->Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-74542222699074902442008-07-31T01:14:00.000-07:002008-12-23T00:12:05.692-08:00Searching for files with different extensions using a single “find” command.<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>support</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????????¡ì????????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <div style=""> <table vspace="0" width="505" cellpadding="0" cellspacing="0" height="70" hspace="0"> <tbody><tr> <td style="padding: 0in 9.35pt;" valign="top" align="left" height="70"> <div style="border: 1.5pt solid windowtext; padding: 1pt; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">The find command is used to search the files in a directory. You can either mention the particular file name or use the wild card character “*”. So if you have to search for all the “. cpp” files recursively in a directory , the find command will be :<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;">find . –name “*.cpp”<o:p></o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">This command will give the path ( relative with reference to the current directory) of files with extension “.cpp”. <o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">The find command together with<span style=""> </span>“–exec”, can be used to perform different operations on the files. e.g. If you wish to search for a particular pattern in all<span style=""> </span>“.h”<span style=""> </span>files in a directory recursively, you can use combination of find and grep command as shown below.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;">find . –name “*.h” –exec grep –l “<pattern>” {} \;<o:p></o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">Here the output of find command which is nothing but the relative path of the “.h” files will be given to the grep command, thus giving the required result.<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;">Here if you wish to search for the pattern in “*.cpp” as well as “*.h” files, you can use<span style=""> </span>“–o” option as shown below:<o:p></o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b style=""><span style="font-size: 10pt;">find . –name<span style=""> </span>“*.cpp” –o –name<span style=""> </span>“.h” | xargs grep<span style=""> </span>–l<span style=""> </span>“<pattern>” <o:p></o:p></span></b></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><o:p> </o:p></span></p> <p class="MsoNormal" style="border: medium none ; padding: 0in; background: white none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt;"><span style=""> </span>Note: This<span style=""> </span>“–o” option is available only with the GNU version of find.<o:p></o:p></span></p> </div> </td> </tr> </tbody></table> </div> <!--[if !supportTextWrap]-->
<br /> <!--[endif]-->Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-73296524105981090282008-07-31T01:08:00.000-07:002008-12-23T00:12:05.692-08:00When to use XtFree () ?<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>support</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????????¡ì????????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <table class="MsoNormalTable" style="border: medium none ; margin-left: 0.45in; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"> <tbody><tr style=""> <td style="border: 1pt solid windowtext; padding: 0in 5.4pt; width: 3.5in;" valign="top" width="336"> <p class="MsoNormal">When we are using Xmotif routines such as XmTextGetString, XmTextGetSelection, which return a character pointer, these routines allocate storage for the returned string. This allocated memory should be freed by the programmer using XtFree ().<span style=""> </span><o:p></o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><span style=""> </span>e.g.<o:p></o:p></p> <p class="MsoNormal">string getText( )<o:p></o:p></p> <p class="MsoNormal">{<o:p></o:p></p> <p class="MsoNormal">#ifdef _TRACELOG<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>traceLog(eDebug,”Enetered getText () “);<o:p></o:p></p> <p class="MsoNormal">#endif<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span><o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>string strText;<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>char* pchText = NULL:<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>pchText = XmTextGetString (TextWidget);<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>if (pchText)<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>{<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>strText = pchText;<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>XtFree (pchText);<o:p></o:p></p> <p class="MsoNormal">#ifdef _TRACELOG<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>traceLog(eDebug,”Got the getText ():[%s] “,<span style=""> </span><o:p></o:p></p> <p class="MsoNormal"><span style=""> </span><span style=""> </span>“strText.c_str () );<o:p></o:p></p> <p class="MsoNormal">#endif<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>}<o:p></o:p></p> <p class="MsoNormal">#ifdef _TRACELOG<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>traceLog(eDebug,”Returning from getText () “);<o:p></o:p></p> <p class="MsoNormal">#endif<o:p></o:p></p> <p class="MsoNormal"><span style=""> </span>return strText; <o:p></o:p></p> <p class="MsoNormal">}<o:p></o:p></p> </td> </tr> <tr style=""> <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 3.5in;" valign="top" width="336"> <p class="MsoNormal">Use XtFree( ) routine to free the memory allocated by the Xmotif routines which return a character pointer.<o:p></o:p></p> </td> </tr> </tbody></table> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-58857022527144418512008-07-31T01:07:00.000-07:002008-12-23T00:12:05.692-08:00Usage of Microsoft Visual Source Safe for Unix-based projects<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>support</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????????¡ì????????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; mso-bidi-font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoHeader, li.MsoHeader, div.MsoHeader {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:11.0pt; mso-bidi-font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} p.MsoFooter, li.MsoFooter, div.MsoFooter {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:11.0pt; mso-bidi-font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:#606420; text-decoration:underline; text-underline:single;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:870530847; mso-list-type:simple; mso-list-template-ids:67698689;} @list l0:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; font-family:Symbol;} @list l1 {mso-list-id:1271160715; mso-list-type:simple; mso-list-template-ids:67698689;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in; font-family:Symbol;} @list l2 {mso-list-id:1392383109; mso-list-type:simple; mso-list-template-ids:67698703;} @list l2:level1 {mso-level-tab-stop:.25in; mso-level-number-position:left; margin-left:.25in; text-indent:-.25in;} ol {margin-bottom:0in;} ul {margin-bottom:0in;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <p class="MsoNormal" style="text-align: center;" align="center"><b style=""><u>
<br /><o:p></o:p></u></b></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><b style=""><i style="">Introduction:</i></b></p> <p class="MsoNormal" style="text-align: justify;">This document explains why and how Microsoft Visual Source Safe can be used for the source code control of projects that are based on Unix-based systems. (Unix-based systems are those that run any flavor of the UNIX operating system, e.g., Linux, HP-UX, IBM AIX, Sun Solaris).</p> <p class="MsoNormal"><o:p> </o:p></p> <p class="MsoNormal"><b style=""><i style=""><span style="" lang="FR">Source Code Control on Unix:<o:p></o:p></span></i></b></p> <p class="MsoNormal" style="text-align: justify;">Traditionally, SCCS has been used as the source code control system for Unix. This package (Set of programs) is usually bundled along with any Unix system. However, of late, the industry has seen movement towards using either RCS (Revision Control System) or CVS/RCS (Concurrent Versioning System over RCS). Both of these are distributed free with full source code under the GNU Public License (see <a href="http://www.gnu.org/">http://www.gnu.org</a> ). The latest stable versions can be downloaded by public FTP from ftp://ftp.gnu.org/pub. </p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: justify;"><b style=""><i style="">Problems:<o:p></o:p></i></b></p> <p class="MsoNormal" style="text-align: justify;">The problems with using the above-mentioned source code control systems are mentioned in this section.</p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: justify;">Here we are assuming that most of our documentation is done using Microsoft Office or other utilities on the MS Windows (Win95/Win98/NT/Win 2000) platforms. It is also assumed that we will work on the Unix projects through a Windows-based PC (either by using the telnet program or by using some kind of an X emulator).</p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="">1.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span><!--[endif]-->Since we need to keep versions of the documents too, we will need to install Microsoft Visual Source Safe. If we use the above source code control systems, we will end up with having to maintain 2 repositories, one for the documents and one for the source. We will also have to constantly switch between the commands/functionality offered by the Unix-based source code control system and Microsoft VSS.</p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="">2.<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span><!--[endif]-->CVS/RCS is inherently difficult to use for teams that are not accustomed to the Unix-based interface.</p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: justify;"><b style=""><i style=""><o:p> </o:p></i></b></p> <p class="MsoNormal" style="text-align: justify;"><b style=""><i style="">The Suggested Solution:<o:p></o:p></i></b></p> <p class="MsoNormal" style="text-align: justify;">Use a single repository by using only Microsoft Visual Source Safe. Even the code will be stored in the VSS. For the <b style=""><i style="">how</i> </b>of this, read on.</p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->Install SAMBA on the Unix-server where the development is expected to take place. SAMBA is an implementation (again under GNU free license) of the SMB (Server Management Block) protocol which Windows uses for its networking. For example, this is how Windows uses to "Find Computer" and "Explore" some PC in the Network Neighborhood.</p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->Configure SAMBA appropriately (see SAMBA documentation for more). Directories on the Unix-server can be "shared" like a Windows directory.</p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->Go to any Windows PC in the neighborhood and "Find Computer" giving the name of the Unix server…and, like magic, the Unix server shows up. Exploring will show the directories shared on the Unix server.</p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->What we have achieved is to fool the Windows PC in believing that the Unix server is a Windows NT server. Now, we can map any shared directory on the Unix server (subject to permissions, of course!) and this appears like a drive on the PC.</p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->Now, create a folder on the mapped drive and make it the "Working Directory" for the source code folder in Microsoft VSS. After this, any check-in / checkout of the source code will be directly transferred to / from the Unix-server.</p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: justify;"><b style=""><i style="">Caveats:<o:p></o:p></i></b></p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->SAMBA has to be configured in the right way, which won't take a minute if you want the defaults.</p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->Security will usually be configured in SAMBA to use the Unix password mechanism. Each Unix user will usually have a login and a home directory on the Unix server. If we are using Win95/Win98 PCs to map Unix directories, the username that is used to log into Win95/Win98 <b style=""><span style="font-size: 14pt;">should</span></b><span style="font-size: 12pt;"> </span>be the same as the Unix login name for that user. This problem does not arise with NT because NT prompts for a dialog box that allows the change of the username while connecting to a drive. Actually, this problem is something that is wrongly done by Windows and has nothing to do with SAMBA.</p> <p class="MsoNormal" style="margin-left: 0.25in; text-align: justify; text-indent: -0.25in;"><!--[if !supportLists]--><span style="font-family: Symbol;"><span style="">·<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span></span></span><!--[endif]-->VSS has to be configured to see files ending with .c, .h and other Unix source files as binary. If this is not done, VSS automatically puts in a <cr> and <lf> sequence of characters. If such a file is opened in a text editor on Unix, the end of lines have the familiar <b style=""><i style="">^M</i></b> character.</p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: justify;"><b style=""><i style="">Conclusion:<o:p></o:p></i></b></p> <p class="MsoNormal" style="text-align: justify;">Maybe using CVS/RCS will still be useful for some projects. But, most of the project leaders should be happy to be using a single source and document repository.</p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: justify;">Using SAMBA, directories on Unix servers can be mapped as Windows NT drives. One usage of this is to have Unix files stored in VSS and set the working directory to the appropriate folder in the mapped drive. (Other uses are to use the Unix server as a file server…for example, "Oh! I do not have enough disk space to install this software. But, I the Unix server have a lot of free space. So I can map that as a drive and install my software on that drive!).</p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: justify;">In this way, Microsoft Visual Source Safe can be used for versioning files on Unix-based projects.</p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> <p class="MsoNormal" style="text-align: justify;"><o:p> </o:p></p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0tag:blogger.com,1999:blog-345201392220129351.post-83426705541556998022008-07-31T01:05:00.000-07:002008-12-23T00:12:05.692-08:00Generating dependencies for makefile using a script:<meta equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///D:%5CDOCUME%7E1%5Cshesu04%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml"><!--[if gte mso 9]><xml> <o:documentproperties> <o:author>support</o:Author> <o:version>11.9999</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:usefelayout/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" latentstylecount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:???????????????¡ì????????; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:"\@Arial Unicode MS"; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-fareast-language:EN-US;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--> <p class="MsoNormal">
<br /></p> <p class="MsoNormal"><span style=""> </span>In a makefile we mention the dependency of the object file on other files. These dependencies can be written in a file using script.</p> <p class="MsoNormal">This script prepares a list of files included in the cpp file and writes it to a file in the format, required for the makefile. Now this file is included in the make file for specifying the dependencies.</p> Sumedhhttp://www.blogger.com/profile/11533458660230230361noreply@blogger.com0