Basic Unix commands


 
COMMAND COMMENTS
cat filename Copies the named file (or files) to the output.
cd Changes your working directory to be your login directory.
cd .. Change directories by moving up one level.
cd dir_name Changes directory to the directory named.
chmod u+rwx filename Changes the protection on a file. u = user (the file owner), +rwx = "on" for read, write, and execute.  Also can use - for "off", e.g., go-x means "off" for "group" and "other" (i.e., everyone else).
clear Clears the terminal screen.
cp filename1 filename2 Copies file filename1 to filename2.
date Displays date and time.
diff filename1 filename2 Compares file filename1 to filename2.
echo anything Simply write the arguments to the standard output.
emacs filename Edits the named file using the emacs editor.
exit Exit from the current shell.  (If this is your login shell, it will log you out.)
grep pattern filename Displays lines from the named file which match the pattern.
head filename Look at the start of the named file. Also head -20 for first 20 lines (etc.)
kill process_id Kill one of your processes.  If it doesn't work, use kill -9 process_id
less filename Displays file, one page at a time, with prompting.
lp filename Prints the named file.
ls Brief listing of your files (brief). 
ls -a Gives listing that includes files starting with a "dot".
ls -al Gives detailed listing of your files.
man command_name Find out more about the command specified.
mkdir dir_name Create (make) a subdirectory named dir_name.
mv filename1 filename2 Renames file fname1 to fname2 (also moves file, if directory path is included).
ps -x Show what processes you are running.
rm filename Deletes the specified file.
rmdir dir_name Removes (deletes) the specified subdirectory (which must be empty).
tail filename Look at the end of the named file. Also tail -20 for last 20 lines (etc.)
tin newsgroup Read a newsgroup.
vi filename Edit the named file using the vi editor. [Also see emacs (above).] Emergency exit: type ESCAPE then :q!

Other basic Unix things

All Unix processes have three i/o streams by default: The default assignment of the three streams can be changed when the process is run: When specifying filenames, some wildcards are permitted: Examples:
joe? matches joe0 and joex but not joe or joe37.
jane*.html matches jane.html or jane-b.html.
s[oui]n matches only son, sun or sin.
mark[0-9].txt matches mark3.txt but not mark37.txt or markb.txt.
~/*.{htm,html} matches anything in your home directory that ends with .htm or .html.