Useful commands
Introduction
Unix has become very large and it is often quite difficult to find a command to do what you want to do. This guide lists some useful/popular commands, grouped by category, that are available on the School's system with a short explanation of each. Obviously, to get more information you should use the man command.
Processes
| ps | The ps program gives you information about active processes. Without arguments it lists processes started by you from the same terminal as ps was launched. To list all of your processes type ps -u username. To list all processes running on the machine type ps -a. |
| top | This gives you a list about the top CPU processes sorted in order of raw CPU usage. While running top you can use the following commands.
|
Text Processing
| awk | Awk is a very sophisticated
program for pattern matching and processing text files. Awk scans
through each line of a file and if the pattern matches then the associated
program is run. As a simple example consider a payroll file which
has on each line the name of the employee, their rate of pay, and the number
of hours they worked. e.g.
If that data was in a file called payroll
and we ran the following command
|
| sort | Sort takes a file, or the standard input, and sorts the lines into alphabetical order. Sort also has a few useful options.
|
| wc | This program performs a word count on the given file or standard input. By default it will display lines, words, and characters. |
| fold | Reformats a text file so that a maximum line length is not exceeded. E.g. fold -w 10 myfile would output myfile in lines of 10 characters. |
Files
| diff | Diff compares two files. In its most basic form diff will compare two files line by line and report any differences. e.g. diff file1 file2. If you want the comparison to be case insensitive then use diff -i file1 file2. Using diff -w will ignore any white space in the file. |
| file | The file command attempts to determine what the type of a file is. E.g. typing file this.ps (where this.ps is a Postscript file will produce) this.ps: PostScript document. |
| split | The split utility splits a file into pieces. It has the following options
|
| head, tail | These programs print the first or last ten lines of a file. |
Miscellaneous Utilities
| cal | The cal program displays a calendar for the given month or year. For example type cal 09 2000 for a September 2000 calendar or cal 2000 for the whole year. Remember to use 4 digit year numbers. |
| script | The script program logs all activity (input, output and error) that appears in a terminal. This is very useful if you want to log your interaction with a program into a file. |
| time | This programs times how long another program takes to run. |
| at | Lets you run a command at a later date/time. See man page for examples. |
Postscript
| psnup | Shrink Postscript pages to fit on a single physical page. |
| psselect | Allows you to extract specific pages from a Postscript document. |
| psbook | Changes the order of Postscript pages so that they can be printed as a book. |
| html2ps | Convert HTML pages to Postscript. Use the -D option to generate more compatible Postscript |
| ps2ascii | Extracts the ASCII text from a Postscript file. |
Graphics
| Netpbm | Netpbm is a large collection of graphics utilities. Use man pages for further info. |
| gifdiff | Compares two gif images to see if they look similar. |
| gif2tiff | Converts GIF images to tiff format. |