Basic UNIX/Linux Commands

Here are some of the most common unix commands to get you started. When you see [FILE], type a file name there instead. If you start a filename with /, you have to specify the complete path to the file, e.g. /home/.../myfile. If the first character of the name is not /, a search will be conducted from the directory you are currently in.

to list most files in CURRENT DIRETORY        ls
to go to another directory                    cd [directory]
to go to your home directory                  cd ~
to view content of a file                     less [FILE]
to logout                                     exit

FILE COMMANDS

list files              ls, ls -al
list contents of        more [FILE] (q to quit), cat [FILE]
edit/create new         emacs [FILE] (ctrl-c ctrl-x to exit),
                        vi [FILE] (:wq or ZZ to exit)
copy                    cp [old] [new]
move/rename             mv [old] [new]
delete                  rm [FILE]
print                   lpr -P[printer_name] [FILE] 
                         (no space in between the P and the printer name)

DIRECTORIES

return to home             cd
show current directory     pwd
change directory           cd [directory] 
                           (cd .. to back up one)
make new directory         mkdir [dir name]
delete directory           rmdir [directory]

Other File Commands

space used                      quota
show print jobs                 lpq -P[printer name]
set access privileges on file   chmod [#] [FILE]  
                                (#: 700 protects, 777 unprotects)
count file lines, words, chars  wc [FILE]
search for word in file         grep [word] [FILE]
compare 2 files                 cmp [file1] [file2]
show file type                  file [FILE]
find a file                     find [FILE]
give first few lines of a file  head [FILE]
append file                     cat [file1] [file2] > [new_file]

Other Miscelanneous Commands

mail                           pine or mail
getting started hints          help
online command help            man [command]
who you are                    whoami
who else is logged in          who, finger, users, w
show time / date               date
what commands do               whatis [command], apropos [command]
generate a calendar            cal [month] [year]
clear screen                   clear
echo text to screen            echo [text]
change password                passwd
give a command a nicname       alias [nicname] [command]
logout                         exit
/pre>


Other Useful Stuff

Ctrl-C will kill a running program

[command] > [FILE]   redirects output of a command from the screen to a 
  file - example:  finger > myfile

[command] < [FILE]   redirects input to a command from the keyboard to a 
  file - example:  prog1 < mydata

[command] >> [FILE]  appends output of a command to a file - example: 
  date >> datefile

[command1] | [command2]  feeds the output from the first command as 
  input to the second - example: ls -al | more

-[option] can be used immediately after most commands - example: ls -l

Adapted from a document written by C. Covington and R. Wooley.