
University Computing Services
A brief guide
to using UNIX on UCS computers at Florida State University.
If you need additional
help, contact the Technology ServicesHelpdesk.
Commands
Some of the commands
available under Unix are listed below. For additional information, see
the on-line manual pages.
| Directory Commands
|
|
| cd path
| Changes directory to path
|
| pwd
| Shows current directory
|
| ls path
| Lists contents of directory path
|
| mkdir path
| Creates directory path
|
| rmdir path
| Removes directory path
|
| File Commands
|
|
| cp file newfile
| Copies file to newfile
|
| mv file newfile
| Renames file
|
| mv file directory
| Moves file into directory
|
| rm file
| Removes file
|
| ln file1 file2
| Adds a link to file1
|
| cat files
| Types files to screen
|
| more file
| Types file, a page at a time
|
| head file
| Types top lines of file
|
| tail file
| Types bottom lines of file
|
| sort file
| Sorts file
|
| find
| Finds files
|
| grep pattern file
| Searches file for pattern
|
| chmod
| Changes file access permissions
|
| umask
| Sets default file access permissions
|
| rcp
| Copies files between Unix hosts
|
| ftp
| Copies files between Internet hosts
|
| tar
| Archives files
|
| compress
| Compresses file
|
| uncompress
| Uncompresses file
|
| pack
| Compresses file
|
| unpack
| Uncompresses packed file
|
| pico
| Invokes pico screen editor
|
| ed
| Invokes ed line editor
|
| vi
| Invokes vi screen editor
|
| emacs
| Invokes emacs screen editor
|
| sed
| Invokes stream editor
|
| awk
| Scans and processes patterns
|
| file file
| Shows the type of file
|
| diff file1 file2
| Compares file1 and file2
for differences
|
| du
| Displays user's disk usage and availability
|
| df
| Displays disk space information
|
| Other Commands
|
|
| exit
| Logs out
|
| passwd
| Changes password
|
| groups user
| Shows the groups user belongs to
|
| man command
| Types on-line manual pages for command
|
| who
| Shows logged in users
|
| finger
| Shows logged in users
|
| date
| Prints day of week, date, time
|
| elm
| Read or send electronic mail messages with elm
|
Some points to
remember about Unix commands:
- Unix is case
sensitive: upper- case characters are distinct from lowercase characters
in commands and file names. Unix command names must be entered in
lower case.
- Unix command
names cannot be abbreviated.
- A Unix command
can be continued to another line if the last character in the line
(the character immediately preceding the carriage return) is a backslash
(\).
- Several commands
can be submitted on the same command line, separated by semicolons
(;).
- Many non-alphabetic
characters have special meanings to shells. A summary is provided
below.
- The Korn shell,
Bourne shell, and C shell all provide means to create new names for
commands or sequences of commands.
A number of characters
have special meanings when they are included in commands issued to a
shell:
| Special Characters in Shell Commands
|
| $
| Indicates variable substitution
|
| *
| Matches any string in a file name
|
| ?
| Matches any single character in a file name
|
| []
| Matches any of the enclosed characters in a file name
|
| \
| Turns off the meaning of the immediately following
special character
|
| '
| Enclosing single quotes turn off the special meanings
of all characters
|
| "
| Enclosing double quotes turn off the special meanings
of all characters except $ and backquote
|
| `
| Enclosing backquotes (grave accent) around a command
name supply output from the command as an argument to another command
|
| &
| Executes preceding command in background mode
|
| ;
| Separates multiple commands on one line
|
| <
| Redirects the contents of a file into a command as
standard input
|
| >
| Redirects the standard output of a command into a file
|
| >>
| Appends the output of a command to the end of a file
|
| |
| Output of one command becomes input of another command
(pipe)
|
| ()
| Groups commands in subshell
|
| {}
| Groups commands in current shell
|
| ||
| Executes the second command only if the first fails
|
| &&
| Executes the second command only if the first succeeds
|
| ~
| User's home directory (C shell and Korn shell)
|
| :
| Extracts part of path variable (C shell only)
|
| !
| History recall (C shell only)
|
Examples of the
use of many of these characters appear in this manual. The chapter is
shown in brackets ({}).
In Unix, the input
that a command usually accepts from a terminal keyboard is called "standard
input" (stdin), and
the output that it normally sends to the user's screen is called "standard
output" (stdout).
"Standard error" (stderr) is
error information normally directed to the terminal screen. Unix allows
the user to redirect standard input, output, and error information to
files.
Redirecting
Standard Input, Output, and Error
The "redirect input"
symbol (<) instructs the Unix shell to take a program's standard
input from a file instead of the terminal. The usage is
% command [options] [arguments] < infile
where command
is the name of the utility and infile
is the file to be read. If the file does not exist, the command
will produce an error.
The "redirect output"
symbol (>) instructs the shell to write a program's output to a file
instead of the terminal. The usage is
% command [options] [arguments] > outfile
If the outfile
already exists, the
shell will destroy its original contents.
Output from a command
can be appended to a file rather than overwriting it by using the "append
output" symbol (>>). The command line
% command [options] [arguments] >>
outfile
appends the output
of command to the file outfile.
This example creates
a listing of the files in /usr/ucb in
the file ucb.list, then
displays the file:
% ls -al /usr/ucb > ucb.list
% cat ucb.list
total 2277
drwxr-xr-x 2 uservice root 1312 Feb 7 08:25 .
drwxr-xr-x 22 uservice root 736 Jan 24 14:00 ..
-rwsr-sr-x 1 uservice sys 166912 Feb 7 08:25 chsh
-rwxr-xr-x 1 bin bin 121512 Oct 25 10:18 clear
-rwxr-xr-x 1 bin bin 151144 Oct 25 10:18 ctags
-rwxr-xr-x 1 bin bin 180760 Oct 25 10:18 diff
Under the C shell, standard error output can be redirected separately from
standard error output by typing the command in the form
% (command > outfile) >& errfile
The Bourne shell and Korn shell allow the user to redirect standard error
information to a file and separate it from standard output by typing the
command in the form
$ command > outfile 2> errfile
Pipes
Standard output from one utility can be provided as standard input to
another utility by using a pipe (|). The usage is
% command1 | command2
where the output from command1 is used as input for
command2. This example first requests the list of users logged
in to the system, then requests it again and pipes it through the sort
utility to provide an alphabetical listing:
$ who
operator console Oct 11 07:45
ciosl ttyp001 Oct 12 14:03 (scri1.scri.fsu.edu)
jaya ttyp003 Oct 13 07:37 (vsserv.scri.fsu.edu)
holder ttyp005 Oct 13 10:59 (croc.cc.fsu.edu)
pjens ttyp007 Oct 11 08:42 (systems.cc.fsu.edu)
$ who|sort
ciosl ttyp001 Oct 12 14:03 (scri1.scri.fsu.edu)
holder ttyp005 Oct 13 10:59 (ssgcc.cc.fsu.edu)
jaya ttyp003 Oct 13 07:37 (vsserv.scri.fsu.edu)
operator console Oct 11 07:45
pjens ttyp007 Oct 11 08:42 (systems.cc.fsu.edu)