Appendix A: UNIX reference card

  1. File-related commands
  2. Directory-related commands
  3. Informational commands
  4. Compiling and running programs
  5. Printer commands
  6. Job-control commands

File-related commands

cat <file> Displays <file> on your terminal
chmod [-R] <permission-code> <file or directory> Finds common lines of two sorted files
cmp <filename1> <filename2> Compares two files
comp <filename1> <filename2> Finds common lines of two sorted files
compress [-c..] <filename> Compress a file using adaptive Lempel-Ziv coding (extension .Z), -c option sends compressed file to STDOUT
cp [-r..] <file1> <file2> Makes a copy of file1 in file2, -r option copies directories recursively
diff <filename1> <filename2> Finds the difference between two files or directories
find <pathname> <searchcriteria> <action(s)> Find files matching searchcriteria in pathname and act on them according toaction(s).
Example: > find ~/. -name "test.*" -print
finds all files named "test.*" in your home-dir or sub-dirs and prints the pathnames
grep [-ncv..] <pat> <files> Searches files for lines containing pat
gzip [-cd..] <file> Compresses file using Lempel-Ziv coding (LZ77), -c option sends compressed file to STDOUT. Use the command "gzip -d" or "gunzip" to unzip the file
head [-n..] <file> Displays a specified number of lines or bytes at the beginning of file, -n option specifies number of lines, + from beginning, - from end of file
ln [-s..] <file0> <file/dir> Make a file link to file0, -s option makes symbolic links
more <file> Displays the contents of file on your screen, pausing after each screenful with "more" prompt
mv <file1> <file2> Renames file1 as file2
rm <file> Removes (deletes) file
tail [-n..] <file> Displays a specified number of lines or bytes at the end of file, -n specifies number of lines, + from beginning, - from end of file
tar [-xctvzf..] <file(s)> Adds/extracts file(s) to/from a tar-archive (you often find tar/compressed files at Internet anonymous FTP sites)
touch <file> Update the last modified date of file
uncompress [-c..] <filename> Uncompress a compressed file (extension .Z), -c option sends compressed file to STDOUT

Directory-related commands

cd <dir> Changes the current working directory to dir
ls [-atldF] Lists the file names in the current directory
pwd Prints (displays) the current directory
mkdir <dir> Makes (creates) a new directory named dir
rmdir <dir> Removes (deletes) the directory named dir, provided dir is empty. (Use the "rm -r dir" command to remove a directory and all files in it

Informational commands

date Displays the current date and time of day
echo [any string of characters] Echos argument
finger <username> Consults the user database for information about the user account name
man [-k..] <cmd> Consults the on-line manual pages for command cmd
uptime Displays system up time and load averages
wc <file> Displays number of lines in a file
who Displays list of current users

Compiling and running programs

cc <program> Compiles a C program
c++ <program> Compiles a C++ program
f95 <program> Compiles a Fortran-95 program
a.out Runs the executable file a.out

Printer commands

ppr -P<printer> <file> Prints file on the printer named <printer>
ppq -P<printer> Displays the queue for the printer named <printer>
pprm -P<printer> <jobid> Removes a job from the queue for the printer named <printer>
script <file> Records your terminal session in <file>

Job-control commands

bg Force suspended job (Ctrl-z)to run in background (same as adding "&")
jobs Lists all your current jobs
kill [-9] <job/PID> Terminates a job or process. (Use the "-9" option to make the termination mandatory.)
ps [-aux..] List processes. (Use the "ps -ef" command to list all processes currently running on the system.)

 

Published June 24, 2011 2:25 PM