Simple UNIX Commands
- Lists the files in the current directory.
ls -l gives more information about the files. -l stands for the
- Copies a file.
cp sample.c example.c makes a copy of sample.c and names the new
sample.c still exists.
- Renames a file.
mv average.c mean.c changes the name of the file from average.c to
average.c no longer exists.
- Removes or deletes a file.
rm olddata.dat would delete the file olddata.dat
- Types the contents of a file onto the screen one page at a time.
more example.txt would show the contents of the file example.txt
one screenfull at a time.
You must press the spacebar to advance to the next page or <Enter>
advances one line at a time. You may type q to quit or b to go back to
the beginning of the file.
- Displays the contents of a file onto the screen all at once. If the
file is too long to fit onto the screen, it scrolls and you see only the
last screenfull of the file. cat is also used to combine two or
more files and stands for concatenate.
cat mean.h just displays the contents of mean.h
cat mean.h counts.h > statistics.h concatenates the two files mean.h
and counts.h by tacking the contents of counts.h onto the end of mean.h and
calls the new, combined file statistics.h.
mean.h and counts.h still exist in their original form.
- Makes a new subdirectory in the current directory.
mkdir 201 will make a new directory called 201 in the current
- Removes a subdirectory from the current directory, but the subdirectory
must contain no files. You must delete all of the files from a directory
before you are allowed to delete it.
- The command cd alone will return you to your home directory.
- cd 201
- cd followed by a directory name that is found in the current directory,
will change from the current directory to its specified subdirectory, if
that subdirectory exists. So cd 201 will change from the current
directory into its subdirectory called 201, if that subdirectory exists.
- cd ..
- Moves you up one level in the directory tree.
- Tells you the directory you're currently in. pwd stands for print
working directory. I find it easier to think of it as standing for
present working directory.
- Prints a file
lpr sample.txt would print the file called sample.txt on the
Academic Computing Services postscript printers found in Room ECS 019.
There is a charge per page for printing.
- Gives a description of a UNIX command and also C keywords and
functions. So man cat will tell you all about the cat command. If
you don't know the name of a command, but you do know what you want to
do, use man -k. If you've forgotten the command for copy, you could
type in man -k copy and you would be supplied with the names of all the
commands that have the word copy in their description, one of which will
be cp. The man command uses the more facility to present the
information, so you must press the spacebar to advance to the next page.
<Enter> advances a line at a time. You may type q to quit or b to go
back one page.
- Tells you the login names of all of the people that are currently
logged onto the same computer as you are. They are not in any order and
it will scroll off the screen.
- "The pipe" is used to combine commands. It "pipes" the output of one
command to be used as input to the next command. Here's a typical use of
the pipe. who|sort|more This will give you all of the people's
login names that are currently logged onto the same machine as you, in
sorted order, one page at a time.