Some Useful UNIX Commands

What follows are some excerpts from the manual pages; for complete descriptions, use man command

Square brackets [ ... ] denote optional arguments to the command.


cd [ directory ]
directory becomes the new working directory. The process must have execute (search) permission in directory. If cd is used without arguments, it returns you to your login directory.

cp file1 file2
cp copies the contents of filename1 onto filename2. The mode and owner of filename2 are preserved if it already existed; the mode of the source file is used otherwise. If filename1 is a symbolic link, or a duplicate hard link, the contents of the file that the link refers to are copied; links are not preserved.

diff [ options ] filename1 filename2
diff is a differential file comparator. When run on regular files, and when comparing text files that differ during directory comparison (see the notes below on comparing directories), diff tells what lines must be changed in the files to bring them into agreement. Except in rare circumstances, diff finds a smallest sufficient set of differences. If neither filename1 nor filename2 is a directory, either may be given as `-', in which case the standard input is used. If filename1 is a directory, a file in that directory whose filename is the same as the filename of filename2 is used (and vice versa).

du [ -s ] [ -a ] [ filename ... ]
du gives the number of kilobytes contained in all files and, recursively, directories within each specified directory or file filename. If filename is missing, `.' (the current directory) is used.

elm
Elm is an interactive screen-oriented mailer program that supersedes mail and mailx.

emacs [ filename ]
MicroEMACS is a tool for creating and changing documents, programs, and other text files. It is both relatively easy for the novice to use, but also very powerful in the hands of an expert. MicroEMACS can be extensively customized for the needs of the individual user.

finger [ options ] [ name ]
By default, finger displays information about each logged-in user, including his or her: login name, full name, terminal name (prepended with a `*' if write-permission is denied), idle time, login time, and location (comment field in /etc/ttytab for users logged in locally, hostname for users logged in remotely) if known.

ftp [ host ]
ftp is the user interface to the ARPANET standard File Transfer Protocol (FTP). ftp transfers files to and from a remote network site.

handout
Handout allows access to a handout in the category of your choice. Handout provides a menu of current handouts and interactively allows viewing, copying, and printing of handouts in the specified categories.

lpq [ -Pprinter ]
lpq displays the contents of a printer queue. It reports the status of jobs specified by job#, or all jobs owned by the user specified by username. lpq reports on all jobs in the default printer queue when invoked with no arguments.

lpr [ -Pprinter ] filename
lpr creates a printer job in a spooling area for subsequent printing as facilities become available. Each printer job consists of a control file and one or more data files. The data files are copies of (or, with -s , symbolic links to) each filename you specify. The spool area is managed by the line printer daemon, lpd. Jobs that specify a printer on a remote machine are forwarded by lpd.

lprm [ -Pprinter ] [ - ] [ job# ] [ username ]
lprm removes a job or jobs from a printer's spooling queue. Since the spool directory is protected from users, using lprm is normally the only method by which a user can remove a job.

ls [ options ] [ name ]
For each filename which is a directory, ls lists the contents of the directory; for each filename which is a file, ls repeats its name and any other information requested. By default, the output is sorted alphabetically. When no argument is given, the current directory is listed. When several arguments are given, the arguments are first sorted appropriately, but file arguments are processed before directories and their contents.

mail [ options ] [ recipient ]
mail is a comfortable, flexible, interactive program for composing, sending and receiving electronic messages. While reading messages, mail provides you with commands to browse, display, save, delete, and respond to messages. While sending mail, mail allows editing and reviewing of messages being composed, and the inclusion of text from files or other messages.

man [ options ] name
man displays information from the reference manuals. It can display complete manual pages that you select by title, or one-line summaries selected either by keyword (-k), or by the name of an associated file (-f).

mkdir directory
mkdir creates directories. Standard entries, `.', for the directory itself, and `..' for its parent, are made automatically.

more file
more is a filter that displays the contents of a text file on the terminal, one screenful at a time. It normally pauses after each screenful, and prints --More-- at the bottom of the screen. more provides a two-line overlap between screens for continuity. If more is reading from a file rather than a pipe, the percentage of characters displayed so far is also shown.

mv file1 file2
mv moves files and directories around in the file system. A side effect of mv is to rename a file or directory.

paper [ user ]
Paper displays paper usage information stored in the default paper quota file /usr/adm/pquota. Each user has an entry in the paper quota file on the home site of the user.

passwd
passwd changes (or installs) a password, login shell (-s option), or full name (-f option) associated with the user username (your own by default). chsh is equivalent to passwd with the -s option, and chfn is equivalent to passwd with the -f option.

ps [ options ]
ps displays information about processes. Normally, only those processes that are running with your effective user ID and are attached to a controlling terminal (see termio(4)) are shown. Additional categories of processes can be added to the display using various options. In particular, the -a option allows you to include processes that are not owned by you (that do not have your user ID), and the -x option allows you to include processes without control terminals. When you specify both -a and -x, you get processes owned by anyone, with or without a control terminal. The -r option restricts the list of processes printed to "running" processes: runnable processes, those in page wait, or those in short-term non-interruptible waits.

quota [ -v ] [ username ]
quota displays users' disk usage and limits. Only the super-user may use the optional username argument to view the limits of users other than himself.

rm file
rm removes (directory entries for) one or more files. If an entry was the last link to the file, the contents of that file are lost. See ln(1V) for more information about multiple links to files.

rmdir directory
rmdir removes each named directory. rmdir only removes empty directories.

sort [ options ] filename
The sort program sorts and collates lines contained in the named files, and writes the result onto the standard output. If no filename argument is given, or if `-' appears as an argument, sort accepts input from the standard input.

telnet [ host [ port ] ]
telnet communicates with another host using the TELNET protocol. If telnet is invoked without arguments, it enters command mode, indicated by its prompt (telnet>). In this mode, it accepts and executes the commands listed below. If it is invoked with arguments, it performs an open command (see below) with those arguments.

vi [ options ] [ filename ]
vi (visual) is a display oriented text editor based on ex. ex and vi are, in fact, the same text editor; it is possible to get to the command mode of ex from within vi and vice-versa.

who
Used without arguments, who lists the login name, terminal name, and login time for each current user. who gets this information from the /etc/utmp file.

Updated: 6/27/95

Peter Blomgren.

PIC60 index page         Send mail to Peter         close