The following is a list of common UNIX commands. There may be some differences between shells. Many commands take further parameters and options not listed here.
ls
Lists the files in the current directory or another directory. Examples:
ls list files in current directory
ls –a list files in the current directory plus hidden files
ls tempdir list files in the directory temp
cd
Changes directories. Example:
cd tempdir changes to the directory temp
cd .. changes to the parent directory above the current one
cd returns to your home directory
mkdir or md
Creates a new directory. Example:
md tempdir creates a new directory named temp
rmdir or rd
Removes (deletes) a directory. The directory must be empty. Example:
rd tempdir deletes the directory temp
rm
Removes (deletes) a file. Example:
rm tempfile deletes the file tempfile
cp
Copies a file to another file or to a directory. The file name can include path information. Examples:
cp tempfile1 tempfile2
cp tempfile tempdir
mv
Renames as well as moves files and directories. Examples:
mv tempfile1 tempfile2 renames the file tempfile1 to tempfile2
mv tempfile1 tempdir moves the file tempfile to the directory tempdir
mv tempdir1 tempdir2 renames the directory tempdir1 to tempdir2
more
Display a file to the screen one screen’s worth at a time; use the spacebar for another screen’s worth or q to quit. Example:
more tempfile displays the file tempfile to the screen
pwd
Stands for present working directory; displays the full path and name of the current
directory
grep
Searches for words or patterns in files.
The general format is:
grep <search string> <file(s)>
This is a case sensitive command. Examples:
grep hello myfile Searches for and finds both hello and Hello in the file myfile
grep –i hello myfile Searches for and finds hello but not Hello in the file myfile
man
Stands for manual and is the utility that returns information about using a command. Example:
man cd returns information about using the command cd.