Basic UNIX Commands
This document provides descriptions of selected UNIX commands.
cd
The command cd my_dir changes your position to the directory
specified, in this case my_dir. The command cd without an
argument moves you to your home directory.
cp
The command cp first_file copy_file copies the contents of
first_file into the file copy_file. To indicate that the
new file is to have the same name as first_file, use a period (.)
instead of of providing a name for the second file. (In
this case, the files must be in separate directories,
as two files cannot have the same name if they are in the same directory.)
For example: cp some_directory/my_file . copies
my_file, located in some_directory, and creates a file named
my_file in the current working directory.
lpr
The command lpr print_file sends print_file to the default
printer (see echo). The form
lpr -Pother_printer print_file sends print_file to
other_printer.
ls
The command ls lists the files in the current directory. The
form ls -F shows the difference between directories and
ordinary files. The form ls -a lists all files, even those that
are normally invisible in UNIX (files whose names start with a period,
i.e. .xstartup).
mkdir
The command mkdir new_dir creates a new subdirectory named
new_dir in the current directory.
more
The command more my_file displays the text of my_file
one page at a time. To see the next page, hit the space bar; to see the previous
page, type b; to quit paging the file, type q.
mv
The command mv file_name dir_name moves the file file_name
from the current directory into the directory dir_name, where
dir_name is a subdirectory of the current directory. The form
mv old_file new_file renames old_file and calls it
new_file.
pwd
The command pwd prints the pathname of the current, or working,
directory.
rm
The command rm my_file deletes my_file. The form
rm -i my_file asks if you really want to remove the
file my_file before it proceeds.
rmdir
The command rmdir my_dir removes the directory my_dir.
The directory must be empty before it can be deleted.
note: If you get an error message that a directory is not empty
when it appears to be, check for invisible files
(see ls).
more UNIX commands
UNIX Survival home page