UNIX For Dummies Cheat Sheet
The UNIX operating system does things in its own UNIX way, so you need to get familiar with shell commands and garner some general tips for dealing with UNIX and finding your place within the system. Of course, you can do everyday things within UNIX, such as name files and print them, but even then, you need to know the UNIX way to accomplish these tasks.
UNIX Shell Commands
Whether your UNIX uses a Bourne-style shell or the C shell, you can do some simple typing to execute a range of commands. The following list shows a list of commands and what to type to execute them:
|To Do This||Type This||To Do This||Type This|
|Cancel a command||Ctrl+U, Ctrl+X, or @||List filenames with sizes and dates||ls -l|
|Change the working directory to /usr||cd/ usr||List hidden files too||ls -al|
|Change the working directory back to your home directory||cd||List files and pause when screen is full||ls | more|
|Copy a file||cp oldfile newfile||Look at a text file||cat letter|
|Copy a file to another directory||cp oldfile dirname||Look at a long text file||more letter|
|Copy a bunch of files to another directory||cp budget* dirname||Make a new link (name) for a file||ln oldname newname|
|Copy all the files in this directory and in all its
|cp -r * newdir||Make new links (names) for files in a directory||ln dirname/* newdir|
|Erase a file||rm junkfile||Combine two files||cat file1 file2 > newfile|
|Rename a file||mv oldname newname||Compare two files||diff file1 file2|
|Move a file to another directory||mv oldfile dirname||Look at the manual page for the ls command||man ls|
|List filenames||ls||Change your password||passwd|
How to Print with UNIX
UNIX lets you do everything any other operating system does, and that includes printing files and documents. The following table shows you how to print whether you’re on a System V UNIX or using Linux or BSD UNIX.
|To Do This||Type This on System V UNIX||Type This on Linux or BSD UNIX|
|Print file||lp textfile||lpr textfile|
|Print file on a named printer||lp -dprinter textfile||lpr -P printer textfile|
|Cancel a print job||cancel requestid||lprm jobnumber|
|Check the printer queue||lpstat -a all||lpq -a|
NetBSD, FreeBSD, OpenBSD, and BSD/OS are all BSD. Solaris 1, OSF/1, and AIX are similar to BSD. Solaris 2 is similar to System V. Your UNIX shell: Bourne Shell, C Shell, Korn Shell, and BASH Shell.
General UNIX Tips and Lost-and-Found Insight
Working with UNIX isn’t that complicated, but it does mean getting familiar with a whole new set of commands and ways of doing things. Here are some general tips when working in UNIX:
Log in before you use UNIX. Remember your user name and password.
When you see a prompt (usually $ or %), you can type a UNIX command.
To back up and correct typos, try pressing Backspace, Delete, # (Shift+3), or Ctrl-H.
To cancel what you have typed and try again, try pressing Ctrl+U or @ (Shift+2).
Type a space between the command name and any other information on the same line.
When typing commands, use the correct capitalization; UNIX distinguishes between CAPITAL and small letters.
When you have typed the command, press Enter (or Return).
When you log in, the working directory is your home directory.
To log out, type exit.
Don’t turn off terminal until you have logged out. Don’t turn off workstations or PCs except by running shutdown or halt.
If you forget where you are, how you logged in, and for other lost-and-found tips, use these:
To find out where you are, type pwd.
To find out who you logged in as, type who am I.
To find a file if you remember its name, type: find . -name filename -print
To find a file if you know that it contains the word dummies, type: grep “dummies“ *
UNIX Filenames and Pathnames
UNIX isn’t alone in being persnickety about creating and finding filenames and pathnames. Keep the following tips in mind as you create and search through UNIX files:
Capital and small letters are different in filenames.
Filenames can contain letters, numbers, periods, and underscores (_). Stay away from other punctuation. Slashes are special (see below).
Filenames shouldn’t contain spaces.
The ? wildcard stands for a single character in a filename. The * wildcard stands for a bunch of characters in a filename. An * by itself stands for all files in the working directory.
A pathname is the path in which you (or UNIX) can find a file or directory. The root (main) directory of the disk is called /.
A pathname consists of directory names separated by slashes (/). If a pathname starts with a slash (/), it begins at the root directory. If a pathname doesn’t start with a slash, it begins at the working directory.