Basic UNIX Shell Commands |
This document describes many essential UNIX shell commands. Be aware that the default user shell in WMU's CS Dept. is the TC shell. The TC shell is slight variant of the C shell, but documentation for one usually works for the other. |
File & Process Management
Synopsis | Description |
cat file | Displays the contents of file. |
cd | Changes the working directory to the user's home directory. |
cd .. | Changes the working directory to the working directory's parent. |
cd dir | Changes the working directory to dir. |
clear | Clears the terminal. |
cp file dir | Copies file and places the copy in dir. |
cp file1 file2 | Copies file1 and names the copy file2. |
cp -r dir1 dir2 | Copies dir1 and all its contents, and places the copies in dir2. |
Ctrl-C | Kills the currently running process. |
less file | Displays the contents of file so the user can scroll back and forward through it. Type Q to quit. |
ls dir | Lists the contents of dir. If dir isn't given, uses the working directory. |
ls -l dir | Lists the contents of dir in long (detailed) form. |
ls -a dir | Lists the contents of dir including hidden files (files which begin with '.'). |
ls -al dir | A combination of "ls -a" and "ls -l" on dir. |
mkdir dir | Makes a new directory, dir, in the working directory. |
more file | Displays the contents of file by the screenful. Type Q to quit. |
mv file dir | Moves file into dir. |
mv file1 file2 | Renames file1 as file2. |
mv dir1 dir2 | Moves dir1 into dir2. |
pwd | Displays the full path to the working directory. |
rm file | Removes (deletes) file. |
rm -f file | Removes file. User is not asked to confirm deletion. |
rm -r dir | Deletes the directory, dir, and all its contents. |
rm -fr dir | A combination of "rm -f" and "rm -r" on dir. |
Other Commonly Used Commands
Synopsis | Description |
lpq | Shows the print queue for the local lineprinter. |
lpr file | Prints file on the local lineprinter |
quota -v | Displays the current users quota status. |
script | Starts a script. Everything that appears in the terminal get put in the script. The file that the script is stored in is named "typescript". Enter "exit" to end the script. |
script file | Like script, only instead of the script file being named "typescript", it's named file. |
tar cvf name.tar files... | Creates an archive named name.tar that contains all the files listed. For each of files that is a directory, that directory and all its contents will be included in the archive. |
tar xvf name.tar | Extracts the contents of the archive name.tar into the working directory. |
tar czvf name.tar.gz files... | Creates a compressed archive named name.tar.gz that contains all the files listed. For each of files that is a directory, that directory and all its contents will be included in the archive. |
tar xzvf name.tar.gz | Extracts the contents of the compressed archive name.tar.gz into the working directory. |
Text Editors
Synopsis | Description |
pico file | Opens file in the simple command-line text editor, Pico. |
emacs file | Opens file in the more advanced command-line text editor, Emacs. It's best to find documentation before trying this one. |
vi file | Opens file in the more advanced command-line text editor, Vi. It's best to find documentation before trying this one. |
xemacs file & | Opens file in the GUI text editor, XEmacs. The "&" prevents XEmacs from locking up the terminal while it runs. |
Communication
Synopsis | Description |
netscape & | Runs Netscape the GUI Web browser. The "&" prevents Netscape from locking up the terminal while it runs.. |
telnet host | Starts a telnet remote command-line login session with host. In WMU's CS Dept., the hosts are named "csxNN.cs.wmich.edu" where the NN can be 01-25. Enter "exit" to quit telnet. |
ftp host | Starts an ftp (File Transfer Protocol) session with host. In WMU's CS Dept., the hosts are named "csxNN.cs.wmich.edu" where the NN can be 01-25. Enter "?" to get a list of ftp commands. Enter "bye" to quit ftp. |
ssh host | Starts a secure remote shell session with host. In WMU's CS Dept., the hosts are named "csxNN.cs.wmich.edu" where the NN can be 01-25. Enter "exit" to quit ssh. |