Basic Unix Commands

Note on systax used in document:
items in [] are optional
items in {} can be repeated 0 or more times.
fn = filename (possible with wildcards)
dir = directory name

File System:

cat fn {fn}
concatenate, can be used to display a file.
more fn {fn}
displays file(s) one screenful, at a time. At MORE prompt enter: space bar - for next screenful <cr> - for next line, q - to quit more command.
cp fn1 fn2
copy file - fn1 to fn2, fn1 remains.
mv fn1 fn2
move (rename) file - fn1 to fn2, fn1 no longer exists.
rm fn
remove (delete) file.
lpr -Pprinter_name fn
print a file, printer_name = ps16 or ps17.
ls [fn]
list files in current directory option filename is usually used to display files matching wildcards. (ie. ls *.s will list all assembly language source files.)
ls -lgRa
Recursive listing of all files within all subdirectories. Longest, most descriptive format.
cd [dir]
change working directory, ``home directory" if not specified. cd .. will backup one level in the directory structure.
print working directory path.
mkdir dir
make a new directory, giving it the name dir (within the current directory)
rmdir dir
remove (delete) the directory named dir (the directory must be empty)
file fn
Tries to determine what kind of information is in a file by consulting the file system index and by reading the file itself.
Prints a summary of total space occupied by all files in a hierarchy.
sort fn
Sorts ASCII files line-by-line.
Change file permissions. See the man pages for a complete description of settings. Use this command to determine whether files can be readable by other people.
find . -name filename
In it's most simple form find will display all files in this and any subdirectories which name matches filename. See the man page for find for a complete description of this command. Find can be use to find files matching name patters, dates, owners, sizes, etc. and to perform action on matched files.
gzip fn
Use this to compress files not needed immediately to conserve disk space. A ``.gz" will be appended to the filename.
gzip -d
Uncompresses files with ``.Z" at end of filename.
head {-n} fn
Prints first n lines of a text file. If no number is specified, the default is 10.
tail {-n} fn
Prints last n lines of a text file. If no number is specified, the default is 10.
tail {-n} fn
Prints last n lines of a text file. If no number is specified, the default is 10.
grep string fn
Print occurrences of string in file

Remote Connection:

ssh remote_host
Launch a secure shell to the remote host specified.


list users currently on the system.
list users currently on the system.
what, similar to who but includes what they are doing.
Email message utility.
pine username
will send Email to username.
talk username
allows two users to have an interactive conversation over the computer.
write username
allows a user to put a message on another users screen.
mesg n
Makes it so other users cannot interrupt you with talk requests, and write messages.


man command
manual, returns the manual for the given command from the UNIX on-line manual. If you cannot find a man page for a command, there may be one in a directory that isn't in your MANPATH. Your MANPATH is setup in the .login file and a command's man page is usually in a man directory off the same parent directory as the command. For example, if the command is located in /usr/local/bin, its man page is probably in /usr/local/man.
man -k keyword
display manual headings containing the word keyword.


alias name def
Assigns ``def'' to the alias ``name''. Usually found in the .cshrc file. For example ``alias dir ls -la''.
Clears screen.
List history of commands used.
re-execute the last command entered.
re-execute the last command that started with the given letter, eg !c will re-execute the last command that began with the letter c.
jobs -l
list all currently stopped or background jobs with job numbers and process ID's.
kill [-signal] %jobnumber
kill the given job number. Use the "jobs" command to show running jobs. You might need to kill a job to logout if you have accidentally put a job into the background or stopped a job. Use -TERM or -KILL singlas to force quite jobs.

kill PID
kill the given Process. refer the "ps" command to find running processes. Use -TERM or -KILL singlas to force quite jobs.
ps -fa
list all your current processes. See the man page for a full description.
kill the current process - the one in the  foreground
suspend foreground process.
put a suspended job in the background.
put a suspended or background job in the foreground.
display time and date.

To find out about more commands, click  here.

FAQ Priority: 
FAQ Category: