Linux/Unix Command Quick Reference

Tips

  1. To execute a program, simply invoke the executable's name.
  2. To execute code in your current directory, you may need to change your path as follows: "setenv PATH ${PATH}:." This adds the current directory (the file systems calls this ".") to the list of directories searched for executables.
  3. Sharing files between nodes   This system uses a utility called the `automounter' to automatically mount file systems across the network. This is invoked by prefacing the path with /hosts/hostname where 'hostname' is replaced with the desired machine name. For example, if you wanted to view a file on machine A in my home account called 'graphcap', you might say: more /hosts/a/home/weinberg/graphcap.



The following list should be enough to get you started . . .


 
Command Action
cc (or gcc)  compile (and link) C source
cc mycode.c  compile and link C source
cc mycode.c -lm   compile and link C source with the math library
cc -c mycode.c -lm   compile link C source only (no executable, will make object file: mycode.o)
cc -o myexe mycode.c -lm   compile and link C source, call execuable myexe
g++, arguments as with cc  compile C++ source, arguments as with cc
g77  compile F77 source
gdb  the GNU debugger (for cc, g++, and g77 generated code)
ddd  nice graphical user interface to gdb
vi standard unix editor
emacs good program editor; invoke "emacs" and type "control-h t" to get a tutorial
man [command]  give me help on the named command
info  read on-line manuals
ls  list files in the current directory
ls -l list files in current directory displaying size, protection, owner, date, etc.
ls -a list all files, including hidden files
ls -la list all files, including hidden files displaying size, protection, owner, date, etc.
cd [path] change directory to the specified path
cp [file1] [file2] copy file1 to a new file file2
mv [file1] [file2] Move file1 to a new file, file2. If the directory specified for file2 is the same as file1 the effect is to rename file1 to file2.
rm [file] remove (delete) the specified file from the disk (this operation is permanent).
rmdir [directory] removes the specified directory from the disk (this operation is permanent)
who or w show the users currently logged in to the system
finger [user[@system]] shows information about a user, a system, or a specific user on a specific system
passwd change your password
chmod change the protection of a file or directory
cat [file1] [file2] concatenate file1 to file2. If file2 is omitted, stdout is assumed. The effect is to print the contents of file1 file on the screen
lpr line printer; use this to print files
more displays output 1 screen at a time. Example: "more myfile"
ssh [host] use secure shell to log into host
ssh [host] [command] use secure shell to log into host and execute a remote command
scp file host: use secure shell to copy a file to a remote host
scp file user@host: use secure shell to copy a file to to a user at a remote host
exit or logout log out of the system

  M. D. Weinberg on June 22, 1999