Information on basic UNIX commands


The most important UNIX commands needed in this course are:

pwd ................ prints the name of the current working directory.

cd ................. changes the directory; when given without any arguments, the shell
                     moves to the users home directory. In order to change to a specific directory, 
                     the full pathname must be given e.g. cd /usr/local/bin changes 
                     to the directory /usr/local/bin. Moving up one directory can be done more 
                     easily by using cd ..

du ................. calculates the size of the current directory. If used with the -k modifier, 
                     the directory size is given in units of 1K. On some systems this is the default, 
                     on others the size is still given in units of 512-byte blocks. On most systems 
                     the -h modifier is also supported giving the sizes of the mounted volumes in 
                     "human readable" units such as MB, GB, or TB.

mkdir name ......... creates directory name as a subdirectory of the current working directory.

rmdir name ......... removes directory name. This only works if there are no files left in
                     directory name. 

df ................. shows all volumes mounted on the system together with the current usage. 
                     If used with the -k modifier, the usage information is given in units of 1K. 
                     On some systems this is the default, on others the size is given in 
                     units of 512-byte blocks. On most systems the -h modifier is also supported
                     giving the sizes of the mounted volumes in "human readable" units such as 
                     MB, GB, or TB.

ls ................. list all files as well as subdirectories of a directory in alphabetical order
                     using the -l modifier gives a more informative listing, one file per line. 
                     The command can be combined with search strings in order to produce partial 
                     listings. For example ls test*.com will list all files starting with the 
                     string test and ending on .com.
              
cp file1 file2 ..... copies file1 to file2.

mv file1 file2 ..... changes the name of file1 to file2.

rm file1 ........... removes file file1. This only works if file file1 is owned by the user or
                     if the user has write permission for this file. One helpful variant is rm -i
                     which prompts the user to confirm deletion of a file. 

more file1 ......... displays the content of file1 page by page. This only makes sense for 
                     text files, of course, and also works for output files that are too large 
                     to be loaded into an text editor.

grep string1 file2   search for string1 in file file2. The command grep "B3LYP" test*.log 
                     will search for string B3LYP in all files starting with test and ending with .log 
                     Please observe that UNIX is case sensitive (e.g. "B3LYP" is different from "b3lyp"). 
                     In case the search string occurs repeatedly in one file, all occurences are listed. 
                     This can be used efficiently to follow the progress of, for example, geometry 
                     optimizations by searching for a string that reappears in the output file for each 
                     optimization cycle. The strings "SCF" or "RMS     Force" (observe the blanks!) will, 
                     for example, be helpful in many optimizations done with Gaussian 98. For searching 
                     binary files, use grep -a.

tail file1 ......... shows the last few lines of file file1. tail -50 file1 gives the 
                     last 50 lines of file1. Output files of calculations that are currently running
                     can most easily be followed by tail -f file1,  file1 being the name of the 
                     output file.

gzip file1 ......... compress file1 using the gzip program. Upon compression a new (compressed) 
                     file file1.gz will be generated. Decompression is possible using either 
                     gunzip file1.gz or gzip -d file1.gz.

compress file1 ..... compress file1 using the standard UNIX compression command. Upon 
                     compression a new (compressed) file file1.Z will be generated.  Decompression 
                     of the latter is possible with the uncompress file1.Z command.

ps ................. shows processes running on the system. Use of the -f or -l modifiers produces 
                     a longer listing containing more information. Use of the -e modifier gives 
                     information on processes of all users. Unfortunately, the exact format and 
                     meaning of the modifiers depends substantially on the particular UNIX version used. 
                     Using Red Hat LINUX 7.x,  ps -ef will give all the required information.

ssh host1 .......... connects to host1 for an interactive session. This command is preferred over
                     the older, insecure telnet command. 

sftp host1 ......... connects to host1 for a file transfer session.
                     This commmand is preferred over the older, insecure ftp commmand.

logout or exit ..... terminate a shell (window).

passwd ............. change your password.

who ................ shows who is logged into the local system.


Several UNIX commands can effectively be combined through the pipe symbol |. The command ps -ef | grep "g03" for example will show you how many processes connected to Gaussian (short: g03) are currently running on your system.

Information on UNIX commands can also be obtained using the standard UNIX manual pages. In order to get information on, for example, the mkdir command, simply type man mkdir.

A short list of the most important UNIX commands can also be found here.
A quick reference card (ps format) can be found on the KFA Juelich web page.
last changes: 16.10.2006, HZ
questions & comments to: zipse@cup.uni-muenchen.de