UNIX Basics --- J. Maybury -------------------------- remember the general format of the Unix command line is: % command [option(s)] [argument(s)] ^ | prompt Also it is important to note that Unix is case-sensitive so commands must be typed in all lowercase otherwise they will not work. Also if you name a file project1.c and another file Project1.c they are two different files because one begins with a capital P and the other a lowercase p. A BRIEF summary of SOME Unix commands : passwd - changes your password options (optional): -f to change your finger information no arguments. chfn - changes your finger information no options. no arguments. logout - logs you off the system no options. no arguments. man - displays reference (manual) pages for a command options (optional): -k to look for a keyword rather than an exact command match arguments (required) - must type at least one argument and it will display the manual pages for that argument, which should be the name of a Unix command. If it cannot find manual pages for the argument it will say so. If you use the -k option it will display a Brief listing of EVERY command that is related to the argument you give (try: man -k delete). note: man pages can be hard to read at first, but can be very helpful in the long run. They are displayed using something similar to the more command (see below for info on the more command) finger - displays user information no options. arguments (optional) - with no arguments it will list the current users on your "host" machine (one of the detectives). If you have any arguments they must be user ids (ex: jm299c28) and you can have as many of them as you want. When you have argument(s) it will list the finger information for each argument (user id) - even if they are not logged on. ls - lists names of files and directories options (optional - there are MANY more, use man to find out about the many other options and how they work): -l for a long listing (includes info about permissions) -F will mark directories with a / and executable files with a * arguments (optional) - you can have as many arguments as you want, but all arguments must either be filenames or directories. If an argument is a filename it will just list that filename, if an argument is a directory it will list the contents of that directory. So for example if you have three arguments (which are all directories) then it will list the contents of all three directories. cd - changes directories no options. arguments (optional) - with no argument it will put you back into your "home" directory. With 1 argument it must be a directory (or a pathname). At most you can have 1 argument. rm - delete (remove) a file options (optional): -i will do an "interactive" delete arguments (required) - all arguments must be the names of existing files (you may use a pathname with each file name). You may have 1 or more arguments. This will not delete directories (unless you use a special option - see the man page). Also, once a file is deleted it is gone forever. cp - copy one file to another options (optional): -i will do an "interactive" copy arguments (2 required) - The first argument must be the name of a file that already exists (you may use a pathname with this filename). The second argument can be a directory - if so it will copy the file into the directory and name the new copy the same as the original file. OR the second argument can be a filename - if so it will create a new copy with the name of the second argument (you may use a pathname with this filename). mv - move (or rename) a file options (optional): -i will do an "interactive" move arguments (2 required) - basically the same as cp. The only difference from cp is that the orginal file will no longer exist. mkdir - make (or create) a new directory no options (there are actually some options, see the man pages if you are interested in findout out about them - most commands do have options, only some of the most common ones are listed in this handout). arguments (required) - must have at least 1 argument but can take more than 1. Each argument must not be an already existing file or directory (you may use a pathname with each argument). rmdir - remove (or delete) a directory no options. arguments (required) - must have at least 1 argument but can take more than 1. Each argument must be the name of an already existing directory (you may use a pathname with each argument). Also each directory you are deleting must be completely empty - so you need to delete any files first by using the rm command. cat - display file no options. arguments (required) - must have at least 1 argument but can take more than 1. Each argument must be the name of an already existing file (you may use a pathname with each argument). Also, if the file does not contain text this could produce some "weird" results (lots of noise). more - display file (one screenful at a time) no options. arguments (required) - must have at least 1 argument but can take more than 1. Each argument must be the name of an already existing file (you may use a pathname with each argument). You should only use this command on files that contain text. commands: q - quit the more utility b - go back one screenful - display next page - display next line h - displays a help screen with many more commands less - similar to more, see the man page, or try it out users - lists who is currently logged on no options. no arguments. rwho - lists who is currently logged onto ALL class cluster machines no options. no arguments. lpr - print command no options. arguments (required) - one, the TEXT file you want to print. qpr - another print command options (required): -q to tell it which printer to print to arguments (required) - one, the text file you want to print. example usage (to print from the class cluster): qpr -q prl project1.c cc - c compiler options (optional): -std1 will force the compiler to use ANSI standard c -trapuv will help find uninitialized variables -o will create a different output file then a.out arguments (1 or 2 required) - if you use the -o option the first argument required is the name of the new output file (instead of a.out). The next argument must be a c program file. BE VERY CAREFUL when using the -o option not to accidentally delete your program - ALWAYS make a backup of your .c file example usage: cc -std1 -trapuv project1.c -o p1.x The following is VERY bad: cc -std1 -trapuv -o project1.c p1.x emacs - a visual text editor options (optional): -nw needed if you are using a Sun or Sparc workstation and are remotely logged in (unless you setup your display and hosts correctly). arguments (optional) - with no argument it will start up editing a blank "buffer". If you have 1 argument and it is the name of a file that already exists it will start up editing with a COPY of that file in the "buffer". If you have 1 argument and it is the name of a file that DOES NOT already exist it will create a newfile (and give it that name) and it will start up editing the contents of that newfile (so it will be a blank "buffer"). commands (note these are CONTROL sequences, so if the command is C-f that means control-f and you hold down the control key and while holding it down hit the f key): C-x C-s - saves the contents of the current buffer C-x C-w - writes the contents of the current buffer to another file C-x C-c - exits out of emacs back to the UNIX prompt C-d - deletes the current character under the cursor C-p - moves cursor up one line (previous) C-n - moves cursor down one line (next) C-b - moves cursor back one character C-f - moves cursor forward one character C-_ - undo (undoes last thing done) C-x u - same as C-_ (if repeated enough it will put the file back the way it was to begin with) C-h - gets help (but be careful with this) pine - a visual e-mail program no options. no arguments. commands - use the arrow keys to move up or down the list of choices. Also you can use any of the commands listed on the bottom 2 lines of the screen (just press the key that corresponds to the letter(s) highlighted - if the letters highlighted are ^X that means hold down and then press x).