Basic UNIX Commands

To succeed in Math 211, there are relatively few UNIX commands that you will need to know. Here is a short list, together with how to use them. In what follows, expressions like ls indicate commands that have to be entered at the UNIX prompt. The expression filename will stand for a filename of your choice. E.g., rm filename should be entered if you want to delete the file from the computer. If the name of the file is really garbage, then what you want to enter is rm garbage.

ls
is used to list all of the files in the current directory. For example, if there is a file is in the computer, but you aren't sure of what the file name is, simply enter ls. You will be presented with a list of all files in the current directory. If the file name you want is not on the list that the computer presents you with, then it is not there.

rm filename
will cause the computer to delete the file from its memory. This deletion is permanent! For that reason the computer will ask you if you are sure by responding rm:remove filename? If you respond with anything but yes (just y will do), the file will not be removed.

cp
is the copy command. The entry cp filename1 filename2 will result in a new file with name filename2, which will have exactly the same contents as filename1. If there already was a file with name filename2, the computer will respond overwrite filename2? If you respond with anything but a yes (or y), the cp command will be ignored.

mv
is the move, or rename command. The entry mv filename1 filename2 will result in filename1 being renamed filename2. If there already was a file named filename2, the computer will respond remove filename2? If you say yes, the contents of the old filename2 will be lost.

cat
is short for concatenate. This command has a variety of uses, but the most common one is to print the contents of a file to the screen. Simply enter cat filename, and the contents of the file will appear on the screen.

more
is the substitute for cat when the file is too long to fit on one screen. The command more filename will cause the file to appear on the screen one screenful at a time. Simply hit the spacebar when you want a new page to appear. Unfortunately you cannot page backwards.

After you have created a few files in your home directory, you will want to organize them. The way to do this is to put the files in appropriately named subdirectories. Here are the basic commands for doing this.
cd
stands for change directory. All by itself, cd will put you in the account's main directory. Used in conjunction with the name of a subdirectory, as is cd directory, it will result in changing location to the named subdirectory.

mkdir directory
will create a new subdirectory with the name provided.

rmdir directory
will delete the indicated directory. There is one catch. The directory must be empty or the command will not be executed.

You will occasionally want to print a file:
lpr
is the command to use when you want a hard copy of a file while using an Owlnet workstation. The command lpr filename will cause the file to be printed on a line printer. The command lpr -Pps filename causes the file to be printed on a nearby laser printer. Ask a fellow student to find out which printer will be used.
More complete information on UNIX is available.


Last modified: Tue Aug 27 11:55:37 CDT 1996