Unix Cheat Sheet (Unix Linux 命令行参考手册)

Unix Cheat Sheet


http://www.rain.org/~mkummel<wbr></wbr>/unix.html

People who use Windows without DOS, or a Macintosh, or PPP without a terminal, or an ISP's menu without the Unix prompt are at a disadvantage. Something is happening, and they don't know what it is. I like to know what's really going on, so I've been learning some Unix.

The Net is a Unix place. I'm no wizard, but I'm comfortable with basic commands and occasionally type "rm" at my DOS prompt instead of "del". This is my Unix cheat sheet, so I can remember. Uppercase and lowercase matter. These commands (mostly) work with my C-shell account on RAIN. Your account might be different, especially if your prompt ends with a "$" (Korn shell) rather than a "%", so be cautious. When I need help, I reach for the books UNIX in a Nutshell (O'Reilly) and Unix Unbound by Harley Hahn (Osborne/McGraw Hill, 1994).

This page won't look right without table support. Most of this is available in a text version.


Help on any Unix command. RTFM!

man {command}Type man ls to read the manual for the ls command.

man {command} > {filename}Redirect help to a file to download.

whatis {command}Give short description of command. (Not on RAIN?) <!-- D(["mb","\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>apropos {keyword}\u003c/tt\>\u003c/td\>\u003ctd\>Search for all Unix commands that match keyword, eg \u003cb\>apropos file\u003c/b\>. (Not on RAIN?)\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>List a directory\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ls {path}\u003c/tt\>\u003c/td\>\u003ctd\>It&#39;s ok to combine attributes, eg \u003cb\>ls -laF\u003c/b\> gets a long listing of all files with types.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ls {path_1} {path_2}\u003c/tt\>\u003c/td\>\u003ctd\>List both {path_1} and {path_2}.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ls -l {path}\u003c/tt\>\u003c/td\>\u003ctd\>Long listing, with date, size and permisions.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ls -a {path}\u003c/tt\>\u003c/td\>\u003ctd\>Show all files, including important .dot files that don&#39;t otherwise show.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ls -F {path}\u003c/tt\>\u003c/td\>\u003ctd\>Show type of each file. &quot;\u003cb\>/\u003c/b\>&quot; \u003d directory, &quot;\u003cb\>*\u003c/b\>&quot; \u003d executable.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ls -R {path}\u003c/tt\>\u003c/td\>\u003ctd\>Recursive listing, with all subdirs.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ls {path} &gt; {filename}\u003c/tt\>\u003c/td\>\u003ctd\>Redirect directory to a file.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ls {path} | more\u003c/tt\>\u003c/td\>\u003ctd\>Show listing one screen at a time.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>dir {path}\u003c/tt\>\u003c/td\>\u003ctd\>Useful alias for DOS people, or use with \u003cb\>ncftp\u003c/b\>.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Change to directory\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cd {dirname}\u003c/tt\>\u003c/td\>\u003ctd\>There must be a space between.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cd ~\u003c/tt\>\u003c/td\>\u003ctd\>Go back to home directory, useful if you&#39;re lost.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cd ..\u003c/tt\>\u003c/td\>\u003ctd\>Go back one directory.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cdup\u003c/tt\>\u003c/td\>\u003ctd\>Useful alias, like &quot;cd ..&quot;, or use with \u003cb\>ncftp\u003c/b\>.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Make a new directory\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>",1] ); //-->

apropos {keyword}Search for all Unix commands that match keyword, eg apropos file. (Not on RAIN?)

List a directory

ls {path}It's ok to combine attributes, eg ls -laF gets a long listing of all files with types.

ls {path_1} {path_2}List both {path_1} and {path_2}.

ls -l {path}Long listing, with date, size and permisions.

ls -a {path}Show all files, including important .dot files that don't otherwise show.

ls -F {path}Show type of each file. "/" = directory, "*" = executable.

ls -R {path}Recursive listing, with all subdirs.

ls {path} > {filename}Redirect directory to a file.

ls {path} | moreShow listing one screen at a time.

dir {path}Useful alias for DOS people, or use with ncftp.

Change to directory

cd {dirname}There must be a space between.

cd ~Go back to home directory, useful if you're lost.

cd ..Go back one directory.

cdupUseful alias, like "cd ..", or use with ncftp.

Make a new directory

<!-- D(["mb","\u003ctt\>mkdir {dirname}\u003c/tt\>\u003c/td\>\u003ctd\>\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Remove a directory\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>rmdir {dirname}\u003c/tt\>\u003c/td\>\u003ctd\>Only works if {dirname} is empty.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>rm -r {dirname}\u003c/tt\>\u003c/td\>\u003ctd\>Remove all files and subdirs. Careful!\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Print working directory\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>pwd\u003c/tt\>\u003c/td\>\u003ctd\>Show where you are as full path. Useful if you&#39;re lost or exploring.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Copy a file or directory\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cp {file1} {file2}\u003c/tt\>\u003c/td\>\u003ctd\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cp -r {dir1} {dir2}\u003c/tt\>\u003c/td\>\u003ctd\>Recursive, copy directory and all subdirs.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cat {newfile} &gt;&gt; {oldfile}\u003c/tt\>\u003c/td\>\u003ctd\>Append newfile to end of oldfile.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Move (or rename) a file\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>mv {oldfile} {newfile}\u003c/tt\>\u003c/td\>\u003ctd\>Moving a file and renaming it are the same thing.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>mv {oldname} {newname}\u003c/tt\>\u003c/td\>\u003ctd\>\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Delete a file\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>rm {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>\u003cb\>?\u003c/b\> and \u003cb\>*\u003c/b\> wildcards work like DOS should. &quot;?&quot; is any character; &quot;*&quot; is any string of characters.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ls {filespec}\u003cbr\>rm {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>Good strategy: first list a group to make sure it&#39;s what&#39;s you think...\u003cbr\>...then delete it all at once.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"2\"\>\u003cfont size\u003d\"+1\"\>Download with zmodem\u003c/font\>\u003c/td\>\u003ctd\>(Use \u003cb\>sx\u003c/b\> with xmodem.)\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>sz [-a|b] {filename}",1] ); //--> mkdir {dirname}

Remove a directory

rmdir {dirname}Only works if {dirname} is empty.

rm -r {dirname}Remove all files and subdirs. Careful!

Print working directory

pwdShow where you are as full path. Useful if you're lost or exploring.

Copy a file or directory

cp {file1} {file2}

cp -r {dir1} {dir2}Recursive, copy directory and all subdirs.

cat {newfile} >> {oldfile}Append newfile to end of oldfile.

Move (or rename) a file

mv {oldfile} {newfile}Moving a file and renaming it are the same thing.

mv {oldname} {newname}

Delete a file

rm {filespec} ? and * wildcards work like DOS should. "?" is any character; "*" is any string of characters.

ls {filespec}
rm {filespec}
Good strategy: first list a group to make sure it's what's you think...
...then delete it all at once.

Download with zmodem(Use sx with xmodem.)

sz [-a|b] {filename} <!-- D(["mb","\u003c/tt\>\u003c/td\>\u003ctd\>\u003cb\>-a\u003c/b\> \u003d ascii, \u003cb\>-b\u003c/b\> \u003d binary. Use binary for everything. (It&#39;s the default?)\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>sz *.zip\u003c/tt\>\u003c/td\>\u003ctd\>Handy after downloading with FTP. Go talk to your spouse while it does it&#39;s stuff.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"2\"\>\u003cfont size\u003d\"+1\"\>Upload with zmodem\u003c/font\>\u003c/td\>\u003ctd\>(Use \u003cb\>rx\u003c/b\> with xmodem.)\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>rz [-a|b] (filename}\u003c/tt\>\u003c/td\>\u003ctd\>Give \u003cb\>rz\u003c/b\> command in Unix, THEN start upload at home. Works fine with multiple files.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>View a text file\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>more {filename}\u003c/tt\>\u003c/td\>\u003ctd\>View file one screen at a time.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>less {filename}\u003c/tt\>\u003c/td\>\u003ctd\>Like \u003cb\>more\u003c/b\>, with extra features.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cat {filename}\u003c/tt\>\u003c/td\>\u003ctd\>View file, but it scrolls.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cat {filename} | more\u003c/tt\>\u003c/td\>\u003ctd\>View file one screen at a time.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>page {filename}\u003c/tt\>\u003c/td\>\u003ctd\>Very handy with \u003cb\>ncftp\u003c/b\>.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>pico {filename}\u003c/tt\>\u003c/td\>\u003ctd\>Use text editor and don&#39;t save.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Edit a text file.\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>pico {filename}\u003c/tt\>\u003c/td\>\u003ctd\>The same editor PINE uses, so you already know it. \u003cb\>vi\u003c/b\> and \u003cb\>emacs\u003c/b\> are also available.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Create a text file.\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>cat &gt; {filename}\u003c/tt\>\u003c/td\>\u003ctd\>Enter your text (multiple lines with \u003cb\>enter\u003c/b\> are ok) and press \u003cb\>control-d\u003c/b\> to save.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>pico {filename}\u003c/tt\>\u003c/td\>\u003ctd\>Create some text and save it.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Compare two files\u003c/font\>",1] ); //--> -a = ascii, -b = binary. Use binary for everything. (It's the default?)

sz *.zipHandy after downloading with FTP. Go talk to your spouse while it does it's stuff.

Upload with zmodem(Use rx with xmodem.)

rz [-a|b] (filename}Give rz command in Unix, THEN start upload at home. Works fine with multiple files.

View a text file

more {filename}View file one screen at a time.

less {filename}Like more, with extra features.

cat {filename}View file, but it scrolls.

cat {filename} | moreView file one screen at a time.

page {filename}Very handy with ncftp.

pico {filename}Use text editor and don't save.

Edit a text file.

pico {filename}The same editor PINE uses, so you already know it. vi and emacs are also available.

Create a text file.

cat > {filename}Enter your text (multiple lines with enter are ok) and press control-d to save.

pico {filename}Create some text and save it.

Compare two files <!-- D(["mb","\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>diff {file1} {file2}\u003c/tt\>\u003c/td\>\u003ctd\>Show the differences.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>sdiff {file1} {file2}\u003c/tt\>\u003c/td\>\u003ctd\>Show files side by side.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Other text commands\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>grep &#39;{pattern}&#39; {file}\u003c/tt\>\u003c/td\>\u003ctd\>Find regular expression in file.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>sort {file1} &gt; {file2}\u003c/tt\>\u003c/td\>\u003ctd\>Sort file1 and save as file2.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>sort -o {file} {file}\u003c/tt\>\u003c/td\>\u003ctd\>Replace file with sorted version.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>spell {file}\u003c/tt\>\u003c/td\>\u003ctd\>Display misspelled words.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>wc {file}\u003c/tt\>\u003c/td\>\u003ctd\>Count words in file.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Find files on system\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>find {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>Works with wildcards. Handy for snooping.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>find {filespec} &gt; {filename}\u003c/tt\>\u003c/td\>\u003ctd\>Redirect find list to file. Can be big!\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Make an Alias\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>alias {name} &#39;{command}&#39;\u003c/tt\>\u003c/td\>\u003ctd\>Put the command in &#39;single quotes&#39;. More useful in your \u003cb\>.cshrc\u003c/b\> file.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Wildcards and Shortcuts\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>*\u003c/tt\>\u003c/td\>\u003ctd\>Match any string of characters, eg \u003cb\>page*\u003c/b\> gets page1, page10, and page.txt.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>?\u003c/tt\>\u003c/td\>\u003ctd\>Match any single character, eg \u003cb\>page?\u003c/b\> gets page1 and page2, but not page10.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>[...]\u003c/tt\>\u003c/td\>\u003ctd\>Match any characters in a range, eg \u003cb\>page[1-3]\u003c/b\> gets page1, page2, and page3.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>~\u003c/tt\>\u003c/td\>\u003ctd\>Short for your home directory, eg ",1] ); //-->

diff {file1} {file2}Show the differences.

sdiff {file1} {file2}Show files side by side.

Other text commands

grep '{pattern}' {file}Find regular expression in file.

sort {file1} > {file2}Sort file1 and save as file2.

sort -o {file} {file}Replace file with sorted version.

spell {file}Display misspelled words.

wc {file}Count words in file.

Find files on system

find {filespec}Works with wildcards. Handy for snooping.

find {filespec} > {filename}Redirect find list to file. Can be big!

Make an Alias

alias {name} '{command}'Put the command in 'single quotes'. More useful in your .cshrc file.

Wildcards and Shortcuts

*Match any string of characters, eg page* gets page1, page10, and page.txt.

?Match any single character, eg page? gets page1 and page2, but not page10.

[...]Match any characters in a range, eg page[1-3] gets page1, page2, and page3.

~Short for your home directory, eg <!-- D(["mb","\u003cb\>cd ~\u003c/b\> will take you home, and \u003cb\>rm -r ~\u003c/b\> will destroy it.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>.\u003c/tt\>\u003c/td\>\u003ctd\>The current directory.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>..\u003c/tt\>\u003c/td\>\u003ctd\>One directory up the tree, eg \u003cb\>ls ..\u003c/b\>.\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"2\"\>\u003cfont size\u003d\"+1\"\>Pipes and Redirection\u003c/font\>\u003c/td\>\u003ctd\>(You \u003cb\>pipe\u003c/b\> a command to another command, and \u003cb\>redirect\u003c/b\> it to a file.)\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>{command} &gt; {file}\u003c/tt\>\u003c/td\>\u003ctd\>Redirect output to a file, eg \u003cb\>ls &gt; list.txt\u003c/b\> writes directory to file.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>{command} &gt;&gt; {file}\u003c/tt\>\u003c/td\>\u003ctd\>Append output to an existing file, eg \u003cb\>cat update &gt;&gt; archive\u003c/b\> adds update to end of archive.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>{command} &lt; {file}\u003c/tt\>\u003c/td\>\u003ctd\>Get input from a file, eg \u003cb\>sort &lt; file.txt\u003c/b\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>{command} &lt; {file1} &gt; {file2}\u003c/tt\>\u003c/td\>\u003ctd\>Get input from \u003ctt\>file1\u003c/tt\>, and write to \u003ctt\>file2\u003c/tt\>, eg \u003cb\>sort &lt; old.txt &gt; new.txt\u003c/b\> sorts old.txt and saves as new.txt.\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>{command} | {command}\u003c/tt\>\u003c/td\>\u003ctd\>Pipe one command to another, eg \u003cb\>ls | more\u003c/b\> gets directory and sends it to \u003cb\>more\u003c/b\> to show it one page at a time.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Permissions, important and tricky!\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd colspan\u003d\"2\"\>\nUnix permissions concern who can \u003cb\>read\u003c/b\> a file or directory, \u003cb\>write\u003c/b\> to it, and \u003cb\>execute\u003c/b\> it.\nPermissions are granted or withheld with a magic 3-digit number.\nThe three digits correspond to the \u003cb\>owner\u003c/b\> (you); the \u003cb\>group\u003c/b\> (?); and the \u003cb\>world\u003c/b\> (everyone else).\u003cp\>\nThink of each digit as a sum:\u003cbr\>\n\u003ctable border\u003d\"0\" width\u003d\"300\"\>\n\u003ctbody\>\u003ctr\>\u003ctd width\u003d\"30\"\>\u003cbr\>\u003c/td\>\u003ctd\>execute permission \u003c/td\>\u003ctd\>\u003d 1\u003cbr\>\u003c/td\>\n\u003c/tr\>\u003ctr\>\u003ctd width\u003d\"30\"\>\u003cbr\>\u003c/td\>\u003ctd\>write permission \u003c/td\>\u003ctd\>\u003d 2\u003cbr\>\u003c/td\>\n\u003c/tr\>\u003ctr\>\u003ctd width\u003d\"30\"\>\u003cbr\>\u003c/td\>\u003ctd\>",1] ); //--> cd ~ will take you home, and rm -r ~ will destroy it.

.The current directory.

..One directory up the tree, eg ls ...

Pipes and Redirection(You pipe a command to another command, and redirect it to a file.)

{command} > {file}Redirect output to a file, eg ls > list.txt writes directory to file.

{command} >> {file}Append output to an existing file, eg cat update >> archive adds update to end of archive.

{command} < {file}Get input from a file, eg sort < file.txt

{command} < {file1} > {file2}Get input from file1, and write to file2, eg sort < old.txt > new.txt sorts old.txt and saves as new.txt.

{command} | {command}Pipe one command to another, eg ls | more gets directory and sends it to more to show it one page at a time.

Permissions, important and tricky!

Unix permissions concern who can read a file or directory, write to it, and execute it. Permissions are granted or withheld with a magic 3-digit number. The three digits correspond to the owner (you); the group (?); and the world (everyone else).

Think of each digit as a sum:


execute permission = 1

write permission = 2

<!-- D(["mb","write and execute (1+2)\u003c/td\>\u003ctd\>\u003d 3 \u003cbr\>\u003c/td\>\n\u003c/tr\>\u003ctr\>\u003ctd width\u003d\"30\"\>\u003cbr\>\u003c/td\>\u003ctd\>read permission \u003c/td\>\u003ctd\>\u003d 4\u003cbr\>\u003c/td\>\n\u003c/tr\>\u003ctr\>\u003ctd width\u003d\"30\"\>\u003cbr\>\u003c/td\>\u003ctd\>read and execute (4+1)\u003c/td\>\u003ctd\>\u003d 5\u003cbr\>\u003c/td\>\n\u003c/tr\>\u003ctr\>\u003ctd width\u003d\"30\"\>\u003cbr\>\u003c/td\>\u003ctd\>read and write (4+2)\u003c/td\>\u003ctd\>\u003d 6\u003cbr\>\u003c/td\>\n\u003c/tr\>\u003ctr\>\u003ctd width\u003d\"30\"\>\u003cbr\>\u003c/td\>\u003ctd\>read, write and execute (4+2+1)\u003c/td\>\u003ctd\>\u003d 7\u003cbr\>\u003c/td\>\n\u003c/tr\>\u003c/tbody\>\u003c/table\>\n\u003c/p\>\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd colspan\u003d\"2\"\>Add the number value of the permissions you want to grant each group to make a three digit number, \none digit each for the owner, the group, and the world. Here are some useful combinations. Try to figure them out!\u003cp\>\n\u003c/p\>\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>chmod 600 {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>You can read and write; the world can&#39;t. Good for files.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>chmod 700 {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>You can read, write, and execute; the world can&#39;t. Good for scripts.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>chmod 644 {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>You can read and write; the world can only read. Good for web pages.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>chmod 755 {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>You can read, write, and execute; the world can read and execute. Good for programs you want to share, and your \u003ctt\>public_html\u003c/tt\> directory.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Permissions, another way\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd colspan\u003d\"2\"\>\nYou can also change file permissions with letters:\u003cp\>\n\u003ctable border\u003d\"0\" width\u003d\"400\"\>\n \u003ctbody\>\u003ctr\>\u003ctd width\u003d\"30\"\>\u003cbr\>\u003c/td\>\u003ctd\>\u003cb\>u\u003c/b\> \u003d user (yourself) \u003c/td\>\u003ctd\>\u003cb\>g\u003c/b\> \u003d group \u003c/td\>\u003ctd\>\u003cb\>a\u003c/b\> \u003d everyone\u003cbr\>\u003c/td\>\n \u003c/tr\>\u003ctr\>\u003ctd width\u003d\"30\"\>\u003cbr\>\u003c/td\>\u003ctd\>\u003cb\>r\u003c/b\> \u003d read \u003c/td\>\u003ctd\>\u003cb\>w\u003c/b\> \u003d write \u003c/td\>\u003ctd\>\u003cb\>x\u003c/b\> \u003d execute\u003cbr\>\u003c/td\>\n\u003c/tr\>\u003c/tbody\>\u003c/table\>\n\u003c/p\>\u003cp\>\n\u003c/p\>\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>chmod u+rw {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>Give yourself read and write permission\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>chmod u+x {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>Give yourself execute permission.",1] ); //--> write and execute (1+2)= 3

read permission = 4

read and execute (4+1)= 5

read and write (4+2)= 6

read, write and execute (4+2+1)= 7

Add the number value of the permissions you want to grant each group to make a three digit number, one digit each for the owner, the group, and the world. Here are some useful combinations. Try to figure them out!


chmod 600 {filespec}You can read and write; the world can't. Good for files.

chmod 700 {filespec}You can read, write, and execute; the world can't. Good for scripts.

chmod 644 {filespec}You can read and write; the world can only read. Good for web pages.

chmod 755 {filespec}You can read, write, and execute; the world can read and execute. Good for programs you want to share, and your public_html directory.

Permissions, another way

You can also change file permissions with letters:


u = user (yourself) g = group a = everyone

r = read w = write x = execute


chmod u+rw {filespec}Give yourself read and write permission

chmod u+x {filespec}Give yourself execute permission. <!-- D(["mb","\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>chmod a+rw {filespec}\u003c/tt\>\u003c/td\>\u003ctd\>Give read and write permission to everyone.\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>Applications I use\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>finger {userid}\u003c/tt\>\u003c/td\>\u003ctd\>Find out what someone&#39;s up to.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>gopher\u003c/tt\>\u003c/td\>\u003ctd\>Gopher.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>irc\u003c/tt\>\u003c/td\>\u003ctd\>IRC, but not available on RAIN.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>lynx\u003c/tt\>\u003c/td\>\u003ctd\>Text-based Web browser, fast and lean.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ncftp\u003c/tt\>\u003c/td\>\u003ctd\>Better FTP.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>pico {filename}\u003c/tt\>\u003c/td\>\u003ctd\>Easy text editor, but limited. \u003cb\>vi\u003c/b\> and \u003cb\>emacs\u003c/b\> are available.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>pine\u003c/tt\>\u003c/td\>\u003ctd\>Email.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>telnet {host}\u003c/tt\>\u003c/td\>\u003ctd\>Start Telnet session to another host.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>tin\u003c/tt\>\u003c/td\>\u003ctd\>Usenet.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>uudecode {filename}\u003cbr\>uuencode {filename}\u003c/tt\>\u003c/td\>\u003ctd\>Do it on the server to reduce download size about 1/3.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>ytalk {userid}\u003c/tt\>\u003c/td\>\u003ctd\>Chat with someone else online, eg \u003cb\>ytalk mkummel\u003c/b\>. Please use \u003cb\>w\u003c/b\> first so you don&#39;t interrupt a big download!\u003cbr\>\n\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003chr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd colspan\u003d\"3\"\>\u003cfont size\u003d\"+1\"\>System info\u003c/font\>\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>date\u003c/tt\>\u003c/td\>\u003ctd\>Show date and time.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>df\u003c/tt\>\u003c/td\>\u003ctd\>Check system disk capacity.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>du\u003c/tt\>\u003c/td\>\u003ctd\>Check your disk usage and show bytes in each directory.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>more /etc/motd\u003c/tt\>\u003c/td\>\u003ctd\>Read message of the day, &quot;motd&quot; is a useful alias..\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>printenv\u003c/tt\>\u003c/td\>\u003ctd\>Show all environmental variables (in C-shell% - use \u003cb\>set\u003c/b\> in Korn shell$).\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>",1] ); //-->

chmod a+rw {filespec}Give read and write permission to everyone.

Applications I use

finger {userid}Find out what someone's up to.

gopherGopher.

ircIRC, but not available on RAIN.

lynxText-based Web browser, fast and lean.

ncftpBetter FTP.

pico {filename}Easy text editor, but limited. vi and emacs are available.

pineEmail.

telnet {host}Start Telnet session to another host.

tinUsenet.

uudecode {filename}
uuencode {filename}
Do it on the server to reduce download size about 1/3.

ytalk {userid}Chat with someone else online, eg ytalk mkummel. Please use w first so you don't interrupt a big download!

System info

dateShow date and time.

dfCheck system disk capacity.

duCheck your disk usage and show bytes in each directory.

more /etc/motdRead message of the day, "motd" is a useful alias..

printenvShow all environmental variables (in C-shell% - use set in Korn shell$).

<!-- D(["mb","\u003ctt\>quota -v\u003c/tt\>\u003c/td\>\u003ctd\>Check your total disk use.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>uptime\u003c/tt\>\u003c/td\>\u003ctd\>Find out system load.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>\u003cbr\>\u003c/td\>\u003ctd\>\u003ctt\>w\u003c/tt\>\u003c/td\>\u003ctd\>Who&#39;s online and what are they doing?\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003c/tbody\>\u003c/table\>\n\n\u003chr\>\n\u003cfont size\u003d\"+1\"\>Unix Directory Format\u003c/font\>\u003cp\>\n\u003c/p\>\u003cblockquote\>\nLong listings (\u003cb\>ls -l\u003c/b\>) have this format:\u003cp\>\n\u003c/p\>\u003cpre\>\u003ctt\>\u003cbr\> \u003cb\>-\u003c/b\> file\u003cbr\> \u003cb\>d\u003c/b\> directory, \u003cb\>*\u003c/b\> executable\u003cbr\> ^ symbolic links (?) file size (bytes) file name \u003cb\>/\u003c/b\> directory\u003cbr\> ^ ^ ^ ^ ^\n\u003cbr\> \u003cb\>drwxr-xr-x 11 mkummel 2560 Mar 7 23:25 public_html/\u003cbr\> -rw-r--r-- 1 mkummel 10297 Mar 8 23:42 index.html\u003c/b\>\u003cbr\> ^\u003cbr\> ^^^ user permission (rwx) date and time last modified\n\u003cbr\> ^^^ group permission (rwx)\u003cbr\> ^^^ world permission (rwx)\u003cbr\>\u003c/tt\>\u003c/pre\>\n\u003c/blockquote\>\n\n\u003chr\>\n\u003cfont size\u003d\"+1\"\>How to Make an Alias\u003c/font\>\u003cp\>\n\u003c/p\>\u003cblockquote\>\nAn alias lets you type something simple and do something complex. It&#39;s a shorthand for a command.\nIf you want to type &quot;dir&quot; instead of &quot;ls -l&quot; then type \u003cb\>alias dir &#39;ls -l&#39;\u003c/b\>. The single quotes tell\nUnix that the enclosed text is one command.\n\u003cp\>\nAliases are more useful if they&#39;re permanent so you don&#39;t have to think about them. You can do this by \nadding the alias to your \u003cb\>.cshrc\u003c/b\> file so they&#39;re automatically loaded when you start. \nType \u003cb\>pico .cshrc\u003c/b\> and look for the alias section and add what you want.\nIt will be effective when you start. \nJust remember that if you make an alias with the name of a Unix command, that command will become unavailable.\n\u003c/p\>\u003cp\>\nHere are a few aliases from my \u003cb\>.cshrc\u003c/b\> file:\n\u003c/p\>\u003cp\>\n\u003c/p\>\u003cpre\> # enter your aliases here in the form:\u003cbr\>\t # alias this means this\u003cbr\>\u003cbr\> alias h history \u003cbr\> alias m more",1] ); //--> quota -v Check your total disk use.

uptimeFind out system load.

wWho's online and what are they doing?

Unix Directory Format

Long listings ( ls -l) have this format:


- file
d directory, * executable
^ symbolic links (?) file size (bytes) file name / directory
^ ^ ^ ^ ^

drwxr-xr-x 11 mkummel 2560 Mar 7 23:25 public_html/
-rw-r--r-- 1 mkummel 10297 Mar 8 23:42 index.html

^
^^^ user permission (rwx) date and time last modified

^^^ group permission (rwx)
^^^ world permission (rwx)

How to Make an Alias

An alias lets you type something simple and do something complex. It's a shorthand for a command. If you want to type "dir" instead of "ls -l" then type alias dir 'ls -l'. The single quotes tell Unix that the enclosed text is one command.

Aliases are more useful if they're permanent so you don't have to think about them. You can do this by adding the alias to your .cshrc file so they're automatically loaded when you start. Type pico .cshrc and look for the alias section and add what you want. It will be effective when you start. Just remember that if you make an alias with the name of a Unix command, that command will become unavailable.

Here are a few aliases from my .cshrc file:

            # enter your aliases here in the form:
# alias this means this

alias h history
alias m more<!-- D(["mb","\u003cbr\> alias\tq\tquota -v\n\u003cbr\> alias bye exit\u003cbr\> alias \tls \tls -F\u003cbr\> alias dir ls\u003cbr\> alias \tcdup\tcd ..\u003cbr\> alias\tmotd\tmore /etc/motd\u003cbr\>\u003cbr\>\u003c/pre\>\n\u003c/blockquote\>\n\n\u003chr\>\n\u003cfont size\u003d\"+1\"\>How to Make a Script\u003c/font\>\u003cp\>\n\u003c/p\>\u003cblockquote\>\nA Unix script is a text file of commands that can be executed, like a \u003cb\>.bat\u003c/b\> file in DOS. \nUnix contains a powerful programming language with loops and variables that I don&#39;t really understand. \nHere&#39;s a useful example.\n\u003cp\>\nUnix can&#39;t rename a bunch of files at once the way DOS can. \nThis is a problem if you develop Web pages on a DOS machine and then upload them to your Unix Server.\nYou might have a bunch of \u003cb\>.htm\u003c/b\> files that you want to rename as \u003cb\>.html\u003c/b\> files, \nbut Unix makes you do it one by one. This is actually not a defect. (It&#39;s a feature!) \nUnix is just being more consistent than DOS. So make a script!\n\u003c/p\>\u003cp\>\nMake a text file (eg with \u003cb\>pico\u003c/b\>) with the following lines. The first line is special. It tells\nUnix what program or shell should execute the script. Other # lines are comments.\n\u003c/p\>\u003cpre\> #! /bin/csh\u003cbr\> # htm2html converts *.htm files to *.html\u003cbr\> foreach f ( *.htm )\u003cbr\> set base\u003d`basename $f .htm`\u003cbr\> mv $f $base.html\u003cbr\> end\u003cbr\>\u003c/pre\>\nSave this in your home directory as \u003cb\>htm2html\u003c/b\> (or whatever). \nThen make it user-executable by typing \u003cstrong\>chmod 700 htm2html\u003c/strong\>.\nAfter this a \u003cb\>*\u003c/b\> will appear by the file name when you \u003cb\>ls -F\u003c/b\>, to show that it&#39;s executable. Change to \na directory with \u003cb\>.htm\u003c/b\> files and type \u003cb\>~/htm2html\u003c/b\>, and it will do its stuff.\n\u003cp\>\nThink about scripts whenever you find yourself doing the same tedious thing over and over.\n\u003c/p\>\u003c/blockquote\>\n\n\u003chr\>\n\u003cfont size\u003d\"+1\"\>Dotfiles (aka Hidden Files)\u003c/font\>\u003cp\>\n\u003c/p\>\u003cblockquote\>\n\u003cb\>Dotfile\u003c/b\> names begin with a &quot;.&quot; These files and directories don&#39;t show up when you list a directory unless you\nuse the \u003cb\>-a\u003c/b\> option, so they are also called ",1] ); //-->
alias q quota -v

alias bye exit
alias ls ls -F
alias dir ls
alias cdup cd ..
alias motd more /etc/motd


How to Make a Script

A Unix script is a text file of commands that can be executed, like a .bat file in DOS. Unix contains a powerful programming language with loops and variables that I don't really understand. Here's a useful example.

Unix can't rename a bunch of files at once the way DOS can. This is a problem if you develop Web pages on a DOS machine and then upload them to your Unix Server. You might have a bunch of .htm files that you want to rename as .html files, but Unix makes you do it one by one. This is actually not a defect. (It's a feature!) Unix is just being more consistent than DOS. So make a script!

Make a text file (eg with pico) with the following lines. The first line is special. It tells Unix what program or shell should execute the script. Other # lines are comments.

    #! /bin/csh
# htm2html converts *.htm files to *.html
foreach f ( *.htm )
set base=`basename $f .htm`
mv $f $base.html
end
Save this in your home directory as htm2html (or whatever). Then make it user-executable by typing chmod 700 htm2html. After this a * will appear by the file name when you ls -F, to show that it's executable. Change to a directory with .htm files and type ~/htm2html, and it will do its stuff.

Think about scripts whenever you find yourself doing the same tedious thing over and over.


Dotfiles (aka Hidden Files)

Dotfile names begin with a "." These files and directories don't show up when you list a directory unless you use the -a option, so they are also called <!-- D(["mb","\u003cb\>hidden files\u003c/b\>. \nType \u003cb\>ls -la\u003c/b\> in your home directory to see what you have.\n\u003cp\>\nSome of these dotfiles are crucial. They initialize your shell and the programs you use,\nlike \u003cb\>autoexec.bat\u003c/b\> in DOS and \u003cb\>.ini\u003c/b\> files in Windows. \n\u003cb\>rc\u003c/b\> means &quot;run commands&quot;. These are all text files that can be edited, but change them at your peril. \nMake backups first!\n\u003c/p\>\u003cp\>\nHere&#39;s some of what I get when I type \u003cb\>ls -laF\u003c/b\>:\u003c/p\>\u003cp\>\n\u003ctable border\u003d\"0\" width\u003d\"500\"\>\n\u003ctbody\>\u003ctr\>\u003ctd\>.addressbook \u003c/td\>\u003ctd\>my email addressbook.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.cshrc \u003c/td\>\u003ctd\>my C-shell startup info, important!\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.gopherrc \u003c/td\>\u003ctd\>my \u003cb\>gopher\u003c/b\> setup.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.history \u003c/td\>\u003ctd\>list of past commands.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.login \u003c/td\>\u003ctd\>login init, important!\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.lynxrc \u003c/td\>\u003ctd\>my \u003cb\>lynx\u003c/b\> setup for WWW.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.ncftp/ \u003c/td\>\u003ctd\>hidden dir of \u003cb\>ncftp\u003c/b\> stuff.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.newsrc \u003c/td\>\u003ctd\>my list of subscribed newsgroups.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.pinerc \u003c/td\>\u003ctd\>my \u003cb\>pine\u003c/b\> setup for email.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.plan \u003c/td\>\u003ctd\>text appears when I&#39;m \u003cb\>fingered\u003c/b\>, ok to edit.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.profile \u003c/td\>\u003ctd\>Korn shell startup info, important!\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.project \u003c/td\>\u003ctd\>text appears when I&#39;m \u003cb\>fingered\u003c/b\>, ok to edit.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.signature \u003c/td\>\u003ctd\>my signature file for mail and news, ok to edit.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.tin/ \u003c/td\>\u003ctd\>hidden dir of my \u003cb\>tin\u003c/b\> stuff for usenet.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>.ytalkrc \u003c/td\>\u003ctd\>my \u003cb\>ytalk\u003c/b\> setup.\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003c/tbody\>\u003c/table\>\n\u003c/p\>\u003c/blockquote\>\n\n\u003chr\>\n\u003cfont size\u003d\"+1\"\>DOS and UNIX commands\u003c/font\>\u003cp\>\n\u003c/p\>\n\n\u003ctable border\u003d\"0\" width\u003d\"500\"\>\u003ctbody\>\u003ctr align\u003d\"left\"\>\u003cth\>Action\u003c/th\>\u003cth\>DOS\u003c/th\>\u003cth\>UNIX\u003cbr\>\n\u003c/th\>\u003c/tr\>\u003ctr\>\u003ctd\>change directory\u003c/td\>\u003ctd\>cd\u003c/td\>\u003ctd\>cd\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>change file protection\u003c/td\>\u003ctd\>attrib\u003c/td\>\u003ctd\>chmod\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>compare files\u003c/td\>\u003ctd\>comp\u003c/td\>\u003ctd\>diff\u003cbr\>\n\u003c/td\>\u003c/tr\>\u003ctr\>\u003ctd\>copy file\u003c/td\>\u003ctd\>copy\u003c/td\>\u003ctd\>",1] ); //--> hidden files. Type ls -la in your home directory to see what you have.

Some of these dotfiles are crucial. They initialize your shell and the programs you use, like autoexec.bat in DOS and .ini files in Windows. rc means "run commands". These are all text files that can be edited, but change t

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值