J^T: John Thywissen's personal pages

POSIX Shell Commands

A POSIX shell command is one of the following:

  1. simple command: a special built-in utility or a regular utility
  2. pipeline: [!] command | command ...
  3. list: commands separated by new-line ; & && ||
  4. compound command: commands inside () {} for case if while until
  5. function definition: fname() linebreak compound_command

Special Built-In Utilities

break - exit from for, while, or until loop
break [n]

colon - null utility
: [argument...]

continue - continue for, while, or until loop
continue [n]

dot - execute commands in current environment
. file

eval - construct command by concatenating arguments
eval [argument...]

exec - execute commands and open, close, or copy file descriptors
exec [command [argument...]]

exit - cause the shell to exit
exit [n]

export - set export attribute for variables
export name[=word]...
export -p

readonly - set read-only attribute for variables
readonly name[=word]...
readonly -p

return - return from a function
return [n]

set - set or unset options and positional parameters
set [-abCefmnuvx] [-h] [-o option] [argument...]
set [+abCefmnuvx] [+h] [+o option] [argument...]
set -- [argument...]
set -o
set +o

shift - shift positional parameters
shift [n]

times - write process times

trap - trap signals
trap [action condition...]

unset - unset values and attributes of variables and functions
unset [-fv] name...

Regular Utilities (non-development)

alias - define or display aliases
alias [alias-name[=string]...]

ar - create and maintain library archives
ar -d [-v] archive file...
ar -m [-abiv] [posname] archive file...
ar -p [-v] [-s] archive [file...]
ar -q [-cv] archive file...
ar -r [-cuv] [-abi] [posname] archive file...
ar -t [-v] [-s] archive [file...]
ar -x [-v] [-sCT] archive [file...]

asa - interpret carriage-control characters (FORTRAN)
asa [file...]

at - execute commands at a later time
at [-m] [-f file] [-q queuename] -t time_arg
at [-m] [-f file] [-q queuename] timespec...
at -r at_job_id...
at -l -q queuename
at -l [at_job_id...]

awk - pattern scanning and processing language
awk [-F ERE] [-v assignment]... program [argument...]
awk [-F ERE] -f progfile... [-v assignment]... [argument...]

basename - return non-directory portion of a pathname
basename string [suffix]

batch - schedule commands to be executed in a batch queue

bc - arbitrary-precision arithmetic language
bc [-l] [file...]

bg - run jobs in the background
bg [job_id...]

c99 - compile standard C programs
c99 [-c] [-D name[=value]]... [-E] [-g] [-I directory]... [-L directory]... [-o outfile] [-Ooptlevel] [-s] [-U name]... operand...

cal - print a calendar
cal [[month] year]

cat - concatenate and print files
cat [-u] [file...]

cd - change the working directory
cd [-L] [-P] [directory]
cd -

chgrp - change the file group ownership
chgrp -hR group file...
chgrp -R [-H|-L|-P] group file...

chmod - change the file modes
chmod [-R] mode file...

chown - change the file ownership
chown -hR owner[:group] file...
chown -R [-H|-L|-P] owner[:group] file...

cksum - write file checksums and sizes
cksum [file...]

cmp - compare two files
cmp [-l|-s] file1 file2

comm - select or reject lines common to two files
comm [-123] file1 file2

command - execute a simple command
command [-p] command_name [argument...]
command [-v|-V] command_name

compress - compress data
compress [-fv] [-b bits] [file...]
compress [-cfv] [-b bits] [file]

cp - copy files
cp [-fip] source_file target_file
cp [-fip] source_file... target
cp -R [-H|-L|-P] [-fip] source_file... target

crontab - schedule periodic background work
crontab [file]
crontab [-e|-l|-r]

csplit - split files based on context
csplit [-ks] [-f prefix] [-n number] file arg...

cut - cut out selected fields of each line of a file
cut -b list [-n] [file...]
cut -c list [file...]
cut -f list [-d delim] [-s] [file...]

date - write the date and time
date [-u] [+format]
date [-u] mmddhhmm[[cc]yy]

dd - convert and copy a file
dd [operand...]

df - report free disk space
df [-k] [-P|-t] [file...]

diff - compare two files
diff [-c|-e|-f|-C n] [-br] file1 file2

dirname - return the directory portion of pathname
dirname string

du - estimate file space usage
du [-a|-s] [-kx] [-H|-L] [file...]

echo - write arguments to standard output
echo [string...]

ed - edit text
ed [-p string] [-s] [file]

env - set the environment for command invocation
env [-i] [name=value]... [utility [argument...]]

ex - text editor
ex [-rR] [-l] [-s|-v] [-c command] [-t tagstring] [-w size] [file...]

expand - convert tabs to spaces
expand [-t tablist] [file...]

expr - evaluate arguments as an expression
expr operand

false - return false value

fc - process the command history list
fc [-r] [-e editor] [first [last]]
fc -l [-nr] [first [last]]
fc -s [old=new] [first]

fg - run jobs in the foreground
fg [job_id]

file - determine file type
file [-dhi] [-M file] [-m file] file...

find - find files
find [-H|-L] path... [operand_expression...]

fold - filter for folding lines
fold [-bs] [-w width] [file...]

fuser - list process IDs of all processes that have one or more files open
fuser [-cfu] file...

gencat - generate a formatted message catalog
gencat catfile msgfile...

getconf - get configuration values
getconf [-v specification] system_var
getconf [-v specification] path_var pathname

getopts - parse utility options
getopts optstring name [arg...]

grep - search a file for a pattern
grep [-E|-F] [-c|-l|-q] [-insvx] -e pattern_list... [-f pattern_file]... [file...]
grep [-E|-F] [-c|-l|-q] [-insvx] [-e pattern_list]... -f pattern_file... [file...]
grep [-E|-F] [-c|-l|-q] [-insvx] pattern_list [file...]

hash - remember or report utility locations
hash [utility...]
hash -r

head - copy the first part of files
head [-n number] [file...]

iconv - codeset conversion
iconv [-cs] -f fromcode -t tocode [file...]
iconv -l

id - return user identity
id [user]
id -G [-n] [user]
id -g [-nr] [user]
id -u [-nr] [user]

ipcrm - remove an XSI message queue, semaphore set, or shared memory segment identifier
ipcrm [-q msgid|-Q msgkey|-s semid|-S semkey|-m shmid|-M shmkey]...

ipcs - report XSI interprocess communication facilities status
ipcs [-qms] [-a|-bcopt]

jobs - display status of jobs in the current session
jobs [-l|-p] [job_id...]

join - relational database operator
join [-a file_number|-v file_number] [-e string] [-o list] [-t char] [-1 field] [-2 field] file1 file2

kill - terminate or signal processes
kill -s signal_name pid...
kill -l [exit_status]
kill [-signal_name] pid...
kill [-signal_number] pid...

link - call link( ) function
link file1 file2

ln - link files
ln [-fs] source_file target_file
ln [-fs] source_file... target_dir

locale - get locale-specific information
locale [-a|-m]
locale [-ck] name...

localedef - define locale environment
localedef [-c] [-f charmap] [-i sourcefile] [-u code_set_name] name

logger - log messages
logger string...

logname - return the user's login name

lp - send files to a printer
lp [-c] [-d dest] [-n copies] [-msw] [-o option]... [-t title] [file...]

ls - list directory contents
ls [-CFRacdilqrtu1] [-H|-L] [-fgmnopsx] [file...]

mailx - process messages
mailx [-s subject] address...
mailx -e
mailx [-HiNn] [-F] [-u user]
mailx -f [-HiNn] [-F] [file]

man - display system documentation
man [-k] name...

mesg - permit or deny messages
mesg [y|n]

mkdir - make directories
mkdir [-p] [-m mode] dir...

mkfifo - make FIFO special files
mkfifo [-m mode] file...

more - display files on a page-by-page basis
more [-ceisu] [-n number] [-p command] [-t tagstring] [file...]

mv - move files
mv [-fi] source_file target_file
mv [-fi] source_file... target_file

newgrp - change to a new group
newgrp [-l] [group]

nice - invoke a utility with an altered nice value
nice [-n increment] utility [argument...]

nl - line numbering filter
nl [-p] [-b type] [-d delim] [-f type] [-h type] [-i incr] [-l num] [-n format] [-s sep] [-v startnum] [-w width] [file]

nohup - invoke a utility immune to hangups
nohup utility [argument...]

od - dump files in various formats
od [-v] [-A address_base] [-j skip] [-N count] [-t type_string]... [file...]
od [-bcdosx] [file] [[+]offset[.][b]]

paste - merge corresponding or subsequent lines of files
paste [-s] [-d list] file...

patch - apply changes to files
patch [-blNR] [-c|-e|-n] [-d dir] [-D define] [-i patchfile] [-o outfile] [-p num] [-r rejectfile] [file]

pathchk - check pathnames
pathchk [-p] pathname...

pax - portable archive interchange
pax [-cdnv] [-H|-L] [-f archive] [-s replstr]... [pattern...]
pax -r [-cdiknuv] [-H|-L] [-f archive] [-o options]... [-p string]... [-s replstr]... [pattern...]
pax -w [-dituvX] [-H|-L] [-b blocksize] [[-a] [-f archive] [-o options]... [-s replstr]... [-x format] [file...]
pax -r -w [-diklntuvX] [-H|-L] [-p string]... [-s replstr]... [file...] directory

pr - print files
pr [+page] [-column] [-adFmrt] [-e[char][gap]] [-h header] [-i[char][gap]] [-l lines] [-n[char][width]] [-o offset] [-s[char]] [-w width] [-fp] [file...]

printf - write formatted output
printf format [argument...]

ps - report process status
ps [-aA] [-defl] [-G grouplist] [-o format]... [-p proclist] [-t termlist] [-U userlist] [-g grouplist] [-n namelist] [-u userlist]

pwd - return working directory name
pwd [-L|-P]

read - read a line from standard input
read [-r] var...

renice - set nice values of running processes
renice [-g|-p|-u] -n increment ID...

rm - remove directory entries
rm [-fiRr] file...

rmdir - remove directories
rmdir [-p] dir...

sed - stream editor
sed [-n] script [file...]
sed [-n] [-e script]... [-f script_file]... [file...]

sh - shell, the standard command language interpreter
sh [-abCefhimnuvx] [-o option] [+abCefhimnuvx] [+o option] [command_file [argument...]]
sh -c [-abCefhimnuvx] [-o option] [+abCefhimnuvx] [+o option] command_string [command_name [argument...]]
sh -s [-abCefhimnuvx] [-o option] [+abCefhimnuvx] [+o option] [argument]

sleep - suspend execution for an interval
sleep time

sort - sort, merge, or sequence check text files
sort [-m] [-o output] [-bdfinru] [-t char] [-k keydef]... [file...]
sort -c [-bdfinru] [-t char] [-k keydef] [file]

split - split files into pieces
split [-l line_count] [-a suffix_length] [file[name]]
split -b n[k|m] [-a suffix_length] [file[name]]

strings - find printable strings in files
strings [-a] [-t format] [-n number] [file...]

stty - set the options for a terminal
stty [-a|-g]
stty operands

tabs - set terminal tabs
tabs [-n|-a|-a2|-c|-c2|-c3|-f|-p|-s|-u] [-T type]
tabs [-T type] n[[sep[+]n]...]

tail - copy the last part of a file
tail [-f] [-c number|-n number] [file]

talk - talk to another user
talk address [terminal]

tee - duplicate standard input
tee [-ai] [file...]

test - evaluate expression
test [expression]
[ [expression] ]

time - time a simple command
time [-p] utility [argument...]

touch - change file access and modification times
touch [-acm] [-r ref_file|-t time] file...

tput - change terminal characteristics
tput [-T type] operand...

tr - translate characters
tr [-c|-C] [-s] string1 string2
tr -s [-c|-C] string1
tr -d [-c|-C] string1
tr -ds [-c|-C] string1 string2

true - return true value

tsort - topological sort
tsort [file]

tty - return user's terminal name

type - write a description of command type
type name...

ulimit - set or report file size limit
ulimit [-f] [blocks]

umask - get or set the file mode creation mask
umask [-S] [mask]

unalias - remove alias definitions
unalias alias-name...
unalias -a

uname - return system name
uname [-snrvma]

uncompress - expand compressed data
uncompress [-cfv] [file...]

unexpand - convert spaces to tabs
unexpand [-a|-t tablist] [file...]

uniq - report or filter out repeated lines in a file
uniq [-c|-d|-u] [-f fields] [-s char] [input_file [output_file]]

unlink - call the unlink( ) function
unlink file

uucp - UNIX-to-UNIX copy
uucp [-cCdfjmr] [-n user] source-file... destination-file

uudecode - decode a binary file
uudecode [-o outfile] [file]

uuencode - encode a binary file
uuencode [-m] [file] decode_pathname

uustat - uucp status inquiry and job control
uustat [-q|-k jobid|-r jobid]
uustat [-s system] [-u user]

uux - remote command execution
uux [-np] command-string
uux [-jnp] command-string

vi - screen-oriented (visual) display editor
vi [-rR] [-l] [-c command] [-t tagstring] [-w size] [file...]

wait - await process completion
wait [pid...]

wc - word, line, and byte or character count
wc [-c|-m] [-lw] [file...]

who - display who is on the system
who [-mTu]
who [-mu]-s [-bHlprt] [file]
who [-mTu] [-abdHlprt] [file]
who -q [file]
who am i
who am I

write - write to another user
write user_name [terminal]

xargs - construct argument lists and invoke utility
xargs [-ptx] [-E eofstr][-I replstr|-L number|-n number] [-s size] [utility [argument...]]

zcat - expand and concatenate data
zcat [file...]

Development Regular Utilities

admin - create and administer SCCS files (DEVELOPMENT)
admin -i[name] [-n] [-a login] [-d flag] [-e login] [-f flag] [-m mrlist] [-r rel] [-t[name] [-y[comment]] newfile
admin -n [-a login] [-d flag] [-e login] [-f flag] [-m mrlist] [-t[name]] [-y[comment]] newfile...
admin [-a login] [-d flag] [-m mrlist] [-r rel] [-t[name]] file...
admin -h file...
admin -z file...

cflow - generate a C-language flowgraph (DEVELOPMENT)
cflow [-r] [-d num] [-D name[=def]]... [-i incl] [-I dir]... [-U dir]... file...

ctags - create a tags file (DEVELOPMENT, FORTRAN)
ctags [-a] [-f tagsfile] pathname...
ctags -x pathname...

cxref - generate a C-language program cross-reference table (DEVELOPMENT)
cxref [-cs] [-o file] [-w num] [-D name[=def]]... [-I dir]... [-U name]... file...

delta - make a delta (change) to an SCCS file (DEVELOPMENT)
delta [-nps] [-g list] [-m mrlist] [-r SID] [-y[comment]] file...

fort77 - FORTRAN compiler (FORTRAN)
fort77 [-c] [-g] [-L directory]... [-O optlevel] [-o outfile] [-s] [-w] operand...

get - get a version of an SCCS file (DEVELOPMENT)
get [-begkmnlLpst] [-c cutoff] [-i list] [-r SID] [-x list] file...

lex - generate programs for lexical tasks (DEVELOPMENT)
lex [-t] [-n|-v] [file...]

m4 - macro processor (DEVELOPMENT)
m4 [-s] [-D name[=val]]... [-U name]... file...

make - maintain, update, and regenerate groups of programs (DEVELOPMENT)
make [-einpqrst] [-f makefile]... [-k|-S] [macro=value]...

nm - write the name list of an object file (DEVELOPMENT)
nm [-APv] [-efox] [-g|-u] [-t format] file...

prs - print an SCCS file (DEVELOPMENT)
prs [-a] [-d dataspec] [-r[SID]] file...
prs [-e|-l] -c cutoff [-d dataspec] file...
prs [-e|-l] -r[SID] [-d dataspec]file...

rmdel - remove a delta from an SCCS file (DEVELOPMENT)
rmdel -r SID file...

sact - print current SCCS file-editing activity (DEVELOPMENT)
sact file...

sccs - front end for the SCCS subsystem (DEVELOPMENT)
sccs [-r] [-d path] [-p path] command [options...] [operands...]

strip - remove unnecessary information from executable files (DEVELOPMENT)
strip file...

unget - undo a previous get of an SCCS file (DEVELOPMENT)
unget [-ns] [-r SID] file...

val - validate SCCS files (DEVELOPMENT)
val -
val [-s] [-m name] [-r SID] [-y type] file...

what - identify SCCS files (DEVELOPMENT)
what [-s] file...

yacc - yet another compiler compiler (DEVELOPMENT)
yacc [-dltv] [-b file_prefix] [-p sym_prefix] grammar

Note: The command description and synopsis excerpts above are copyright IEEE and The Open Group. No claim is made to them by the copyright notice on this page.