Pro UNIX Commands

|  – Pipe symbol – send the output of one process into another process. For example, the “ls -l” command prints out all of the files in the current directory, along with information about those files, and the “more” command displays only one screenful of information at a time. If there are a lot of files in the current directory, you might want to try “ls -l | more”, which makes “ls -l” send all of it”s output to “more” which then displays it one screenful at a time. Another useful one is “ps -ef | grep USERNAME”, replacing USERNAME with the user you”re looking for: it will only show the lines with that user in them.
> filename
Redirect output to a file. This symbol will send the output of a command to the specified file. For example, “ls -l > names.dat” will put the names and permissions of all the files in the local directory into a file named “names.dat”. If you don”t want to see any output from a command, you can send the output to “/dev/null” ( “ls -l > /dev/null” would send the names to “/dev/null”, though it doesn”t really serve a purpose in this example ).

< filename
Redirect input from a file. This symbol will take everything in the file and send it to a process as if it came from the standard input ( usually the keyboard ). For example, the “spell” program reads from standard input and prints out the words that it thinks are misspelled. So, you can type “spell”, then type in the words that you want to check followed by -D ( the end of file mark ), and spell will print out the misspelled words. If you wanted to check all of the words in a file, you”d redirect the standard input to come from the file “spell < filename”, and spell would read the file instead of the keyboard.

&
Make a process run in the background automatically. The process must not need input from the keyboard or output to the screen. Say the process is “cat file1 file2 > file3” and the that file1 and file2 are large. This could take a while before it finishes. To make it run in the background ( which will allow you to continue to work while it is running ), the easiest thing to do would be to use the “&”, like so: “cat file1 file2 > file3 &”.

%#
Part of the process control available under the csh shell. “%#” ( where “#” is replaces with a job number ) will re-enter a suspended process. If you use “jobs” to find the processes that you have suspended or are running in the background, what you get back might look like the following:
[1] 21998 Suspended emacs useful.tex
[2] – 22804 Suspended (signal) elm
[3] + 22808 Suspended badb
Where the first number ( in brackets ) is the job number, and typing “%1” at the command line would cause you to re-enter the emacs job.

-c
Part of the process control available under the csh shell. -C sends a termination signal to current process. This usually kills the current process.

-z
Part of the process control available under the csh shell. -Z sends a terminal stop signal to the current process. This allows you to temporarily exit a running process, and re-enter it with “fg”. The “jobs” command will show you what processes you have done this to. If the process doesn”t require input from the keyboard or output to stdout ( usually the screen ), then after using “-Z” you can make the process run in the background with “bg”.

Dvi {-Pprintername}filename.dvi
Dvi prints out “filename.dvi” files, which are produced by the TeX and LaTeX text processing programs. More information on TeX and LaTeX can be found in the printed manuals, available for borrowing at the EMBA computer facility. “-Pprintername” tells Dvi which printer to print out on. This parameter isn”t necessary if you”ve set your “PRINTER” environment variable (do this with the “setenv” command ).

Vroff filename
Vroff is an X-windows previewer for documents that use the nroff/troff text processing commands. For more information, look in the document formatting portion of the printed manuals in room 252 – the “Nroff/Troff User”s manual” and the “Troff Tutorial” are both worth looking at.

Xroff {-Pprintername}filename
Xroff prints out documents that use the nroff /troff text processing commands. For more information, look in the document formatting portion of the printed manuals in Votey room 252 – the “Nroff/Troff User”s manual” and the “Troff Tutorial” are both worth looking at. “-Pprintername” specifies which printer to send the print job to ( i.e. -Pembalaz ). This parameter isn”t necessary if you”ve set your “PRINTER” environment variable ( do this with the “setenv” command ).

awk
Pattern scanning and processing language. Very useful for making text filters. “awk” can run it”s own script files ( “awk -f scriptfile inputfile” would run the script file on the input file ), or it can accept quick scripts on the command line – “awk “length < 80″ filename” prints to stdout ( usually the screen ) all of the lines in the file “filename” that are shorter than 80 characters.

badb
BADB ( Business ADministration Database ) is used to access the Stock Exchange information supplied on the CRSP and Compustat tapes. Type “badb” at the command line, and choose the data base that you wish to enter. It is interactive, and there is on-line help.

bg
Background a stopped job. If you start a process that doesn”t require input from the keyboard or output to the screen, then you can make it run in the background. Say the process is “cat file1 file2 > file3” and the that file1 and file2 are large. This could take a while before it finishes. If you start the process, and then realize that you want to make it run in the background ( which will allow you to continue to work while it is running ), type “-Z” and then “bg”. The process is now backgrounded. You can see the status of the job with “jobs” or “ps”.

bitmap {filename}
X-windows bitmap viewer/editor. Bitmaps can be used for X-window icons and backgrounds. (best if run from SGI machine, and SUN server (Newton, Griffin, Sadye, ect …)
cedit
X-windows color viewer. Shows what color a particular decimal value of RGB looks like. Runs from SGI machines.
compress {filename}
Reduces the size of the named file using adaptive Lempel-Ziv coding. Whenever possible, each file is replaced by one with the extension “.Z”, while keeping the same ownership modes. If “filename” isn”t specified, compress will compress its standard input.

djns
Dow Jones News Retrieval Service. This service can give you up-to-the-minute news, current and historical stock quotes, the MCI Mail service, Official Airline Guide flight and fare information, as well as detailed corporate and industry data. Also available in this unique service are a wide variety of general interest databases, including sports and weather reports, a computerized shopping service, movie reviews, a lexicon of investment terminology and an encyclopedia.

etags
Creates a tags file for use with emacs and epoch. A tags file gives the location of functions and type definitions in a group of files. Emacs and epoch use entries in the tags file to locate and display a definition. To go to a function definition in emacs, type “M-.” ( Meta period ). This will ask you the name of the function that you wish to find. Type it in and press return. If what you typed in is found at the beginning of a number of functions, you might not get the correct one on the first try. If this is the case, keep typing “M-,” ( Meta comma ) until you reach the one that you want.

fg {%jobnumber}
Run a currently backgrounded process in the foreground. If you use “jobs” to find the processes that you have suspended or running in the background, what you get back might look like the following:
[1] 21998 Suspended emacs useful.tex
[2] – 22804 Suspended (signal) elm
[3] + 22808 Suspended badb
Simply typing “fg” at the command line will put you back in the process that has the “+” in the 2nd column, in this case it would be the “badb” process. “fg %2” will put you back in the “elm” process.

gr_top
Graphically displays processes ordered by %CPU usage.
grep {string}{-e expression}{filename(s)}
Along with egrep and fgrep, grep is used to search files for a string or a regular expression. If no “filename” is given, grep searches it”s standard input for the the string or expression. When grep finds the requested string or expression, it prints out the line that contains it along with the filename of the file that the line is from. Example: “grep chance *” will search all of the files in the current directory for the word “chance”.

gtar
GNU project”s version of “tar”. gtar”s command line parameters are similar to those of tar. gtar has the added advantage of not trying to keep the original file ownership of files being extracted. All files are changed to belong to the person doing the extraction. To create an archive, you might type “gtar cvf archname file1 file2 file3”, which would put file1-3 in the archive named archname. “c” of “cvf archname” in the command line means create the named archive, “v” means verbose – print names of the files and the operation performed on them, and the “f archname” gives the name of the archive that you want to do the operations on. “gtar tvf archname” will print out the names of all of the files in the archive, “gtar xvf archname” will extract all of the files from archname, and “gtar xvf archname filename” will extract only “filename” from the archive, provided that it is in the archive in the first place.

interleaf
A WYSIWYG ( What You See Is What You Get ) editor and desktop files organizer available on the Sun machines. For more information look in the printed manual pages.
kill -9 {PID}{%job-number}
Terminates a process with the process id of PID or the specified job number. See “jobs” and “ps” for information on how to find PID”s or job numbers. So, if the PID is 12345, then “kill -9 12345” will kill the job. If the job number is 5, then “kill -9 %5” will kill it.

latex filename.tex
LaTeX is a text processing language ( a superset of the TeX language ), and “latex” compiles this language into a device independent (dvi) representation of the resulting document. “latex” will report errors and, if there are none, give you a file named “filename.dvi”. This file can be previewed with “xdvi”, and may be printed out with “Dvi”. More information on the LaTeX language is available in the LaTeX manual which you can borrow from an EMBA counselor.

nroff {filename}
“nroff” and “troff” are text processing languages. The “nroff” program is an ASCII previewer for nroff/troff files, showing what the file will look like when it is printed ( prints to stdout – usually the screen ). This can be handy for looking at nroff/troff files that you are writing “nroff filename | more”, or for looking at the manual pages that come along with software that you get from the Internet “nroff -man filename | more”. “Vroff” is a graphical previewer of nroff/troff files that will show different fonts and point sizes ( which the nroff program won”t ).

nice {command}
Runs a {command} with low priority so others dont experience “lagg-time”.

popd
Removes the top directory from the directory stack, placing you into the new top directory. Use pushd to place new directories on the stack. If the stack consists of the following ( leftmost is the top of the stack ): “/usr / /usr/local/bin”, then you will be in the “/usr” directory, and typing popd will make the stack look like this: “/ /usr/local/bin”, putting you in the root directory ( / ).

pushd {directory}
Pushes “directory” on to the directory stack, placing you into that directory. If “directory” isn”t specified, pushd swaps the two top directories on the stack, placing you into whichever directory is now on the top of the stack. Use popd to remove stack entries. If the directory stack looks like this ( use “dirs” to print out the current directory stack, and the leftmost directory is top of stack): “/ /bin”, and you type “pushd /usr/local/bin”, then the new stack looks like this: “/usr/local/bin / /bin”, and you will be in the /usr/local/bin directory. If you then type “pushd”, the stack will look like this: “/ /usr/local/bin /bin” and you will be in the root directory. Finally if you type “pushd +2” the stack will look like this: “/bin / /usr/local/bin”, and you will be in the /bin directory.

sed {-e script}{-f scriptfile}{filename}
Stream editor. Useful for making text filters. “sed” can take its instructions from a file ( -f scriptfile ) or the command line ( -e script ). For example “sed -e “s/test/testing/g” filename” will replace every instance of the word “test” with the word “testing” and print the result to stdout ( usually the screen ).
sort {options}{filename}
Sorts the input lines alphabetically by default, numerically if given the “-n” command line option. Without a “filename”, sort works on the standard input. Otherwise it sorts the lines in the file and writes the sorted output to stdout ( usually the screen ).

tar
Creates tape archives, plus adds to, and extracts files from tape archives. Sometimes has permission problems when extracting files by maintaining the ownership of the files in the archive. If you have this problem, try “gtar”. To create an archive, you might type “tar cvf archname file1 file2 file3”, which would put file1-3 in the archive named archname. “c” of “cvf archname” in the command line means create the named archive, “v” means verbose – print names of the files and the operation performed on them, and the “f archname” gives the name of the archive that you want to do the operations on. “tar tvf archname” will print out the names of all of the files in the archive, “tar xvf archname” will extract all of the files from archname, and “tar xvf archname filename” will extract only “filename” from the archive, provided that it is in the archive in the first place.

uncompress filename.Z
Uncompresses files that have been compressed with the “compress” command (which automatically adds the “.Z” to the end of the filename).

uudecode filename
Decodes files that have been encoded with the “uuencode” command. “uuencode” changes binary files into ascii files so that they can be easily e-mailed or posted to the news.

uuencode {source-file}file-label
Converts a binary file into an ASCII-encoded representation that can be sent using mail(1) or posted to a news-group. If you don”t specify “source-file”, then uuencode takes its input from standard-input. “uuencode” sends the encoded output to stdout ( usually the screen ). When decoded using “uudecode” the resulting file will be named “file-label”.

wp51
WordPerfect 5.1. Available on Sun”s. For the ASCII version, you must first unset your “DISPLAY” environment variable ( “unsetenv DISPLAY” ), then type “wp51”. For the X-windows version of wp51 you must first set your “DISPLAY” environment variable ( “setenv DISPLAY dname:0”, where dname is the name of the display that you are using ), and then you must tell it where to find the appropriate fonts by typing “xset fp+ /usr/local/lib/X11/fonts/wp” on the console of the machine that you are working on, then simply type “wp51” at the command line in one of your Sun windows ( griffin, newton, sadye ).

xarchie
X-window interface for Archie servers. Archie servers provide information about files available for ftp anywhere on the Internet. ( i.e., it helps you figure out where you can ftp a particular file from ). Say you want to find out where you can ftp the gdb debugger from – you”d type “gdb” in for the “Search Term:”, and then press return. Xarchie will then connect to one of the archie servers ( which one can be controlled though the “settings” menu ), and look for any file that it know about that contains the string “gdb”. It will report the ftp servers, the directory, and the file found on your screen. You can then use ftp to get the file if you want it.

Advertisements

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.