A Little Shell Music
This was originally written for the use of Santa Rosa Junior College students on the "Nermal" system that Scott built and adminned, until he and Dane decided that was so much fun they may as well make a living at it and founded Sonoma Interconnect (towards which all of us SRJC geeks made quick tracks). The original of this document can be found all over the Net... all I did was make it a little less scary (I hope). Wherever this says "Nermal" please change it to (your bash [Bourne Again SHell] -using Linux system's name here).
v 1.0 (2/95) = Ding an sich.
v 3.1 (1/97) = Added a truly great chmod guide (thanks, Don's friend!)
v 3.11 (4/97) = Aesthetic upgrade.
Anybody else have any comments? Then away we go!
Unix/Linux Command Reference
(adapted and revised by Neal Attinson (email@example.com) from a Berkeley unix.hlp file, for the Nermal-flavored Linux Operating System. Last revision dated on or near January 1997.)
A Word to the Fore
You've finally logged on to Nermal, gotten your account all set up and are now puzzled by only one thing-- how do you find your way around this place?
Fear not! The following file will help you with some basic commands and show you how to teach yourself others. Like anything else, there's a learning curve; but if you are coming here from a command-line interface such as DOS it's just a matter of substituting one command for another. If you're more familiar with a point-and-shoot interface like MacWindoze, consider it a lesson in how *real* operating systems work. ;-)
You may download this file by saving it (hit "p" if you're viewing it with lynx, "s" if you're viewing it through gopher) then typing
(Don't worry about the extra "l"). If your communications program doesn't handle the Zmodem protocol, try typing "sx unix.html" and then activating an Xmodem transfer. This file is approximately 6 pages when printed out.
All documentation for the system is online. By using the "apropos" and "man" commands, you can usually find anything. For example, if you want to find all the commands that relate to files, enter the following (all commands are entered at the system prompt, or $ symbol):
(There are quite a few of these, so if you enter
they"ll print to the screen and stop when the screen is full; hit the spacebar to see the next screen.)
To find out what a particular command does, you'd type
where "foo" is the command you want to find out more about. (Note: the word "foo" is a term long-used by those in the computer community to stand for something else; it and its companion terms "bar", "baz", etc. are technically known as metasyntactic variables. Likewise, any term below that's mentioned (inside parentheses) is also considered a variable, where a too-exuberant use of "foo" would make things unclear.)
Look at the general command format and conventions of this document near the end. (See Contents, below)
A couple of notes about filenames: Filenames on Linux can be up to 255 characters long. Don't use filenames that contain spaces; you'll have a hard time doing anything with them. If you use a filename with more than eight letters, the excess letters will be automatically stripped when you download the file to a DOS-based machine.
(backspace) delete previous character from screen ^W delete previous word from screen ^U delete whole current line from screenJob Control
^C kill the current process ^Z stop the current process, but leave it around.End of File
^D end of file - if you are reading a file from the terminal, this ends it. If you are at command level (system prompt), it will log you out(Go to Contents)
cat foo (foo = filename of file to be displayed) conCATenate: copies files to standard output (monitor screen) as one file. Similar to the DOS "type" command. cd (directory) Change working Directory. With no arguments, this will return you to your home directory (/home/user/yourloginname, or ~/) if you are somewhere else in the directory tree (like /pub/.0/disc1, for example) chmod (mode) (files) CHange MODe for files. [This is file protection.] E.g. "chmod go+rx foo" allows Others to Read. first letter from "ugo" [user, group, others] symbol is + to add, - to remove, = to set second letter from "rwxst" [read, write, execute, setuid, sticky] (Here's a better way to look at it -- Permission mode bits: +------------------ 0400 read by owner | +---------------- 0200 write by owner | | +-------------- 0100 execute (search in directory) by owner | | | +------------ 0040 read by group | | | | +---------- 0020 write by group | | | | | +-------- 0010 execute/search by group | | | | | | +------ 0004 read by others | | | | | | | +---- 0002 write by others | | | | | | | | +-- 0001 execute/search by others | | | | | | | | | r w x r w x r w x chmod 777 r w x r w x r w x r/w/x by all chmod 755 r w x r - x r - x r/x by all; w by owner chmod 744 r w x r - - r - - r by all; w/x by owner chmod 700 r w x - - - - - - r/w/x by owner only chmod 666 r w - r w - r w - r/w by all chmod 644 r w - r - - r - - r by all; w by owner chmod 600 r w - - - - - - - r/w by owner only ^^^^^ ^^^^^ ^^^^^ | | |_____ OTHER | | | |___________ GROUP | |_________________ OWNER Skip ahead to find out more about rwx-ness.) cp (file1) (file2) CoPy file cp (files) (directory) CoPy several files into a different directory -i interactively confirm if will overwrite an old file -r recursively copy all files in directories diff (file1) (file2) shows DIFFerences between files -b ignore blank spaces -c show more of the context du [directory] shows Disk Usage of directory [default: current dir] dr shows how much disk space you're currently using. Since you have a 2 Megabyte quota, this comes in handy since some files can get big fast, like ~/Mail/sent. emacs (file) edit file with EMACS. (Try "teach-emacs" to learn about EMACS.) There are two other file editors available here, "pico" and "joe". The former is easier for novices, the second is more versatile; pico is the default editor for the Pine mail program, and joe for the Elm mail program. Invoke them as for emacs.) grep (pattern) (files) search all files for a string (actually a general pattern) Many options. fgrep and egrep are minor variants. head (files) show HEAD (first few lines) of files [default std in] ln oldfile newname LiNk files: create an alternate name for a file ln -s filespec name symbolic LiNk: "name" will refer to filespec lpq show Line Printer Queue lpr files print files on Line PRinter [has many options] lprm ReMove current job from Line Printer [if yours] lprm - ReMove all your jobs from Line Printer lprm jobnumber ReMove specified job from Line Printer ls (files) LiSt files [default: all files in directory] (similar to DOS "dir/w" command) -a all files [normally files starting with . not shown] -l long form - give lots of information (similar to DOS "dir" command, with no switches.) -t time-sorted - most recent first -R Recursively look into directories ll same as "ls -l"
These options can be combined, as in "ls -laR", which shows you every file in every directory under the one in which you invoke it.
--(A note about the file system: Just as DOS's "dir" command gives you the size, date and other values related to a file, so does Linux' "ls -l" and "ll" commands. The result looks like this:
total 94 drwx------ 10 nattinso user 1024 Feb 13 06:43 . drwxr-xr-x 656 root root 16384 Feb 10 14:38 .. -rw-r--r-- 1 nattinso user 800 Feb 12 13:36 .bash_history drwx------ 2 nattinso user 1024 Oct 11 20:06 .elm -rw-r--r-- 1 nattinso user 3223 Feb 13 06:43 .newsrc -rw-r--r-- 1 nattinso user 588 Oct 14 15:39 .plan -rwx------ 1 nattinso user 1092 Feb 13 06:32 .profile -rw-r--r-- 1 nattinso user 37 Jul 9 1994 .project drwxr-xr-x 4 nattinso user 1024 Feb 13 06:43 .tin -rw-r--r-- 1 nattinso user 1170 Jan 27 22:20 .webbk drwx------ 2 nattinso user 1024 Feb 13 06:34 Mail drwxr-xr-x 2 nattinso user 1024 Feb 13 06:36 News drwxr-xr-x 2 nattinso user 1024 Jan 7 21:58 s -rw-r--r-- 1 nattinso user 20292 Feb 12 13:09 unixhelp -rw-r--r-- 1 nattinso user 1757 Jan 21 23:18 ylist
At the very top, we have a total (in kilobytes) of the size of this directory. Each listing thereafter is a file or directory; the column at the left tells you which (entrys beginning with "d" are directories, those with "-" are files) and lists the permissions (what may be done with them) for each -- Read, Write, or eXecute. To be more clear: if
then 0 tells you whether you're looking at a file or a directory; 123 list the permissions of the file's owner, 456 the permissions of the group (see "man chgrp" for details) and 789 the permissions of everybody else not included in the first two fields.
Filenames beginning with "." are only seen with the "ls -a" switch. These are usually configuration files/directories of various sorts (especially if they end in "rc").
more (files) view files a screen at a time mv (oldfile) (newname) MoVe or rename file mv (files) (directory) MoVe files into a directory -i interactively confirm if new name exists - kludge to handle files that begin with "-" pwd Print Working Directory name rm (files) ReMove files (actually only 1 link to them) -i interactively confirms each one -r recursively remove contents of directories - kludge to handle files that begin with "-"
NOTE!! Never, ever type "rm *" from your home directory, as this will more-or-less irrevocably delete ALL the files therefrom. There is no way of conventionally undeleting files under Linux.
rmdir (directory) ReMove DIRectory tail (file) show TAIL (last few lines) of a file [default: std in] touch (files) update last write date of files to current date-time
cc (files) Compile C files. Normally loads as a.out -c don't load, leave relocatables as foo.o -gx produce info for debugger [always use this] -O optimize -o output name the output file this f77 (files) Compile Fortran files. Normally loads as a.out. Can handle several languages: .f Fortran .F Fortran but through C preprocessor first .r Ratfor .e EFL .c C .s assembly -c don't load, leave relocatables as foo.o -C put in code to check array bounds -g produce info for debugger [always use this] -O optimize -o output name the output file this pascal (files) Compile PASCAL files. Normally loads as a.out -c don't load, leave relocatables as foo.o -g produce info for debugger [always use this] -O optimize -o output name the output file this
apropos (word) find all commands and subroutines whose descriptions include this word date print current DATE and time finger who is logged in, how long idle, office addr and phone finger (user) shows personal information [use "joe .plan" to set yours up] groups (user) what GROUPS does user [default: you] belong to? history (number) print most recent number command you did. elm, pine send and read mail. Too complex to describe here man [section] (name) look up command, routine, etc. in manual. If section specified, look only in that section. printenv PRINT your ENVironment variables (terminal type, etc.) ps [options] show processes. default is only yours -a all processes controlled by a terminal -g show group leaders (top level processes) -tx processes on tty x, e.g. ti03 for ttyi03 -u user oriented output -x even processes with no terminal stty show current terminal settings time (command) print execution TIME, etc., of a command uptime amt of TIME system has been UP, load avg, etc. users compact list of all USERS logged on news read system news/announcements w Who is on system, when logged in, load avg., etc. whatis (name) gives you title line from thing's manual entry whereis (name) finds location of system files who [name] who is on the system, when logged in, terminal
.profile a file in your home directory. Is obeyed by the shell whenever one starts. alias list all defined commands (Defined commands are similar to batch files in DOS, except that you put them all in one file ("~/.profile"). Aliases follow the format alias foo="bar" For example, let's say you want to check and see if a friend of yours is logged in so you can have an on-line chat. You could type finger firstname.lastname@example.org but that can get old fast (especially if you're not an adroit typist and you want to do this every time you log in.) So you enter the following in ~/.profile (using joe, pico or emacs): alias check="finger email@example.com" At the system prompt, type . .profile so that Nermal will recognize the alias. Now, all you have to do is type check and the system takes care of the rest.) clear CLEAR terminal screen passwd change your PASSWorD. Asks for old and twice for new script (file) put SCRIPT of terminal session in a file -a append to existing file setenv (variable) (value) set a variable in your "environment", e.g term type. Use "printenv" to see what sorts of things there are stty [options] set up your terminal. Too many options to list here. stty show current options
ftp File Transfer Program - copy files over network talk (person) [ttyname] establish two-window TALK link. other person must also type the command first. End with ^C. telnet (host) login on remote host. ^[q to quit. news read system news/announcements write user [ttyname] WRITEs line from your terminal to his. end with ^D. ! line ! at beginning of line causes it to be executed There are a few programs for the reading of USENET news; USENET is a world-wide messaging system that actually predates (by a few years) the ARPANET, predecessor of today's Internet. The best one for beginners is probably "tin", invoked by typing "tin" at the system prompt; others here include "rn", "nn" and "trn". Two other programs of note for exploring things Internetic are "gopher" and "lynx"; the former was developed at the University of Minnesota as a means of getting a handle on the Internet's vast information resources, and the latter is a text-based World Wide Web (hypertext) browser. Invoke them by typing their names at the system prompt.
^C kill current job ^D unless you have does "ignoreeof", ^D will log you out (or exit from recursive shell) ^Z stop current job, but leave it around. (use "fg" or "bg" to continue it, "jobs" to see it) clear CLEAR terminal screen logout, exit, bye log off the system bg [%job] continue a job in background. [Default: current job] kill (123) KILL process 123 [system-wide numbering, use "ps"] kill %1 KILL job 1 [your process 1, use "jobs"] -9 don't let it trap the interrupt fg [%job] continue a job in foreground. [Default: current job] stop [%job] stop a job [default current] running in background %job [&] continue a job in foreground [in background if &]
(files) a list of file names, separated by spaces, with possible * and ? as wildcards %job % followed by a job number or the name of the program running in the job. Use the "jobs" command to list your jobs. The one with + by it is the "current job". NB: The term "job" is used in the C Shell to refer to a subprocess running under the control of your shell. This is a bit confusing, since the word "job" normally refers to everything a given user is doing. (Indeed the term is used elsewhere in Unix with this meaning.) -x options are listed below the command they apply to. Several options can be combined with a single -. E.g "ls -lt". The options are always given right after the command name, before any other arguments.
command [-options] arguments [<inputfile] [>outputfile] [>erroroutfile] [&] * command is the name of a program. The "PATH" variable shown by "printenv" shows you where it looks if you don't specify a directory name. Normally your own directory is in the path, so you can run a program you have compiled just by typing its name. * options are normally single letters, with a "-" before them * arguments are normally file names, separated by spaces, but can be other things <>>& cause standard input, standard output, and error output to be redirected to files. Not all commands use standard input or output. Typically these represent what you would expect to appear on the terminal. Some commands let you specify a file name, and read from that file, but if you don't specify one, they read from standard input. & at the end of a command causes it to be done in the background. You can type other commands while it is being done.
The syntax for files, directories, and devices is the same: a/b/c/d... where a, b, c, d, are successive levels in the directory hierarchy, starting with the current directory. So prog.c is a file in the current directory bigsystem/prog.c is in a subdirectory contained within the current directory bigsystem/source/prog.c is in a nested subdirectory, etc. Dots are just another character, but the tendency is to have a single dot in a file name, and have what is after the dot indicate what the file is, e.g. the language it is in. So ".c" is usually a C program, ".p" Pascal, ".o" a relocatable object file, etc. If you start the name with a /, then you are giving a directory path starting at the top-level directory (called the "root"). For efficiency reasons, user directories are not directly in the root, but are subdirectories of /u1 or /u2. So one of my files might be /u1/hedrick/prog.c If my current directory is "/u1/hedrick", then I can refer to that file as "prog.c" Devices are simply special files, normally put in the directory /dev. E.g. your terminal can be referred to as "/dev/tty". If you want to use someone else's terminal, you have to specify the number, e.g. "/dev/ttyi06". The tape drive is "/dev/mt0". Some programs also want access to "raw devices", e.g. the raw tape drive is "/dev/rmt0". This bypasses some levels of the device driver, and is supposedly "more efficient". Don't use a name beginning with "/dev/r" unless the program specifically asks for a raw device. Tape drives are even more complex, as the number encodes (1) which tape drive it is, (2) what speed you want, and (3) whether to rewind it before use. There are some special characters that you can use in file names: . the current directory, e.g. "cp /u1/hedrick/prog.c ." which copies the file to the current directory .. the directory above the current one ~hedrick hedrick's home directory. Since you don't know whether a user's home directory is on /u1 or /u2, it is safest to use this syntax to refer to another user's files.
!n command number [use "history" command to see them] !-n n commands ago !! previous command !xxx command beginning with xxx !s/old/new/ reexecute previous replacing old with new ! | more reexecute, piping output through "more" Actually you can do far more general things, but see "man bash" for that.
And that's it! There are literally hundreds of commands, utilities, applications, etc located on this system, but these should serve to get you started.Go back and start over!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~~~~Saint Sisyphus -- "This time, for sure!" - o__/?\ /^^ patron of the quitless. / (???) /^^ (Neal Attinson) /) \?/ /^^ (firstname.lastname@example.org) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Nancy Harrison Life Sciences - Santa Rosa Jr. College Santa Rosa, CA 95401 ----Member California Native Plant Society------