Frequently used UNIX commands
Some frequently used UNIX commands to manage directories, files
etc. and simple utilties are summarized here. To get more descriptive help
on using UNIX commands you can go to
UNIX Commands.
Managing Directories
pwd show the current working directory
cd xyz change working directory to xyz
mkdir xyz create directory named xyz
rmdir xyz remove/delete directory named xyz
Directory Identifiers
~(tilde) your home directory
.(dot) the current working directory
.. the parent directory (one level up)
/ root directory
Managing Files
ls list files in the working directory
ls file1 list file file1 if it exists in the working directory
ls dir1 list contents of the directory dir1
ls -l list directory contents with addtional information
(long listing)
ls -a list all files including hidden ones (.* files)
cat file1 display contents of file1
more file1 display contents of file1, one page at a time
head -n file1 display first n lines (default=10) of file1
tail -n file1 display last n lines (default=10) of file1
rm file1 remove/delete file1
rm -i file1 remove/delete file1 but inquire for confirmation
cp file1 file2 copy file1 to file2
cp file1 dir1 copy file1 into directory dir1
mv file1 file2 move file1 to file2 (i.e., rename file1 to file2)
mv file1 dir1 move file1 into directory dir1
diff file1 file2 display lines which are different in file1 and file2
For more descriptive help on searching, sorting etc., go to
File Manipulation Utilities.
Managing Jobs
ctrl-c kill current job
ctrl-z suspend current job
bg run suspended job in background
fg bring suspended/background job to foreground
ps list processes by their process identifier (PID)
kill PID kill process with process identifier PID
jobs list your jobs by job number
On-line help
man command display manual entry for command
man -k keyword list manual pages that pertain to keyword
insight on-line help on SGI (X version)
learn on-line tutorial on IBM
System Information
who list users logged onto the system
whoami displays your logon ID (username)
df display number of free blcoks on disk
du display disk usage
Utility Programs
wc file1 displays the number of lines, words and characters
in file1
sort file1 sort contents of file, send results to
standard output
grep pattern file1 look for pattern in file1, send
results to standard output
tar file1 write to or retrieve file1 from an archival
storage medium (e.g., tape)
compress file1 compresses file1 and writes file1.Z
uncompress file1.Z restores file1 from compressed format
uniq file1 file2 delete duplicate lines in file1 and
write the new version of file1 into file2
find path -name \search the directory tree path
file -print /for file and display
echo string translate parameter string and display
Special Characters
* match any character (wild card)
& put job in background
! repeat previous command
; Concatenate several commands on one line
# start of a comment
#! first two characters of a shell script
I/O Redirection Commands (csh, tcsh)
< redirect standard input (get input from)
> redirect standard output (write output to)
>& redirect standard output and standard error
>! redirect standard output, overwrite file if it exists
>!& redirect standard output and error, overwrite file if it exists
| send output from first command to input of second command (pipe)
>> append standard output
>>& append standard output and error
Links to other D0 pages
Last update: Oct. 2, 1995
P. Bhat