To bottom

Basic Unix Commands

Unix commands are abbreviations and sometimes cryptic. They can be two, three, or four letters long. For example, rm, cp, and lpr are frequently used. In addition, there may be options, called switches, parameters, and redirection symbols. You must separate the command and its options with spaces. Think of the command as a verb and the options as objects. Unlike MS Windows, lower case letters are not the same as upper case letters. Most commands and options are given in lower-case letters.

Not all commands need switches. Switches usually begin with a minus sign, but a plus sign may be used to turn on an option. Of course, a space separates the switch from the command. Parameters, which are usually file names, follow the switches if they are present or the command itself if not. Again, a space is needed before the parameter. If there are several file names, they are placed one after the other (and separated by spaces). If a group of file names has common letters, you can specify to the entire group with one name that contains the * and ? wild cards. For example, the parameter *plt refers to all files that end in the three letters plt. You can also use square brackets to select particular characters. For example, the option beam[1-3,56] (with no spaces) chooses beam1, beam2, beam3, beam5, and beam6.

The output redirection symbol, >, sends information destined for the video screen to a file instead. Similarly, the input redirection symbol, <, gets information that you normally type from the keyboard from a disk file instead. For example, the line:

 ansys  < infile.a  > outfile
runs the ansys program and feeds it the information from the disk file named infile.a and puts the program output into the file named outfile. The command:
  cat  file1  file2  > file3
combines the two files file1 and file2 and puts the result into a new file named file3. You can find out more about a command with the man (for manual) command. For example, the command man cp tells about the cp command. The following Unix commands are frequently needed.

cd  matlab         change to the subdirectory named matlab
cd                 change to the home directory
cp  file1  file2   make a copy of file1 called file2
cp dir2/file1 .    copy file1 from directory dir2 into current directory
diff file1 file2   show differences between files
echo $param        show idefinition of param
env                show values of environment variables
history            show previous commands by number
lpr -Pserver f1    print file f1 on server (notice capital P)
    -Zduplex         two-sided printing
    -#10             print 10 copies
lpq -Pworkman54    look at printer queue for sage
ls  *dwg           list names of all files ending in the letters dwg
man  cp            learn more about cp command (manual)
mkdir dir          make a new directory called dir
more file1         look at file1 page by page (usually aliased to just m)
mv file1 file2     move or rename file1 to file2
passwd             change password
pwd                show current directory name
quota              your file size
rm  *bak           remove all files ending in the letters bak
abbr=orig          define abbreviation (usually shorter)
tail -15  file1    look at last 15 lines of file1
You can rerun previous commands and make changes with emacs commands:
^P      redisplay previous command (then use commands to change it)
^Rls    repeat most recent command that begins with ls
!5  repeat command 5 (use history or h to find the command number)
!^  first option of previous command
!$  last option of previous command
!*  all options of previous command
!:2 second option of previous command
Before erasing files, check that the parameters are correct. For example, first give:
    ls  fname*      # list corresponding files
    rm  !$          # erase those files
To copy files from my class directory, define a short symbol a, then check that it is correct before using it.
    a=~es421/class        #  define shorter symbol a
    echo  $a              #  check definition
    copy  $a/files  .     #  copy files (don't forget the dot)

Also see: TCC Unix help, alias and function definitions

PC Version To top

MENG 421 | ARMiller home | Ansys | FEA Sites | Assignments

Last revised: January 6, 2004