UNIX HELP David Ljung Notation for commands: < arg > is a required argument [ arg ] is an optional argument < arg1 | arg2 > means either arg1 or arg2 dir is a directory path (such as /users/mgaddis) path is a path (to a directory or a file or whatever) Paths: Each path component is separated by a '/'. So /users/mgaddis/blah would be the file (or directory) called blah, in the mgaddis directory, in the users directory from the root directory. This is an example of an absolute path - it starts with '/' so you know that it is absolutely from the root directory, no matter where you are. On the other hand, the path mgaddis/blah is a relative path. It is the file blah in the directory mgaddis in the current directory you are in. This is only the same as the first path if you are in the /users directory. So it is relative to where you are. Commands: cd [dir] change directory (to 'dir' or to home if no arg given) pwd Show current path (the directory you are in) ls [path] list contents (shows a catalog of files in a directory) (uses current directory if no arg given) cat [path] Shows all the contents of a file. Just dumps them to your screen more [path] Shows the contents of a file one page at a time uname -a Shows information about the system you are on. man [command] Read the man(ual) pages on a command. VERY USEFUL! Try typing 'man ls' Then when you understand the above commands, look at some of the 'SEE OTHERS' listed in the man pages. Common UNIX structure: Root directories: (type 'ls /' to see these) /etc Where extra bootup and OS info is kept /tmp Temporary directory. You can throw junk in here - it will probably get cleaned up periodically. /bin Essential UNIX commands /usr Where some user specific binaries and commands are kept /users Where the user directories are. Sometimes just called /u Sometimes called other names. /dev Device files. Don't worry about these for now - all I/O devices on the machine are considered device files... /lib Libraries for programming and what-not Other interesting directories/files: /usr/bin and /usr/local/bin Location of most UNIX commands /usr/lib User specific libraries /etc/passwd The password file. Yup, the password file on a UNIX system is usually world readable - but don't get all excited because the passwords are one-way encrypted. ~ Your home directory. Type 'cd' and then 'pwd' to find out what it is ~user/ A specific users home directory. To actually create files you need to learn an editor, such as 'vi' (which stands for visual editor). Example: In your home directory: (prompt is '% ') % ls <- shows all directories and files in current (home) directory Mail note (I made this up - Mail is a directory, note is a file) % mkdir joe <- creates directory % ls Mail note joe % cd joe <- changes to directory % ls (nothing is in this directory) % pwd <- print working directory /users/fred/joe % cd .. <- '..' is always the 'parent' directory % pwd /users/fred % cat note <- cat will dump the contents of the (text) file Hi! This is a note! % cp note joe/note.old <- copy 'note' to the directory joe, call it note.old % ls joe note.old % rm note <- remove file note: ? (y/n) y <- confirm % ls Mail joe <- note is now gone from this directory % mv joe/note.old Note <- move the note.old file from the directory joe ls Mail Note joe So, this is what we have: (any arguments in [] are optional, non-optional args are in <>) Commands -------- ls [directory] List contents of dir, or current dir if none specified pwd Print Working Directory (name of current dir) rm [...] Remove file(s) mv Move file (can rename and/or move to a diff. dir) cp Copy file or cp Copy some files to a directory (mv can do this to) cat [..] Show contents of file(s) more A pager: show contents of file - stop at page breaks less A better pager (less is more :) echo Simply outputs the string (i.e.: 'echo hi') another important command: vi Vi is a visual editor which can edit text files. It's awfully hard to use if you don't know how though. If you have it installed, some people like to use: pico Pico is a simple editor used by the pine mailer Wildcards --------- When you specify files you can use wildcards. The most common wildcard is *: Example: rm A*.gif Actually becomes any files that match that pattern: rm A123.gif Abob.gif Atest.gif A.gif....