ITS Document Rack
|

UNIX Pocket Reference List


CCRL-20

Last revised: April, 1999


Contents

In this Document
Connecting and Logging In
The Shell's Prompt for Commands
Logging Out
Changing Your Passwords
Correcting Typing Errors
Special Characters
Setting Your Terminal Type
Getting Online Help
Files and Directories
Creating and Editing Files
Displaying a File at Your Terminal
Printing a File
Deleting a File
Setting a Search Path
Killing a Detached or Runaway Job
Running Programs
Summary of Useful Commands

UNIX is the operating system on the ITS CCWF system (accounting code HPW), the UNIX Timesharing System (UTS), and the Academic Data Server (ADS). Each computer system uses a different version of UNIX: CCWF uses Solaris, UTS uses Digital UNIX, and ADS uses AIX.

This reference list gives a quick overview of common UNIX features and commands. The most current and complete information for any command is its online "man" page--see "Getting Online Help" below for more information. ACITS also publishes an inexpensive manual, Introduction to UNIX (CCUG-1), which can be purchased at the Help Desk in the Varsity Center (VRC). The manual can also be viewed or searched online, using a Web browser, at

http://www.utexas.edu/cc/docs/ccug1/

In this Document . . .

  • Command words and arguments in bold typeface are shown exactly as you type them. Note that most are in lowercase. They must be typed that way: UNIX treats uppercase letters as different from their lowercase counterparts. For items shown in italics, substitute an appropriate value.
  • Type the punctuation shown, such as a hyphen or vertical bar.
  • Control characters, typed by holding down the CTRL key while typing the character, are shown by the notation ^x, where x is the character.
  • You must finish all UNIX commands by pressing the RETURN key, which is not shown here.

Connecting and Logging In

Connecting from Another Computer

If you are using another computer on the campus network (UTnet) or on the Internet, and if that computer has a telnet command, you can use it to connect to a UNIX host. If the other computer is also running UNIX, you can connect using rlogin. If your computer offers ssh, the Secure SHell, you can also connect using ssh or slogin.

Connecting through Telesys

You must have a modem and a computer, and your user number must be validated to use the Telesys dial-up system.

If you use SLIP or PPP software provided in the UT Connect package, it will make the Telesys connection, and you can use telnet to connect to a UNIX host.

Logging In

For your first login, your login name is the user number issued to you by ACITS, in lowercase. When the UNIX system prompts you for a password, give the password originally issued for your user number, also in lowercase.

For your first login, a special program will prompt you for a new UNIX password, possibly for a new UNIX login name, and for other initialization information. Then it will log you out. The login name you choose must be unique: it cannot be used by anyone else on the system. It will also be part of your e-mail address, so you should choose something appropriate.

Make up a password that is six or more characters long, mixing uppercase, lowercase, and numbers to make it difficult for others to guess. This password is the only thing that keeps someone else from using your account and having full access to your work.

The program may ask you to choose a login shell, which is a UNIX command interpreter. The C shell (/bin/csh) is recommended. For this document, the C shell is assumed to be the command interpreter-unless otherwise stated. The program will also prompt you for optional data to put into a database that other users on the Internet can view. This includes such items as your name, office address, and phone number. Press RETURN to leave any item blank.

To add or change data in a later session, use the command:

chfn

Exceptions: For the UTS system, you must run chfn on the machine named curly.cc.utexas.edu. For the ADS and CCWF systems, send your request to

http://www.utexas.edu/cc/help/remark/

The Shell's Prompt for Commands

After you log in, you will see a prompt from the shell. The C shell's prompt usually includes the host machine's name. When you see the shell prompt, such as ccwf.cc.utexas.edu%, you can issue UNIX commands.

Logging Out

IMPORTANT: Don't just turn off the terminal or workstation or disconnect the phone, and do not abandon a terminal or workstation that seems "locked up". When you are through with your UNIX session, log out by typing:

logout or ^d

If you see a new UNIX login prompt, press ^d again. If you see a new Telesys> prompt, type:

exit

If you can't get a response at all and are unable to log out, see "Killing a Detached or Runaway Job" in this document.

Changing Your Password

To change your password, type the command:

passwd

You will be prompted for your old password, then for your new one (twice for confirmation). If the two new passwords match, the change will take effect in about one hour. If they do not match or are otherwise unacceptable, you will be prompted to try again. Neither the old nor new password will display on the screen. Changing your password on UTS, which must be done on the machine named curly.cc.utexas.edu, does not affect your password for Telesys, CCWF, ADS, UMBS, or any other system.

Correcting Typing Errors

To correct an error before you press the RETURN key:

  • Press either the DELETE or BACKSPACE key to back up over a character, depending on the system.
  • Press ^w to back up over a word.
  • Type ^u to erase the entire line.

Special Characters

^c
Interrupts and aborts execution of the current process, which cannot be restarted.

^z
Suspends a process (temporarily stops it by putting it in the "background") so that you can give other UNIX commands. To resume the process, use fg (foreground) or %n, where n is the background job number. To disable ^z (make it undefined), give the command:

stty susp u

<
Reads from the file named to the right of this symbol instead of from standard input. Thus:

Mail jsmith < note

mails the contents of file "note" to user jsmith instead of prompting for text from your terminal ("standard input").

>
Writes to the file named to the right of this symbol instead of to standard output. Thus:

cat myfile

displays contents of "myfile" at your terminal (standard output), but:

cat myfile > listout

copies it to file "listout" instead, overwriting and destroying any previous contents of the file "listout". (In the C shell, a prior set noclobber command prevents such destruction.)

>>
Appends output to the file named to the right of this symbol. Thus:

cat nextfile >> listout

appends a copy of "nextfile" to file "listout" instead of overwriting what is already in "listout".

|
Creates a "pipe" so that output from one program (on left) becomes input to the next one (on right). Thus:

ls | lpr -Pcom_lw

sends output from the ls (listing) program to the lpr (printing) program.

*
Matches zero or more characters in a filename. For example, A* matches A, AbC, ARGUE, African, etc.

?
Matches any single character in a filename. For example, A?C matches AAC, ABC, ACC, etc.

\
Prevents the following character from being interpreted as special. For example, \* makes * an ordinary character.

The shell performs filename matching and input/output redirection before calling any program that uses the files.

Setting Your Terminal Type

Some programs must know what type of terminal you are using in order to process control characters correctly. To identify your terminal to the C shell, give the command:

setenv TERM type

where type is the terminal type, such as vt100. Your terminal type should already be defined by initialization files set up for you when you first used a particular ACITS UNIX system.

Getting Online Help

Online UNIX documentation consists of "man" (manual), pages that you can display or print by using the man program. For example, to display the man page for the rm (remove) program, type:

man rm

For information on the man program itself, type:

man man

The program pauses after displaying each screenful of text. Press the space bar to continue, or press q to quit.

To print a man page, "pipe" the output of the man program to the ul program (for underline and boldface removal, which some printers can't do) then pipe that output to the lpr program--like this:

man rm | ul-Tdumb | lpr -Pacwl_lw

This prints the rm man page on the laser printer at the Student Microcomputer Facility. If you don't know which man page you need, type:

apropos keyword

to get a list of man pages that contain keyword in their title lines.

On the ADS system, get additional online help by using the InfoExplorer program. Type info -h to get started.

Longer documents and frequently asked questions can be searched and displayed by using your Web browser to connect to:

http://www.utexas.edu/cc/unix/

Files and Directories

A UNIX filename or directory name can contain up to 255 letters, digits, and punctuation characters (best limited to period and underscore). To list names of files in your own directory, type:

ls

This will not list filenames that begin with a period, unless you include the -a (all) option, like this:

ls -a

Names of initialization files typically begin with a period. For example, the C shell executes commands in .login each time you log in, and those in .cshrc each time you start up the C shell. The initialization file for the Bourne shell or the Korn shell is .profile.

Other ls options include:

-l
long form, gives file protections, size in bytes.

-F
marks directory names with a slash, executable files with an asterisk.

To list a subset of your files, use special characters. For example, to list all filenames beginning with A, use:

ls A*

For complete information about the ls command, see:

man ls

Creating and Editing Files

To create and alter files on a UNIX system, use a text editor. The most common one is the vi editor. Its use is described in Introduction to UNIX, CCUG-1. The pico editor is very easy to use, with an on-screen menu of commands and built-in help.

Emacs is another popular editor. A summary of Emacs commands is in GNU Emacs Pocket Reference List, CCRL-34, available free at the Help Desk.

NOTE: To use most editors, your terminal type will need to be defined. A definition of vt100 works in most cases.

Displaying a File at Your Terminal

Use the cat (catenate) or more command to display files at your terminal. For example:

cat source1 source2

displays "source1" and "source2" in that order.

more testfile

displays "testfile", pausing after each screenful. Press the space bar to see each new screen.

Printing a File

To send files to a printer, use lpr. For example:

lpr -Pfacsmf_lw source1 source2

prints files "source1" and "source2" on a laser printer at the Student Microcomputer Facility (SMF) in the Flawn Academic Center (FAC). For information about options, output devices, and locations, see:

man lpr and http://www.utexas.edu/cc/unix/print-service/

On ADS, use InfoExplorer. To learn how, type

info -h

Deleting a File

Use rm (remove) to delete files from your directory. For example:

rm trashfile

The -i (interactive) option to rm causes the system to request confirmation of each file deletion. This option may prevent accidental deletions and is useful if you are removing several files, as in:

rm -i *file

To delete a file that starts with a hyphen, use

rm - file

Setting a Search Path

Your command search path is the sequence of directories the shell searches to find commands you issue. For the C shell, to add a directory to the search path, use set path. For example:

set path=($path /usr/lang) ; rehash

adds /usr/lang to your current search path, $path. But this works only for the current login session. If you want your path set as above for EVERY login session, put the set path command in your .login file.

Killing a Detached or Runaway Job

If your terminal gets disconnected from your job or if it "locks up", you can kill the detached processes this way:

  1. Log in again to the same machine (if need be, from another terminal) and type: tty (tells which terminal line you are now using) ps -u username(username is your own username. This lists all your running processes)
  2. For lines that have "csh" in the COMMAND column and that have a terminal line in the TT column different from your current terminal, look in the PID column for the process id number of that C shell.
  3. Send that C shell's process id (pid) a hangup signal:

    kill -HUP pid

  4. Repeat the ps -u username command to make sure all unwanted processes are gone. If not, reissue the kill command like this:

    kill -9 pid

Running Programs

To compile a Fortran program using the UNIX FORTRAN-77 compiler, f77, type:

f77 file

where file is the name of the source file. On ADS, you can also use xlf or xlf90. If the source filename ends in .f it is taken to be a FORTRAN-77 program.

To compile a Pascal program, type:

pc file

where file is the name of the Pascal source file, which normally has .p as its final two characters. Exception: on ADS systems, use

xlp file

To compile a C program, type:

cc file

where file is the name of the C source file, normally having .c as its last two characters. On ADS systems, you can also use xlc.

To compile a C++ program with the GNU C++ compiler, type

g++ file

All of these compilers compile and load object code into executable files named a.out. To execute your program, simply type:

a.out

If you get the message "a.out: Command not found", check to be sure that your command search path is set correctly. Or you may be able to solve the problem by using the command:

./a.out

to specify your current working directory. To write object code to some file other than a.out, use the -o compiler option, like this:

cc -o output

where output is the name of your executable file. To compile only, use the -c option. In this case, the compiled program is written to a file with the same name as the source file but with the final .f, .p, or .c replaced by .o; no loading or linking takes place.

NOTE: Programs compiled on one machine architecture will not run on another. For example, an a.out file compiled on the CCWF system will not execute on UTS. To debug your C, Pascal, FORTRAN, and assembly language programs, compile them with the -g option, then use an interactive debugging program. For information on available debugging programs, type:

apropos debug

For other compiler options, see the man pages for f77, PC, and cc. On UNIX systems running AIX, see the man pages for xlf, xlc, and xlp.

To print a listing of your program, type:

lpr -Psite -p sourcefile

To include line numbers, use:

cat -n sourcefile | lpr -Psite -p

Summary of Useful Commands

The following commands are grouped alphabetically by function. Unless noted otherwise, each has a man page describing it in full. Commands marked "C shell only" are described in the csh man page (except on ADS systems, where you should use InfoExplorer for information).

Access Control

exit - terminate a shell (see "man sh" or "man csh")
logout - sign off; end session (C shell and bash shell only; no man page)
passwd - change login password
rlogin - log in remotely to another UNIX system
slogin - secure version of rlogin

Communications

from - list senders of mail
Mail - send and receive mail
mesg - permit or deny terminal messages and talk requests
pine - send and receive mail (easiest for new users)
talk - talk to another logged-in user (full screen)
write - write to another logged-in user

Programming Tools

ar - archive and library maintainer
as - assembler, specific to each machine architecture
awk - pattern scanning and processing language
CC - C++ compiler (cxx on UTS; xlC on ADS)
cc - C compiler (xlc on ADS)
crontab - maintain periodic tasks
csh - C shell command interpreter
dbx - source-level debugging program
f77 - FORTRAN compiler (xlf on ADS)
g++ - GNU C++ compiler
gcc - GNU C compiler gdb - GNU Project debugger
gprof - display profile of called routines
kill - kill a process
ld - the UNIX loader
lex - generate lexical analysis programs
lint - check C source code
make - manage multipart program projects
maple - symbolic mathematics program
nice - run a command at low priority (see "man nice" or "man csh")
nohup - run a command immune to hangups
PC - Pascal compiler (xlp on ADS)
perl - Popular script interpreter
prof - display profile data
ranlib - convert archives to random libraries
sh - Bourne shell command interpreter
/bin/time - time a command
yacc - generate input parsing programs

Documentation

apropos - locate commands by keyword lookup
/usr/bin/X11/dxbook - start the BookReader program (UTS only)
info - start the InfoExplorer program (ADS only)
man - find manual information about commands
whatis - describe what a command is
whereis - locate source, binary, or man page for a program

Editors

emacs - screen-oriented text editor
ex - line-oriented text editor
pico - simple, screen-oriented text editor (easiest for new users)
sed - stream-oriented text editor
vi - full-screen text editor
vim - full-screen text editor ("vi-improved")

File and Directory Management

cd - change working directory
chmod - change the protection of a file or directory
chquota - change disk quota on ACITS UNIX systems
cmp - compare two files
comm - select/reject lines common to two sorted files
compress - compress a file
cp - copy files
crypt - encrypt/decrypt files (not on ADS)
diff - compare the contents of two ASCII files
file - determine file type
grep - search a file for a pattern
ln - make a link to a file
ls - list the contents of a directory
mkdir - create a directory
mv - move or rename files and directories
pwd - show the full pathname of your working directory
quota - display disk usage and limits
rm - delete (remove) files
rmdir - delete (remove) directories
sort - sort or merge files
tee - copy input to standard output and other files
tr - translate characters
umask - change default file protections
uncompress - restore compressed file
uniq - report (or delete) repeated lines in a file
wc - count lines, words, and characters in a file

File Display and Printing

cat - show the contents of a file; catenate files
fold - fold long lines to fit output device head - show first few lines of a file
lpq - examine the printer spooling queue
lpr - print a file
lprm - remove jobs from the printer spooling queue
more - display a file, one screen at a time
page - like "more", but prints screens top to bottom
pr - paginate a file for printing
tail - show the last part of a file
zcat - display a compressed file

File Transfer

ftp - transfer files between network hosts
rcp - transfer files between networked UNIX hosts
scp - secure version of rcp
rz - receive files using ZMODEM protocol
sz - send files using ZMODEM protocol

Miscellaneous

alias - define synonym commands
chsh - change default login shell
clear - clear terminal screen
echo - echo arguments
learn - request computer-aided instruction (not on CCWF)
pbm - portable bitmap manipulation programs
popd - pop the directory stack (C shell only)
pushd - push directory on stack (C shell only)
script - make typescript of terminal session
setenv - set an environment variable (C shell only)
stty - set terminal options

News/Networks

lynx - text-only Web browser for display terminals
netscape - Web browser
netstat - show network status (on UTS, /usr/sbin/netstat)
Pnews - submit USENET news articles
rlogin - login remotely on another UNIX system
slogin - secure version of rlogin
tin - read/post USENET news articles
trn - read/post USENET news articles
rsh - run shell or command on another UNIX system
ssh - secure-shell version of rsh
telnet - run Telnet to log in to remote host

Process Control

(The following commands function under the C shell, bash, and ksh. They do not have separate man pages.)

bg - put suspended process into background
fg - bring process into foreground
jobs - list processes
^y - suspend process at next input request
^z - suspend current process

Status Information

spend - lists year-to-date ACITS UNIX charges
date - show date and time
df - summarize free disk space
du - summarize disk space used
env - display current environment or run programs under modified environment
finger - look up user information
history - list previously issued commands (C shell, bash, and ksh only)
last - indicate last login of users
lpq - examine spool queue
manpath - show search path for man pages
printenv - display environment
Ps - show process status
pwd - display full pathname of working directory
set - set shell variables (C shell, bash, and ksh only)
stty - set terminal options
uptime - show system load, how long system has been up
w - show who is on system, what command each job is executing
who - show who is logged onto the system
whois - Internet user name directory service

Text Processing

checknr - check nroff/troff files
col - filter reverse line feeds
dvips - convert TeX DVI files into PostScript
eqn - typeset mathematics with troff
ispell - check spelling interactively
macref - make cross-reference listing of nroff/troff macro files
neqn - format mathematics with nroff
nroff - format text for simple display
pic - make simple pictures for troff input
psdit - filter troff output for Postscript printer
spell - find spelling errors
tbl - format tables for nroff/troff
troff - format text


Information Technology Services. Infrastructure. Innovation. Integrity.

Last updated May 2, 2002.
Copyright © 1994-2012, Information Technology Services at The University of Texas at Austin.
All rights reserved. For privacy concerns read our privacy policy.

To submit questions or comments regarding this page, use the online Comment Form.