GNU sh-utils, version {No value for ‘VERSION’}

A set of shell utilities

for version {No value for ‘VERSION’}, {No value for ‘RELEASEDATE’}

David MacKenzie et al.

Copyright © 1994 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1 Introduction

First of all, this manual is incomplete. The stty section, in particular, needs substantial reorganization and additional explanatory text before it will be up to the standard of other GNU manuals. Explanatory text in general is lacking; the manual presently assumes you pretty much know what to do, and just need to be reminded of how. Thus, if you are interested, please get involved in improving this manual. The entire GNU community will benefit.

Some of these programs are useful only when writing shell scripts; utilities like these are, in fact, the “language” of shell scripts (to a great extent). Others are occasionally useful interactively.

The GNU shell utilities are mostly compatible with the POSIX.2 standard.

Please report bugs to ‘bug-gnu-utils@prep.ai.mit.edu’. Remember to include the version number, machine architecture, input files, and any other information needed to reproduce the bug. See Bugs in GNU CC.

This manual is based on the Unix man pages in the distribution, which were originally written by David MacKenzie and updated by Jim Meyering. {No value for ‘Francois’} Pinard did the initial conversion to Texinfo format. Karl Berry did the indexing, some reorganization, and editing of the results. Richard Stallman contributed his usual invaluable insights to the overall process.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2 Common options

Certain options are available in all these programs. Rather than writing identical descriptions for each of the programs, they are described here. (In fact, every GNU program accepts (or should accept) these options.)

Many of these programs take arbitrary strings as arguments. In those cases, ‘--help’ and ‘--version’ are taken as these options only if there is one and exactly one command line argument.

--help

Print a usage message listing all available options, then exit successfully.

--version

Print the version number, then exit successfully.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3 Printing text

This section describes commands that display text strings.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 echo: Print a line of text

Synopsis:

echo [ option ]… [ string ]…

echo writes each given string to standard output, with a space between each and a newline after the last one.

The program accepts the following options. Also see Common options.

-n

Do not output the trailing newline.

-e

Enable interpretation of the following backslash-escaped characters in each string:

\a

alert (bell)

\b

backspace

\c

suppress trailing newline

\f

form feed

\n

new line

\r

carriage return

\t

horizontal tab

\v

vertical tab

\\

backslash

\nnn

the character whose ASCII code is nnn (octal); if nnn is not a valid octal number, it is printed literally.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 printf: Format and print data

Synopsis:

printf format [ argument ]…

printf prints the format string, interpreting ‘%’ directives and ‘\’ escapes in the same way as the C printf function. The format argument is re-used as necessary to convert all of the given arguments.

printf has one additional directive, ‘%b’, which prints its argument string with ‘\’ escapes interpreted in the same way as in the format string.

printf interprets ‘\0ooo’ in format as an octal number (if ooo is 0 to 3 octal digits) specifying a character to print, and ‘\xhhh’ as a hexadecimal number (if hhh is 1 to 3 hex digits) specifying a character to print.

An additional escape, ‘\c’, causes printf to produce no further output.

The only options are a lone ‘--help’ or ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 yes: Print a string until interrupted

yes prints the command line arguments, separated by spaces and followed by a newline, forever until it is killed. If no arguments are given, it prints ‘y’ followed by a newline forever until killed.

The only options are a lone ‘--help’ or ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4 Conditions

This section describes commands that are primarily useful for their exit status, rather than their output. Thus, they are often used as the condition of shell if statements, or as the last command in a pipeline.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 false: Do nothing, unsuccessfully

false does nothing except return an exit status of 1, meaning failure. It can be used as a place holder in shell scripts where an unsuccessful command is needed.

Any arguments are ignored, except for a lone ‘--help’ or ‘--version’ (see section Common options).


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 true: Do nothing, successfully

true does nothing except return an exit status of 0, meaning success. It can be used as a place holder in shell scripts where a successful command is needed, although the shell built-in command : (colon) may be faster.

Any arguments are ignored, except for a lone ‘--help’ or ‘--version’ (see section Common options).


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 test: Check file types and compare values

test returns a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression expr. Each part of the expression must be a separate argument.

test has file status checks, string operators, and numeric comparison operators.

Because most shells have a built-in command by the same name, using the unadorned command name in a script or interactively may get you different functionality than that described here.

Besides the options below, test accepts a lone ‘--help’ or ‘--version’. See section Common options. A single non-option argument is also allowed: test returns true if the argument is not null.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.1 File type tests

These options test for particular types of files. (Everything’s a file, but not all files are the same!)

-b file

True if file exists and is a block special device.

-c file

True if file exists and is a character special device.

-d file

True if file exists and is a directory.

-f file

True if file exists and is a regular file.

-h file
-L file

True if file exists and is a symbolic link.

-p file

True if file exists and is a named pipe.

-S file

True if file exists and is a socket.

-t [ fd ]

True if fd is opened on a terminal. If fd is omitted, it defaults to 1 (standard output).


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.2 Access permission tests

These options test for particular access permissions.

-g file

True if file exists and has its set-group-id bit set.

-k file

True if file has its sticky bit set.

-r file

True if file exists and is readable.

-u file

True if file exists and has its set-user-id bit set.

-w file

True if file exists and is writable.

-x file

True if file exists and is executable.

-O file

True if file exists and is owned by the current effective user id.

-G file

True if file exists and is owned by the current effective group id.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.3 File characteristics tests

These options test other file characteristics.

-e file

True if file exists.

-s file

True if file exists and has a size greater than zero.

file1 -nt file2

True if file1 is newer (according to modification date) than file2.

file1 -ot file2

True if file1 is older (according to modification date) than file2.

file1 -ef file2

True if file1 and file2 have the same device and inode numbers, i.e., if they are hard links to each other.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.4 String tests

These options test string characteristics. Strings are not quoted for test, though you may need to quote them to protect characters with special meaning to the shell, e.g., spaces.

-z string

True if the length of string is zero.

-n string
string

True if the length of string is non-zero.

string1 = string2

True if the strings are equal.

string1 != string2

True if the strings are not equal.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.5 Numeric tests

Numeric relationals. The arguments must be entirely numeric (possibly negative), or the special expression -l string, which evaluates to the length of string.

arg1 -eq arg2
arg1 -ne arg2
arg1 -lt arg2
arg1 -le arg2
arg1 -gt arg2
arg1 -ge arg2

These arithmetic binary operators return true if arg1 is equal, not-equal, less-than, less-than-or-equal, greater-than, or greater-than-or-equal than arg2, respectively.

For example:

test -1 -gt -2 && echo yes
⇒ yes
test -l abc -gt 1 && echo yes
⇒ yes
test 0x100 -eq 1
error--> test: integer expression expected before -eq

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.6 Connectives for test

The usual logical connectives.

! expr

True if expr is false.

expr1 -a expr2

True if both expr1 and expr2 are true.

expr1 -o expr2

True if either expr1 or expr2 is true.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4 expr: Evaluate expressions

expr evaluates an expression and writes the result on standard output. Each token of the expression must be a separate argument.

Operands are either numbers or strings. expr coerces anything appearing in an operand position to an integer or a string depending on the operation being applied to it.

Strings are not quoted for expr, though you may need to quote them to protect characters with special meaning to the shell, e.g., spaces.

Operators may given as infix symbols or prefix keywords. Parentheses may be used for grouping in the usual manner (you must quote parentheses to avoid the shell evaluating them, however).

Exit status:

0 if the expression is neither null nor 0,
1 if the expression is null or 0,
2 for invalid expressions.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.1 Relations for expr

The usual logical connectives and relations, in order of precedence.

|

Yields its first argument if it is neither null nor 0, otherwise its second argument.

&

Yields its first argument if neither argument is null or 0, otherwise 0.

< <= = == != >= >

Compare the arguments and return 1 if the relation is true, 0 otherwise. == is a synonym for =. expr first tries to coerce both arguments to numbers and do a numeric comparison; if either coercion fails, it does a lexicographic comparison.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.2 Numeric expressions

Numeric operators, in order of increasing precedence. The connectives (previous section) have higher precedence, the string operators (following section) have lower.

+ -

Addition and subtraction. Both arguments are coerced to numbers; an error occurs if this cannot be done.

* / %

Multiplication, division, remainder. Both arguments are coerced to numbers; an error occurs if this cannot be done.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.3 String expressions

String operators. These have lowest precedence.

string : regex

Perform pattern matching. The arguments are coerced to strings and the second is considered to be a (basic, a la grep) regular expression, with a ^ implicitly prepended. The first argument is then matched against this regular expression.

If the match succeeds and regex uses ‘\(’ and ‘\)’, the : expression returns the part of string that matched the subexpression; otherwise, it returns the number of characters matched.

If the match fails, the : operator returns the null string if ‘\(’ and ‘\)’ are used in regex, otherwise 0.

Only the first ‘\( … \)’ pair is relevant to the return value; additional pairs are meaningful only for grouping the regular expression operators.

See Regular Expression Library in Regex, for details of regular expression syntax.

match string regex

An alternative way to do pattern matching. This is the same as ‘string : regex’.

substr string position length

Returns the substring of string beginning at position with length at most length. If either position or length is negative or non-numeric, returns the null string.

index string character-class

Returns the first position in string where the first character in charset was found. If no character in charset is found in string, return 0.

length string

Returns the length of string.

The keywords cannot be used as strings.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.4 Examples of expr

Here are a few examples, including quoting for shell metacharacters.

To add 1 to the shell variable foo, in Bourne-compatible shells:

foo=`expr $foo + 1`

To print the non-directory part of the file name stored in $fname, which need not contain a /.

expr $fname : '.*/\(^.*\)' '^|' $fname
expr abc : 'a\(.\)c'
⇒ b
expr index abcdef cz
⇒ 3
expr index index a
error--> expr: syntax error


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5 Redirection

Unix shells commonly provide several forms of redirection—ways to change the input source or output destination of a command. But one useful redirection is performed by a separate command, not by the shell; it’s described here.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 tee: Redirect output to multiple files

The tee command copies standard input to standard output and also to any files given as arguments. This is useful when you want not only to send some data down a pipe, but also to save a copy.

Synopsis:

tee [ option ]… [ file ]…

If a file being written to does not already exist, it is created. If a file being written to already exists, the data it previously contained is overwritten unless the -a option is used.

The program accepts the following options. Also see Common options.

-a
--append

Append standard input to the given files rather than overwriting them.

-i
--ignore-interrupts

Ignore interrupt signals.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6 File name manipulation

This section describes commands that manipulate file names.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.1 basename: Strip directory and suffix from a file name

Synopsis:

basename name [ suffix ]

The basename command removes any leading directory components from name. If suffix is specified and is identical to the end of name, it is removed from name as well. basename prints the result on standard output.

The only options are ‘--help’ and ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.2 dirname: Strip non-directory suffix from a file name

Synopsis:

dirname name

dirname prints all but the final slash-delimited component of name. If name is a single component, dirname prints ‘.’ (meaning the current directory).

The only options are ‘--help’ and ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3 pathchk: Check file name portability

Synopsis:

pathchk [ option ]… name

For each name, pathchk prints a message if any of these conditions is true:

  1. one of the existing directories in name does not have search (execute) permission,
  2. the length of name is larger than its filesystem’s maximum file name length,
  3. the length of one component of name, corresponding to an existing directory name, is larger than its filesystem’s maximum length for a file name component.

The program accepts the following option. Also see Common options.

-p
--portability

Instead of performing length checks on the underlying filesystem, test the length of each file name and its components against the POSIX.1 minimum limits for portability. Also check that the file name contains no characters not in the portable file name character set.

Exit status:

0 if all specified file names passed all of the tests,
1 otherwise.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7 Working context information

This section describes commands that display or alter the context in which you are working: the current directory, the terminal settings, and so forth. See also the user-related commands in the next section.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.1 pwd: Print working directory

pwd prints the fully resolved name of the current directory. That is, all components of the printed name will be actual directory names—none will be symbolic links.

Because most shells have a built-in command by the same name, using the unadorned command name in a script or interactively may get you different functionality than that described here.

The only options are a lone ‘--help’ or ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2 stty: Print or change terminal characteristics

If given no arguments, stty prints the baud rate, line discipline number (on systems that support it), and line settings that have been changed from the values set by ‘stty sane’. Mode reading and setting are performed on the tty line connected to standard input.

stty accepts many non-option arguments that change aspects of the terminal line operation, as described below.

Synopses:

stty [ setting ]…
stty [ option ]

The program accepts the following options. Also see Common options.

-a
--all

Print all current settings in human-readable form.

-g
--save

Print all current settings in a form that can be used as an argument to another stty command to restore the current settings.

Many settings can be turned off by preceding them with a ‘-’. Such arguments are marked below with “May be negated” in their description. The descriptions themselves refer to the positive case, that is, when not negated (unless stated otherwise, of course).

Some settings are not available on all POSIX systems, since they use extensions. Such arguments are marked below with “Non-POSIX” in their description. On non-POSIX systems, those or other settings also may not be available, but it’s not feasible to document all the variations: just try it and see.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2.1 Control settings

Control settings:

parenb

Generate parity bit in output and expect parity bit in input. May be negated.

parodd

Set odd parity (even if negated). May be negated.

cs5
cs6
cs7
cs8

Set character size to 5, 6, 7, or 8 bits.

hup
hupcl

Send a hangup signal when the last process closes the tty. May be negated.

cstopb

Use two stop bits per character (one if negated). May be negated.

cread

Allow input to be received. May be negated.

clocal

Disable modem control signals. May be negated.

crtscts

Enable RTS/CTS flow control. Non-POSIX. May be negated.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2.2 Input settings

ignbrk

Ignore breaks. May be negated.

brkint

Make breaks cause an interrupt signal. May be negated.

ignpar

Ignore parity errors. May be negated.

parmrk

Mark parity errors (with a 255-0-character sequence). May be negated.

inpck

Enable input parity checking. May be negated.

istrip

Clear high (8th) bit of input characters. May be negated.

inlcr

Translate newline to carriage return. May be negated.

igncr

Ignore carriage return. May be negated.

icrnl

Translate carriage return to newline. May be negated.

ixon

Enable XON/XOFF flow control (that is, <CTRL-s>/<CTRL-Q>). May be negated.

ixoff
tandem

Enable sending of stop character when the system input buffer is almost full, and start character when it becomes almost empty again. May be negated.

iuclc

Translate uppercase characters to lowercase. Non-POSIX. May be negated.

ixany

Allow any character to restart output (only the start character if negated). Non-POSIX. May be negated.

imaxbel

Enable beeping and not flushing input buffer if a character arrives when the input buffer is full. Non-POSIX. May be negated.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2.3 Output settings

These arguments specify output-related operations.

opost

Postprocess output. May be negated.

olcuc

Translate lowercase characters to uppercase. Non-POSIX. May be negated.

ocrnl

Translate carriage return to newline. Non-POSIX. May be negated.

onlcr

Translate newline to carriage return-newline. Non-POSIX. May be negated.

onocr

Do not print carriage returns in the first column. Non-POSIX. May be negated.

onlret

Newline performs a carriage return. Non-POSIX. May be negated.

ofill

Use fill (padding) characters instead of timing for delays. Non-POSIX. May be negated.

ofdel

Use delete characters for fill instead of null characters. Non-POSIX. May be negated.

nl1
nl0

Newline delay style. Non-POSIX.

cr3
cr2
cr1
cr0

Carriage return delay style. Non-POSIX.

tab3
tab2
tab1
tab0

Horizontal tab delay style. Non-POSIX.

bs1
bs0

Backspace delay style. Non-POSIX.

vt1
vt0

Vertical tab delay style. Non-POSIX.

ff1
ff0

Form feed delay style. Non-POSIX.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2.4 Local settings

isig

Enable interrupt, quit, and suspend special characters. May be negated.

icanon

Enable erase, kill, werase, and rprnt special characters. May be negated.

iexten

Enable non-POSIX special characters. May be negated.

echo

Echo input characters. May be negated.

echoe
crterase

Echo erase characters as backspace-space-backspace. May be negated.

echok

Echo a newline after a kill character. May be negated.

echonl

Echo newline even if not echoing other characters. May be negated.

noflsh

Disable flushing after interrupt and quit special characters. May be negated.

xcase

Enable input and output of uppercase characters by preceding their lowercase equivalents with ‘\’, when icanon is set. Non-POSIX. May be negated.

tostop

Stop background jobs that try to write to the terminal. Non-POSIX. May be negated.

echoprt
prterase

Echo erased characters backward, between ‘\’ and ‘/’. Non-POSIX. May be negated.

echoctl
ctlecho

Echo control characters in hat notation (‘^c’) instead of literally. Non-POSIX. May be negated.

echoke
crtkill

Echo the kill special character by erasing each character on the line as indicated by the echoprt and echoe settings, instead of by the echoctl and echok settings. Non-POSIX. May be negated.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2.5 Combination settings

Combination settings:

evenp
parity

Same as parenb -parodd cs7. May be negated. If negated, same as -parenb cs8.

oddp

Same as parenb parodd cs7. May be negated. If negated, same as -parenb cs8.

nl

Same as -icrnl -onlcr. May be negated. If negated, same as icrnl -inlcr -igncr onlcr -ocrnl -onlret.

ek

Reset the erase and kill special characters to their default values.

sane

Same as:

cread -ignbrk brkint -inlcr -igncr icrnl -ixoff -iuclc -ixany
imaxbel opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel
nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl
-noflsh -xcase -tostop -echoprt echoctl echoke

and also sets all special characters to their default values.

cooked

Same as brkint ignpar istrip icrnl ixon opost isig icanon, plus sets the eof and eol characters to their default values if they are the same as the min and time characters. May be negated. If negated, same as raw.

raw

Same as:

-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr
-icrnl -ixon -ixoff -iuclc -ixany -imaxbel -opost -isig -icanon
-xcase min 1 time 0

May be negated. If negated, same as cooked.

cbreak

Same as -icanon. May be negated. If negated, same as icanon.

pass8

Same as -parenb -istrip cs8. May be negated. If negated, same as parenb istrip cs7.

litout

Same as -parenb -istrip -opost cs8. May be negated. If negated, same as parenb istrip opost cs7.

decctlq

Same as -ixany. Non-POSIX. May be negated.

tabs

Same as tab0. Non-POSIX. May be negated. If negated, same as tab3.

lcase
LCASE

Same as xcase iuclc olcuc. Non-POSIX. May be negated.

crt

Same as echoe echoctl echoke.

dec

Same as echoe echoctl echoke -ixany intr ^C erase ^? kill C-u.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2.6 Special characters

The special characters’ default values vary from system to system. They are set with the syntax ‘name value’, where the names are listed below and the value can be given either literally, in hat notation (‘^c’), or as an integer which may start with ‘0x’ to indicate hexadecimal, ‘0’ to indicate octal, or any other digit to indicate decimal.

For GNU stty, giving a value of ^- or undef disables that special character. (This is incompatible with Ultrix stty, which uses a value of ‘u’ to disable a special character. GNU stty treats a value ‘u’ like any other, namely to set that special character to <u>.)

intr

Send an interrupt signal.

quit

Send a quit signal.

erase

Erase the last character typed.

kill

Erase the current line.

eof

Send an end of file (terminate the input).

eol

End the line.

eol2

Alternate character to end the line. Non-POSIX.

swtch

Switch to a different shell layer. Non-POSIX.

start

Restart the output after stopping it.

stop

Stop the output.

susp

Send a terminal stop signal.

dsusp

Send a terminal stop signal after flushing the input. Non-POSIX.

rprnt

Redraw the current line. Non-POSIX.

werase

Erase the last word typed. Non-POSIX.

lnext

Enter the next character typed literally, even if it is a special character. Non-POSIX.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2.7 Special settings

min n

Set the minimum number of characters that will satisfy a read until the time value has expired, when -icanon is set.

time n

Set the number of tenths of a second before reads time out if the min number of characters have not been read, when -icanon is set.

ispeed n

Set the input speed to n.

ospeed n

Set the output speed to n.

rows n

Tell the tty kernel driver that the terminal has n rows. Non-POSIX.

cols n
columns n

Tell the kernel that the terminal has n columns. Non-POSIX.

size

Print the number of rows and columns that the kernel thinks the terminal has. (Systems that don’t support rows and cols in the kernel typically use the environment variables LINES and COLUMNS instead; however, GNU stty does not know anything about them.) Non-POSIX.

line n

Use line discipline n. Non-POSIX.

speed

Print the terminal speed.

n

Set the input and output speeds to n. n can be one of: 0 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 exta extb. exta is the same as 19200; extb is the same as 38400. 0 hangs up the line if -clocal is set.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3 printenv: Print all or some environment variables

Synopsis:

printenv [ option ] [ variable ]…

If no variables are specified, printenv prints the value of every environment variable. Otherwise, it prints the value of each variable that is set, and nothing for those that are not set.

The only options are a lone ‘--help’ or ‘--version’. See section Common options.

Exit status:

0 if all variables specified were found
1 if at least one specified variable was not found
2 if a write error occurred

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.4 tty: Print file name of terminal on standard input

tty prints the file name of the tty connected to its standard input. It prints ‘not a tty’ if standard input is not a tty.

Synopsis:

tty [ option ]…

The program accepts the following option. Also see Common options.

-s
--silent
--quiet

Print nothing; only return an exit status.

Exit status:

0 if standard input is a tty
1 if standard input is not a tty
2 if given incorrect arguments
3 if a write error occurs

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8 User information

This section describes commands that print user-related information: logins, groups, and so forth.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1 id: Print real and effective uid and gid

id prints information about the given user, or the process running it if no user is specified.

Synopsis:

id [ option ]… [ username ]

By default, it prints the real user id, real group id, effective user id if different from the real user id, effective group id if different from the real group id, and supplemental group ids.

Each of these numeric values is preceded by an identifying string and followed by the corresponding user or group name in parentheses.

The options cause id to print only part of the above information. Also see Common options.

-g
--group

Print only the group id.

-G
--groups

Print only the supplementary groups.

-n
--name

Print the user or group name instead of the ID number. Requires -u, -g, or -G.

-r
--real

Print the real, instead of effective, user or group id. Requires -u, -g, or -G.

-u
--user

Print only the user id.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.2 logname: Print current login name

logname prints the calling user’s name, as found in the file ‘/etc/utmp’, and exits with a status of 0. If there is no ‘/etc/utmp’ entry for the calling process, logname prints an error message and exits with a status of 1.

The only options are ‘--help’ and ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.3 whoami: Print effective user id

whoami prints the user name associated with the current effective user id. It is equivalent to the command ‘id -un’.

The only options are ‘--help’ and ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.4 groups: Print group names a user is in

groups prints the names of the primary and any supplementary groups that each given username, or the current process if none are given, is in. If user names are given, the name of each user is printed before the list of that user’s groups.

Synopsis:

groups [ username ]…

The group lists are equivalent to the output of the command ‘id -Gn’.

The only options are ‘--help’ and ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.5 users: Print login names of users currently logged in

users prints on a single line a blank-separated list of user names of users currently logged in to the current host. Each user name corresponds to a login session, so if a user has more than one login session, that user’s name will appear the same number of times in the output.

Synopsis:

users [ file ]

With no file argument, users extracts its information from the file ‘/etc/utmp’. If a file argument is given, users uses that file instead. A common choice is ‘/etc/wtmp’.

The only options are ‘--help’ and ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.6 who: Print who is currently logged in

Synopsis:

who [ option ] [ file ] [ am i ]

If given no non-option arguments, who prints the following information for each user currently logged on: login name, terminal line, login time, and remote hostname or X display.

If given one non-option argument, who uses that instead of ‘/etc/utmp’ as the name of the file containing the record of users logged on. ‘/etc/wtmp’ is commonly given as an argument to who to look at who has previously logged on.

If given two non-option arguments, who prints only the entry for the user running it (determined from its standard input), preceded by the hostname. Traditionally, the two arguments given are ‘am i’, as in ‘who am i’.

The program accepts the following options. Also see Common options.

-m

Same as ‘who am i’.

-q
--count

Print only the login names and the number of users logged on. Overrides all other options.

-s

Ignored; for compatibility with other versions of who.

-i
-u
--idle

After the login time, print the number of hours and minutes that the user has been idle. ‘.’ means the user was active in last minute. ‘old’ means the user was idle for more than 24 hours.

-H
--heading

Print a line of column headings.

-w
-T
--mesg
--message
--writable

After each login name print a character indicating the user’s message status:

+’ allowing write messages
‘-’ disallowing write messages
‘?’ cannot find terminal device

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9 System context

This section describes commands that print or change system-wide information.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1 date: Print or set system date and time

date with no arguments prints the current time and date, in the format of the ‘%c’ directive (described below).

Synopses:

date [ option ]… [ +format ]
date [ -u|--utc|--universal ] [ MMDDhhmm[[CC]YY][.ss] ]

If given an argument that starts with a ‘+’, date prints the current time and date (or the time and date specified by the --date option, see below) in the format defined by that argument, which is the same as in the strftime function. Except for directives, which start with ‘%’, characters in the format string are printed unchanged. The directives are described below.

By default, date pads numeric fields with zeroes. GNU date recognizes the following numeric modifiers between the ‘%’ and the directive. These are GNU extensions.

-

(hyphen) do not pad the field

_

(underscore) pad the field with spaces


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.1 Time directives

date directives related to times.

%H

hour (00…23)

%I

hour (01…12)

%k

hour ( 0…23)

%l

hour ( 1…12)

%M

minute (00…59)

%p

locale’s AM or PM

%r

time, 12-hour (hh:mm:ss [AP]M)

%s

seconds since the epoch, i.e., 1 January 1970 00:00:00 UTC (a GNU extension)

%S

second (00…61)

%T

time, 24-hour (hh:mm:ss)

%X

locale’s time representation (%H:%M:%S)

%Z

time zone (e.g., EDT), or nothing if no time zone is determinable


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.2 Date directives

date directives related to dates.

%a

locale’s abbreviated weekday name (Sun…Sat)

%A

locale’s full weekday name, variable length (Sunday…Saturday)

%b

locale’s abbreviated month name (Jan…Dec)

%B

locale’s full month name, variable length (January…December)

%c

locale’s date and time (Sat Nov 04 12:02:33 EST 1989)

%d

day of month (01…31)

%D

date (mm/dd/yy)

%h

same as %b

%j

day of year (001…366)

%m

month (01…12)

%U

week number of year with Sunday as first day of week (00…53)

%w

day of week (0…6) with 0 corresponding to Sunday

%W

week number of year with Monday as first day of week (00…53)

%x

locale’s date representation (mm/dd/yy)

%y

last two digits of year (00…99)

%Y

year (1970….)


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.3 Literal directives

date directives that produce literal strings.

%%

a literal %

%n

a newline

%t

a horizontal tab


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.4 Setting the time

If given an argument that does not start with ‘+’, date sets the system clock to the time and date specified by that argument (as described below). You must have appropriate privileges to set the system clock. The ‘--date’ and ‘--set’ options may not be used with such an argument. The ‘--universal’ option may be used with such an argument to indicate that the specified time and date are relative to Coordinated Universal Time rather than to the local time zone.

The argument must consist entirely of digits, which have the following meaning:

MM

month

DD

day within month

hh

hour

mm

minute

CC

first two digits of year (optional)

YY

last two digits of year (optional)

ss

second (optional)

The ‘--set’ option also sets the system clock; see the next section.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.5 Options for date

The program accepts the following options. Also see Common options.

-d datestr
--date=datestr

Display the time and date specified in datestr instead of the current time and date. datestr can be in almost any common format. It can contain month names, timezones, ‘am’ and ‘pm’, ‘yesterday’, ‘ago’, ‘next’, etc. The source file ‘getdate.y’ implements this parsing for all GNU routines; we need precise documentation!

-f datefile
--file=datefile

Parse each line in datefile as with ‘-d’ and display the resulting time and date. If datefile is ‘-’, use standard input. This is useful when you have many dates to process, because the system overhead of starting up the date executable many times can be considerable.

-s datestr
--set=datestr

Set the time and date to datestr, See ‘-d’ above.

-u
--utc
--universal

Print or set the time and date in Universal Coordinated Time instead of in local (wall clock) time.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.6 Examples of date

Here are a few examples. Also see the documentation for the ‘-d’ option in the previous section.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.2 uname: Print system information

uname prints information about the machine and operating system it is run on. If no options are given, uname acts as if the -s option were given.

Synopsis:

uname [ option ]…

If multiple options or -a are given, the selected information is printed in this order:

sysname nodename release osversion machine

The osversion, at least, may well be multiple words. For example:

bash$ uname -a
⇒ Linux hayley 1.0.4 #3 Thu May 12 18:06:34 1994 i486

The program accepts the following options. Also see Common options.

-a
--all

Print all of the below information.

-m
--machine

Print the machine (hardware) type.

-n
--nodename

Print the machine’s network node hostname.

-r
--release

Print the operating system release.

-s
--sysname

Print the operating system name.

-v

Print the operating system version.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.3 hostname: Print or set system name

With no arguments, hostname prints the name of the current host system. With one argument, it sets the current host name to the specified string. You must have appropriate privileges to set the host name.

Synopsis:

hostname [ name ]

The only options are ‘--help’ and ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10 Modified command invocation

This section describes commands that run other commands in some context different than the current one: a modified environment, as a different user, etc.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.1 env: Run a command in a modified environment

env runs a command with an environment modified as specified by the command line arguments.

Synopses:

env [ option ]… [ name=value ]… [ command [ args ]… ]
env

Arguments of the form ‘variable=value’ set the environment variable variable to value value. value may be empty (‘variable=’). Setting a variable to an empty value is different from unsetting it.

The first remaining argument specifies the program name to invoke; it is searched for according to the PATH environment variable. Any remaining arguments are passed as arguments to that program.

If no command name is specified following the environment specifications, the resulting environment is printed. This is like specifying a command name of printenv.

The program accepts the following options. Also see Common options.

-u name
--unset=name

Remove variable name from the environment, if it was in the environment.

-
-i
--ignore-environment

Start with an empty environment, ignoring the inherited environment.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.2 nice: Run a command with modified scheduling priority

If no arguments are given, nice prints the current scheduling priority, which it inherited. Otherwise, nice runs the given command with its scheduling priority adjusted. If no adjustment is given, the priority of the command is incremented by 10. You must have appropriate privileges to specify a negative adjustment. The priority can be adjusted by nice over the range of -20 (the highest priority) to 19 (the lowest).

Synopsis:

nice [ option ]… [ command [ arg ]… ]

Because most shells have a built-in command by the same name, using the unadorned command name in a script or interactively may get you different functionality than that described here.

The program accepts the following option. Also see Common options.

-n adjustment
-adjustment
--adjustment=adjustment

Add adjustment instead of 10 to the command’s priority.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.3 nohup: Run a command immune to hangups

nohup runs the given command with hangup signals ignored, so that the command can continue running in the background after you log out.

Synopsis:

nohup command [ arg ]…

Also, the scheduling priority is increased by 5. If standard output is a tty, it and standard error are redirected so that they are appended to the file ‘nohup.out’; if that cannot be written to, they are appended to the file ‘$HOME/nohup.out’. If that cannot be written to, the command is not run.

If nohup creates either ‘nohup.out’ or ‘$HOME/nohup.out’, it creates it with no “group” or “other” access permissions. It does not change the permissions if the output file already existed.

nohup does not automatically put the command it runs in the background; you must do that explicitly, by ending the command line with an ‘&’.

The only options are ‘--help’ and ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.4 su: Run a command with substitute user and group id

su allows one user to temporarily become another user. It runs a command (often an interactive shell) with the real and effective user id, group id, and supplemental groups of a given user.

Synopsis:

su [ option ]… [ user [ arg ]… ]

If no user is given, the default is root, the super-user. The shell to use is taken from user’s passwd entry, or ‘/bin/sh’ if none is specified there. If user has a password, su prompts for the password unless run by a user with effective user id of zero (the super-user).

By default, su does not change the current directory. It sets the environment variables HOME and SHELL from the password entry for user, and if user is not the super-user, sets USER and LOGNAME to user. By default, the shell is not a login shell.

Any additional args are passed as additional arguments to the shell.

GNU su does not treat ‘/bin/sh’ or any other shells specially (e.g., by setting argv[0] to ‘-su’, passing -c only to certain shells, etc.).

su can optionally be compiled to use syslog to report failed, and optionally successful, su attempts. (If the system supports syslog.) However, GNU su does not check if the user is a member of the wheel group; see below.

The program accepts the following options. Also see Common options.

-c command
--command=command

Pass command, a single command line to run, to the shell with a -c option instead of starting an interactive shell.

-f
--fast

Pass the -f option to the shell. This probably only makes sense if the shell run is csh or tcsh, for which the -f option prevents reading the startup file (‘.cshrc’). With Bourne-like shells, the -f option disables file name pattern expansion (globbing), which is not likely to be useful.

-
-l
--login

Make the shell a login shell. This means the following. Unset all environment variables except TERM, HOME, and SHELL (which are set as described above), and USER and LOGNAME (which are set, even for the super-user, as described above), and set PATH to a compiled-in default value. Change to user’s home directory. Prepend ‘-’ to the shell’s name, intended to make it read its login startup file(s).

-m
-p
--preserve-environment

Do not change the environment variables HOME, USER, LOGNAME, or SHELL. Run the shell given in the environment variable SHELL instead of the shell from user’s passwd entry, unless the user running su is not the superuser and user’s shell is restricted. A restricted shell is one that is not listed in the file ‘/etc/shells’, or in a compiled-in list if that file does not exist. Parts of what this option does can be overridden by --login and --shell.

-s shell
--shell=shell

Run shell instead of the shell from user’s passwd entry, unless the user running su is not the superuser and user’s shell is restricted (see ‘-m’ just above).

Why GNU su does not support the ‘wheel’ group

(This section is by Richard Stallman.)

Sometimes a few of the users try to hold total power over all the rest. For example, in 1984, a few users at the MIT AI lab decided to seize power by changing the operator password on the Twenex system and keeping it secret from everyone else. (I was able to thwart this coup and give power back to the users by patching the kernel, but I wouldn’t know how to do that in Unix.)

However, occasionally the rulers do tell someone. Under the usual su mechanism, once someone learns the root password who sympathizes with the ordinary users, he or she can tell the rest. The “wheel group” feature would make this impossible, and thus cement the power of the rulers.

I’m on the side of the masses, not that of the rulers. If you are used to supporting the bosses and sysadmins in whatever they do, you might find this idea strange at first.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11 Delaying

Perhaps wait or other commands should be described here also?


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

11.1 sleep: Delay for a specified time

sleep pauses for an amount of time specified by the sum of the values of the command line arguments.

Synopsis:

sleep [ number[smhd] ]…

Each argument is a number followed by an optional unit; the default is seconds. The units are:

s

seconds

m

minutes

h

hours

d

days

The only options are ‘--help’ and ‘--version’. See section Common options.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Index

Jump to:   !   %   &   *   +   -   .   /   <   =   >   \   |  
A   B   C   D   E   F   G   H   I   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z  
Index Entry  Section

!
! 4.3.6 Connectives for test
!= 4.3.4 String tests

%
% 4.4.2 Numeric expressions

&
& 4.4.1 Relations for expr

*
* 4.4.2 Numeric expressions

+
+ 4.4.2 Numeric expressions

-
- 4.4.2 Numeric expressions
- 10.1 env: Run a command in a modified environment
- 10.4 su: Run a command with substitute user and group id
-a 4.3.6 Connectives for test
-a 5.1 tee: Redirect output to multiple files
-a 7.2 stty: Print or change terminal characteristics
-a 9.2 uname: Print system information
--adjustment 10.2 nice: Run a command with modified scheduling priority
-adjustment 10.2 nice: Run a command with modified scheduling priority
--all 7.2 stty: Print or change terminal characteristics
--all 9.2 uname: Print system information
--append 5.1 tee: Redirect output to multiple files
-b 4.3.1 File type tests
-c 4.3.1 File type tests
-c 10.4 su: Run a command with substitute user and group id
--command 10.4 su: Run a command with substitute user and group id
--count 8.6 who: Print who is currently logged in
-d 4.3.1 File type tests
-d 9.1.5 Options for date
--date 9.1.5 Options for date
-e 3.1 echo: Print a line of text
-e 4.3.3 File characteristics tests
-ef 4.3.3 File characteristics tests
-eq 4.3.5 Numeric tests
-f 4.3.1 File type tests
-f 9.1.5 Options for date
-f 10.4 su: Run a command with substitute user and group id
--fast 10.4 su: Run a command with substitute user and group id
--file 9.1.5 Options for date
-g 4.3.2 Access permission tests
-G 4.3.2 Access permission tests
-g 7.2 stty: Print or change terminal characteristics
-g 8.1 id: Print real and effective uid and gid
-G 8.1 id: Print real and effective uid and gid
-ge 4.3.5 Numeric tests
--group 8.1 id: Print real and effective uid and gid
--groups 8.1 id: Print real and effective uid and gid
-gt 4.3.5 Numeric tests
-h 4.3.1 File type tests
-H 8.6 who: Print who is currently logged in
--heading 8.6 who: Print who is currently logged in
--help 2 Common options
-i 5.1 tee: Redirect output to multiple files
-i 8.6 who: Print who is currently logged in
-i 10.1 env: Run a command in a modified environment
--idle 8.6 who: Print who is currently logged in
--ignore-environment 10.1 env: Run a command in a modified environment
--ignore-interrupts 5.1 tee: Redirect output to multiple files
-k 4.3.2 Access permission tests
-L 4.3.1 File type tests
-l 10.4 su: Run a command with substitute user and group id
-le 4.3.5 Numeric tests
--login 10.4 su: Run a command with substitute user and group id
-lt 4.3.5 Numeric tests
-m 8.6 who: Print who is currently logged in
-m 9.2 uname: Print system information
-m 10.4 su: Run a command with substitute user and group id
--machine 9.2 uname: Print system information
--mesg 8.6 who: Print who is currently logged in
--message 8.6 who: Print who is currently logged in
-n 3.1 echo: Print a line of text
-n 4.3.4 String tests
-n 8.1 id: Print real and effective uid and gid
-n 9.2 uname: Print system information
-n 10.2 nice: Run a command with modified scheduling priority
--name 8.1 id: Print real and effective uid and gid
-ne 4.3.5 Numeric tests
--nodename 9.2 uname: Print system information
-nt 4.3.3 File characteristics tests
-O 4.3.2 Access permission tests
-o 4.3.6 Connectives for test
-ot 4.3.3 File characteristics tests
-p 4.3.1 File type tests
-p 6.3 pathchk: Check file name portability
-p 10.4 su: Run a command with substitute user and group id
--portability 6.3 pathchk: Check file name portability
--preserve-environment 10.4 su: Run a command with substitute user and group id
-q 8.6 who: Print who is currently logged in
--quiet 7.4 tty: Print file name of terminal on standard input
-r 4.3.2 Access permission tests
-r 8.1 id: Print real and effective uid and gid
-r 9.2 uname: Print system information
--real 8.1 id: Print real and effective uid and gid
--release 9.2 uname: Print system information
-S 4.3.1 File type tests
-s 4.3.3 File characteristics tests
-s 7.4 tty: Print file name of terminal on standard input
-s 8.6 who: Print who is currently logged in
-s 9.1.5 Options for date
-s 9.2 uname: Print system information
-s 10.4 su: Run a command with substitute user and group id
--save 7.2 stty: Print or change terminal characteristics
--set 9.1.5 Options for date
--shell 10.4 su: Run a command with substitute user and group id
--silent 7.4 tty: Print file name of terminal on standard input
-su 10.4 su: Run a command with substitute user and group id
--sysname 9.2 uname: Print system information
-t 4.3.1 File type tests
-T 8.6 who: Print who is currently logged in
-u 4.3.2 Access permission tests
-u 8.1 id: Print real and effective uid and gid
-u 8.6 who: Print who is currently logged in
-u 9.1.5 Options for date
-u 10.1 env: Run a command in a modified environment
--universal 9.1.5 Options for date
-unset 10.1 env: Run a command in a modified environment
--user 8.1 id: Print real and effective uid and gid
--utc 9.1.5 Options for date
-v 9.2 uname: Print system information
--version 2 Common options
-w 4.3.2 Access permission tests
-w 8.6 who: Print who is currently logged in
--writable 8.6 who: Print who is currently logged in
-x 4.3.2 Access permission tests
-z 4.3.4 String tests

.
.cshrc 10.4 su: Run a command with substitute user and group id

/
/ 4.4.2 Numeric expressions
/bin/sh 10.4 su: Run a command with substitute user and group id
/etc/passwd 10.4 su: Run a command with substitute user and group id
/etc/shells 10.4 su: Run a command with substitute user and group id
/etc/utmp 8.2 logname: Print current login name
/etc/utmp 8.5 users: Print login names of users currently logged in
/etc/utmp 8.6 who: Print who is currently logged in
/etc/wtmp 8.5 users: Print login names of users currently logged in
/etc/wtmp 8.6 who: Print who is currently logged in

<
< 4.4.1 Relations for expr
<= 4.4.1 Relations for expr

=
= 4.3.4 String tests
= 4.4.1 Relations for expr
== 4.4.1 Relations for expr

>
> 4.4.1 Relations for expr
>= 4.4.1 Relations for expr

\
\0ooo 3.2 printf: Format and print data
\0xhhh 3.2 printf: Format and print data
\c 3.2 printf: Format and print data

|
| 4.4.1 Relations for expr

A
access permission tests 4.3.2 Access permission tests
addition 4.4.2 Numeric expressions
am i 8.6 who: Print who is currently logged in
and operator 4.3.6 Connectives for test
and operator 4.4.1 Relations for expr
appropriate privileges 9.1.4 Setting the time
appropriate privileges 9.3 hostname: Print or set system name
appropriate privileges 10.2 nice: Run a command with modified scheduling priority
arbitrary date strings, parsing 9.1.5 Options for date
arbitrary text, displaying 3.1 echo: Print a line of text
arithmetic tests 4.3.5 Numeric tests

B
background jobs, stopping at terminal write 7.2.4 Local settings
backslash escapes 3.1 echo: Print a line of text
basename 6.1 basename: Strip directory and suffix from a file name
baud rate, setting 7.2.7 Special settings
beeping at input buffer full 7.2.2 Input settings
beginning of time 9.1.1 Time directives
block special check 4.3.1 File type tests
breaks, cause interrupts 7.2.2 Input settings
breaks, ignoring 7.2.2 Input settings
brkint 7.2.2 Input settings
bsn 7.2.3 Output settings
bugs, reporting 1 Introduction
built-in shell commands, conflicts with 4.3 test: Check file types and compare values
built-in shell commands, conflicts with 7.1 pwd: Print working directory
built-in shell commands, conflicts with 10.2 nice: Run a command with modified scheduling priority

C
C-s/C-q flow control 7.2.2 Input settings
case translation 7.2.4 Local settings
cbreak 7.2.5 Combination settings
change or print terminal settings 7.2 stty: Print or change terminal characteristics
character size 7.2.1 Control settings
character special check 4.3.1 File type tests
characters, special 7.2.6 Special characters
check file types 4.3 test: Check file types and compare values
clocal 7.2.1 Control settings
cols 7.2.7 Special settings
columns 7.2.7 Special settings
COLUMNS 7.2.7 Special settings
combination settings 7.2.5 Combination settings
commands for delaying 11 Delaying
commands for exit status 4 Conditions
commands for file name manipulation 6 File name manipulation
commands for invoking other commands 10 Modified command invocation
commands for printing text 3 Printing text
commands for printing the working context 7 Working context information
commands for printing user information 8 User information
commands for redirection 5 Redirection
commands for system context 9 System context
common options 2 Common options
compare values 4.3 test: Check file types and compare values
comparison operators 4.4.1 Relations for expr
conditions 4 Conditions
conflicts with shell built-ins 4.3 test: Check file types and compare values
conflicts with shell built-ins 7.1 pwd: Print working directory
conflicts with shell built-ins 10.2 nice: Run a command with modified scheduling priority
connectives, logical 4.3.6 Connectives for test
connectives, logical 4.4.1 Relations for expr
context, system 9 System context
control characters, using ‘^c 7.2.4 Local settings
control settings 7.2.1 Control settings
cooked 7.2.5 Combination settings
coordinated universal time 9.1.5 Options for date
cread 7.2.1 Control settings
crn 7.2.3 Output settings
crt 7.2.5 Combination settings
crterase 7.2.4 Local settings
crtkill 7.2.4 Local settings
crtscts 7.2.1 Control settings
csn 7.2.1 Control settings
cstopb 7.2.1 Control settings
ctlecho 7.2.4 Local settings
current working directory, printing 7.1 pwd: Print working directory

D
date 9.1 date: Print or set system date and time
date directives 9.1.2 Date directives
date options 9.1.5 Options for date
date strings, parsing 9.1.5 Options for date
dec 7.2.5 Combination settings
decctlq 7.2.5 Combination settings
delay for a specified time 11.1 sleep: Delay for a specified time
delaying commands 11 Delaying
destinations, multiple output 5.1 tee: Redirect output to multiple files
directives, date 9.1.2 Date directives
directives, literal 9.1.3 Literal directives
directives, time 9.1.1 Time directives
directory check 4.3.1 File type tests
directory components, printing 6.2 dirname: Strip non-directory suffix from a file name
directory, stripping from file names 6.1 basename: Strip directory and suffix from a file name
dirname 6.2 dirname: Strip non-directory suffix from a file name
disabling special characters 7.2.6 Special characters
displaying text 3.1 echo: Print a line of text
division 4.4.2 Numeric expressions
do nothing, successfully 4.2 true: Do nothing, successfully
dsusp 7.2.6 Special characters

E
echo 3.1 echo: Print a line of text
echo 7.2.4 Local settings
echoctl 7.2.4 Local settings
echoe 7.2.4 Local settings
echok 7.2.4 Local settings
echoke 7.2.4 Local settings
echonl 7.2.4 Local settings
echoprt 7.2.4 Local settings
effective uid and gid, printing 8.1 id: Print real and effective uid and gid
effective UID, printing 8.3 whoami: Print effective user id
eight-bit characters 7.2.1 Control settings
eight-bit characters 7.2.5 Combination settings
eight-bit input 7.2.2 Input settings
ek 7.2.5 Combination settings
env 10.1 env: Run a command in a modified environment
environment variables, printing 7.3 printenv: Print all or some environment variables
environment, preserving 10.4 su: Run a command with substitute user and group id
environment, printing 10.1 env: Run a command in a modified environment
environment, running a program in a modified 10.1 env: Run a command in a modified environment
eof 7.2.6 Special characters
eol 7.2.6 Special characters
eol2 7.2.6 Special characters
epoch, seconds since 9.1.1 Time directives
equal string check 4.3.4 String tests
erase 7.2.6 Special characters
evaluation of expressions 4.4 expr: Evaluate expressions
even parity 7.2.1 Control settings
evenp 7.2.5 Combination settings
examples of date 9.1.6 Examples of date
examples of expr 4.4.4 Examples of expr
executable file check 4.3.2 Access permission tests
existence-of-file check 4.3.3 File characteristics tests
exit status commands 4 Conditions
exit status of expr 4.4 expr: Evaluate expressions
exit status of pathchk 6.3 pathchk: Check file name portability
exit status of printenv 7.3 printenv: Print all or some environment variables
exit status of true 4.1 false: Do nothing, unsuccessfully
exit status of true 4.2 true: Do nothing, successfully
exit status of tty 7.4 tty: Print file name of terminal on standard input
expr 4.4 expr: Evaluate expressions
expression evaluation 4.3 test: Check file types and compare values
expression evaluation 4.4 expr: Evaluate expressions
expressions, numeric 4.4.2 Numeric expressions
expressions, string 4.4.3 String expressions

F
failure exit status 4.1 false: Do nothing, unsuccessfully
false 4.1 false: Do nothing, unsuccessfully
fascism 10.4 su: Run a command with substitute user and group id
ffn 7.2.3 Output settings
fields, padding numeric 9.1 date: Print or set system date and time
file characteristics tests 4.3.3 File characteristics tests
file name manipulation 6 File name manipulation
file name pattern expansion, disabled 10.4 su: Run a command with substitute user and group id
file names, checking validity and portability 6.3 pathchk: Check file name portability
file names, stripping directory and suffix 6.1 basename: Strip directory and suffix from a file name
file type tests 4.3.1 File type tests
flow control, hardware 7.2.1 Control settings
flow control, software 7.2.2 Input settings
flushing, disabling 7.2.4 Local settings
formatting times 9.1 date: Print or set system date and time

G
getdate.y 9.1.5 Options for date
globbing, disabled 10.4 su: Run a command with substitute user and group id
Greenwich Mean Time 9.1.5 Options for date
group wheel, not supported 10.4 su: Run a command with substitute user and group id
groups 8.4 groups: Print group names a user is in

H
hangups, immunity to 10.3 nohup: Run a command immune to hangups
hard link check 4.3.3 File characteristics tests
hardware flow control 7.2.1 Control settings
hardware type 9.2 uname: Print system information
hat notation for control characters 7.2.4 Local settings
help, online 2 Common options
history 1 Introduction
HOME 10.4 su: Run a command with substitute user and group id
hostname 9.2 uname: Print system information
hostname 9.3 hostname: Print or set system name
hup[cl] 7.2.1 Control settings

I
icanon 7.2.4 Local settings
icrnl 7.2.2 Input settings
id 8.1 id: Print real and effective uid and gid
idle time 8.6 who: Print who is currently logged in
iexten 7.2.4 Local settings
ignbrk 7.2.2 Input settings
igncr 7.2.2 Input settings
ignpar 7.2.2 Input settings
imaxbel 7.2.2 Input settings
immunity to hangups 10.3 nohup: Run a command immune to hangups
index 4.4.3 String expressions
information, about current users 8.6 who: Print who is currently logged in
inlcr 7.2.2 Input settings
inpck 7.2.2 Input settings
input settings 7.2.2 Input settings
intr 7.2.6 Special characters
introduction 1 Introduction
invocation of commands, modified 10 Modified command invocation
isig 7.2.4 Local settings
ispeed 7.2.7 Special settings
istrip 7.2.2 Input settings
iuclc 7.2.2 Input settings
ixany 7.2.2 Input settings
ixoff 7.2.2 Input settings
ixon 7.2.2 Input settings

K
kill 7.2.6 Special characters

L
last day 9.1.5 Options for date
lcase 7.2.5 Combination settings
LCASE 7.2.5 Combination settings
leading directory components, stripping 6.1 basename: Strip directory and suffix from a file name
length 4.4.3 String expressions
line 7.2.7 Special settings
line settings of terminal 7.2 stty: Print or change terminal characteristics
LINES 7.2.7 Special settings
literal directives 9.1.3 Literal directives
litout 7.2.5 Combination settings
lnext 7.2.6 Special characters
local settings 7.2.4 Local settings
logical and operator 4.3.6 Connectives for test
logical and operator 4.4.1 Relations for expr
logical connectives 4.3.6 Connectives for test
logical connectives 4.4.1 Relations for expr
logical or operator 4.3.6 Connectives for test
logical or operator 4.4.1 Relations for expr
login name, printing 8.2 logname: Print current login name
login sessions, printing users with 8.5 users: Print login names of users currently logged in
login shell 10.4 su: Run a command with substitute user and group id
login shell, creating 10.4 su: Run a command with substitute user and group id
login time 8.6 who: Print who is currently logged in
logname 8.2 logname: Print current login name
LOGNAME 10.4 su: Run a command with substitute user and group id
lowercase, translating to output 7.2.3 Output settings

M
machine type 9.2 uname: Print system information
machine-readable stty output 7.2 stty: Print or change terminal characteristics
manipulation of file names 6 File name manipulation
match 4.4.3 String expressions
matching patterns 4.4.3 String expressions
message status 8.6 who: Print who is currently logged in
min 7.2.7 Special settings
MIT AI lab Why GNU su does not support the ‘wheel’ group
modem control 7.2.1 Control settings
modified command invocation 10 Modified command invocation
modified environment, running a program in 10.1 env: Run a command in a modified environment
modifying scheduling priority 10.2 nice: Run a command with modified scheduling priority
multiplication 4.4.2 Numeric expressions

N
name of operating system 9.2 uname: Print system information
named pipe check 4.3.1 File type tests
network node name 9.2 uname: Print system information
newer-than file check 4.3.3 File characteristics tests
newline echoing after kill 7.2.4 Local settings
newline, echoing 7.2.4 Local settings
newline, translating to crlf 7.2.3 Output settings
newline, translating to return 7.2.2 Input settings
next day 9.1.5 Options for date
nice 10.2 nice: Run a command with modified scheduling priority
nl 7.2.5 Combination settings
nln 7.2.3 Output settings
no-op 4.2 true: Do nothing, successfully
node name 9.2 uname: Print system information
noflsh 7.2.4 Local settings
nohup 10.3 nohup: Run a command immune to hangups
nohup.out 10.3 nohup: Run a command immune to hangups
nohup.out 10.3 nohup: Run a command immune to hangups
non-directory suffix, stripping 6.2 dirname: Strip non-directory suffix from a file name
nonempty file check 4.3.3 File characteristics tests
nonzero-length string check 4.3.4 String tests
not-equal string check 4.3.4 String tests
numeric expressions 4.4.2 Numeric expressions
numeric field padding 9.1 date: Print or set system date and time
numeric tests 4.3.5 Numeric tests

O
ocrnl 7.2.3 Output settings
odd parity 7.2.1 Control settings
oddp 7.2.5 Combination settings
ofdel 7.2.3 Output settings
ofill 7.2.3 Output settings
olcuc 7.2.3 Output settings
older-than file check 4.3.3 File characteristics tests
onlcr 7.2.3 Output settings
onlret 7.2.3 Output settings
onocr 7.2.3 Output settings
operating system name 9.2 uname: Print system information
operating system release 9.2 uname: Print system information
operating system version 9.2 uname: Print system information
opost 7.2.3 Output settings
options for date 9.1.5 Options for date
or operator 4.3.6 Connectives for test
or operator 4.4.1 Relations for expr
ospeed 7.2.7 Special settings
output settings 7.2.3 Output settings
owned by effective gid check 4.3.2 Access permission tests
owned by effective uid check 4.3.2 Access permission tests

P
pad character 7.2.3 Output settings
pad instead of timing for delaying 7.2.3 Output settings
padding of numeric fields 9.1 date: Print or set system date and time
parenb 7.2.1 Control settings
parentheses for grouping 4.4 expr: Evaluate expressions
parity 7.2.5 Combination settings
parity errors, marking 7.2.2 Input settings
parity, ignoring 7.2.2 Input settings
parmrk 7.2.2 Input settings
parodd 7.2.1 Control settings
parsing date strings 9.1.5 Options for date
pass8 7.2.5 Combination settings
passwd entry, and su shell 10.4 su: Run a command with substitute user and group id
PATH 10.1 env: Run a command in a modified environment
PATH 10.4 su: Run a command with substitute user and group id
pathchk 6.3 pathchk: Check file name portability
pattern matching 4.4.3 String expressions
permission tests 4.3.2 Access permission tests
pipe fitting 5.1 tee: Redirect output to multiple files
portable file names, checking for 6.3 pathchk: Check file name portability
POSIX.2 1 Introduction
print name of current directory 7.1 pwd: Print working directory
print system information 9.2 uname: Print system information
print terminal file name 7.4 tty: Print file name of terminal on standard input
printenv 7.3 printenv: Print all or some environment variables
printf 3.2 printf: Format and print data
printing all or some environment variables 7.3 printenv: Print all or some environment variables
printing current user information 8.6 who: Print who is currently logged in
printing current usernames 8.5 users: Print login names of users currently logged in
printing groups a user is in 8.4 groups: Print group names a user is in
printing real and effective uid and gid 8.1 id: Print real and effective uid and gid
printing text 3.1 echo: Print a line of text
printing text, commands for 3 Printing text
printing the current time 9.1 date: Print or set system date and time
printing the effective UID 8.3 whoami: Print effective user id
printing the hostname 9.3 hostname: Print or set system name
printing user’s login name 8.2 logname: Print current login name
priority, modifying 10.2 nice: Run a command with modified scheduling priority
prterase 7.2.4 Local settings
pwd 7.1 pwd: Print working directory

Q
quit 7.2.6 Special characters

R
raw 7.2.5 Combination settings
read from stdin and write to stdout and files 5.1 tee: Redirect output to multiple files
readable file check 4.3.2 Access permission tests
real uid and gid, printing 8.1 id: Print real and effective uid and gid
redirection 5 Redirection
regular expression matching 4.4.3 String expressions
regular file check 4.3.1 File type tests
relations, numeric or string 4.4.1 Relations for expr
release of operating system 9.2 uname: Print system information
remainder 4.4.2 Numeric expressions
remote hostname 8.6 who: Print who is currently logged in
repeated output of a string 3.3 yes: Print a string until interrupted
restricted shell 10.4 su: Run a command with substitute user and group id
return, ignoring 7.2.2 Input settings
return, translating to newline 7.2.2 Input settings
return, translating to newline 7.2.3 Output settings
root, becoming 10.4 su: Run a command with substitute user and group id
rows 7.2.7 Special settings
rprnt 7.2.6 Special characters
RTS/CTS flow control 7.2.1 Control settings

S
same file check 4.3.3 File characteristics tests
sane 7.2.5 Combination settings
scheduling priority, modifying 10.2 nice: Run a command with modified scheduling priority
seconds since the epoch 9.1.1 Time directives
set-group-id check 4.3.2 Access permission tests
set-user-id check 4.3.2 Access permission tests
setting the hostname 9.3 hostname: Print or set system name
setting the time 9.1.4 Setting the time
SHELL 10.4 su: Run a command with substitute user and group id
size 7.2.7 Special settings
sleep 11.1 sleep: Delay for a specified time
socket check 4.3.1 File type tests
software flow control 7.2.2 Input settings
special characters 7.2.6 Special characters
special settings 7.2.7 Special settings
speed 7.2.7 Special settings
start 7.2.6 Special characters
sticky bit check 4.3.2 Access permission tests
stop 7.2.6 Special characters
stop bits 7.2.1 Control settings
strftime and date 9.1 date: Print or set system date and time
string expressions 4.4.3 String expressions
string tests 4.3.4 String tests
strip directory and suffix from file names 6.1 basename: Strip directory and suffix from a file name
stripping non-directory suffix 6.2 dirname: Strip non-directory suffix from a file name
stty 7.2 stty: Print or change terminal characteristics
su 10.4 su: Run a command with substitute user and group id
substitute user and group ids 10.4 su: Run a command with substitute user and group id
substr 4.4.3 String expressions
subtraction 4.4.2 Numeric expressions
successful exit 4.2 true: Do nothing, successfully
suffix, stripping from file names 6.1 basename: Strip directory and suffix from a file name
super-user, becoming 10.4 su: Run a command with substitute user and group id
supplementary groups, printing 8.4 groups: Print group names a user is in
susp 7.2.6 Special characters
swtch 7.2.6 Special characters
symbolic link check 4.3.1 File type tests
symbolic links and pwd 7.1 pwd: Print working directory
syslog 10.4 su: Run a command with substitute user and group id
system context 9 System context
system information, printing 9.2 uname: Print system information
system name, printing 9.3 hostname: Print or set system name

T
tabn 7.2.3 Output settings
tabs 7.2.5 Combination settings
tandem 7.2.2 Input settings
tee 5.1 tee: Redirect output to multiple files
TERM 10.4 su: Run a command with substitute user and group id
terminal check 4.3.1 File type tests
terminal file name, printing 7.4 tty: Print file name of terminal on standard input
terminal lines, currently used 8.6 who: Print who is currently logged in
terminal settings 7.2 stty: Print or change terminal characteristics
test 4.3 test: Check file types and compare values
text, displaying 3.1 echo: Print a line of text
time 7.2.7 Special settings
time directives 9.1.1 Time directives
time formats 9.1 date: Print or set system date and time
time setting 9.1.4 Setting the time
time units 11.1 sleep: Delay for a specified time
time, printing or setting 9.1 date: Print or set system date and time
tomorrow 9.1.5 Options for date
tostop 7.2.4 Local settings
true 4.2 true: Do nothing, successfully
tty 7.4 tty: Print file name of terminal on standard input
Twenex Why GNU su does not support the ‘wheel’ group
two-way parity 7.2.1 Control settings

U
u, and disabling special characters 7.2.6 Special characters
uname 9.2 uname: Print system information
uppercase, translating to lowercase 7.2.2 Input settings
USER 10.4 su: Run a command with substitute user and group id
user id, switching 10.4 su: Run a command with substitute user and group id
user information, commands for 8 User information
user name, printing 8.2 logname: Print current login name
usernames, printing current 8.5 users: Print login names of users currently logged in
users 8.5 users: Print login names of users currently logged in
utmp 8.2 logname: Print current login name

V
valid file names, checking for 6.3 pathchk: Check file name portability
version number, finding 2 Common options
version of operating system 9.2 uname: Print system information
vtn 7.2.3 Output settings

W
werase 7.2.6 Special characters
wheel group, not supported 10.4 su: Run a command with substitute user and group id
who 8.6 who: Print who is currently logged in
who am i 8.6 who: Print who is currently logged in
whoami 8.3 whoami: Print effective user id
working context 7 Working context information
working directory, printing 7.1 pwd: Print working directory
writable file check 4.3.2 Access permission tests
write, allowed 8.6 who: Print who is currently logged in

X
xcase 7.2.4 Local settings
XON/XOFF flow control 7.2.2 Input settings

Y
yes 3.3 yes: Print a string until interrupted
yesterday 9.1.5 Options for date

Z
zero-length string check 4.3.4 String tests

Jump to:   !   %   &   *   +   -   .   /   <   =   >   \   |  
A   B   C   D   E   F   G   H   I   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

[Top] [Contents] [Index] [ ? ]

Table of Contents


[Top] [Contents] [Index] [ ? ]

About This Document

This document was generated on September 19, 2022 using texi2html 5.0.

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ << ] FastBack Beginning of this chapter or previous chapter 1
[ < ] Back Previous section in reading order 1.2.2
[ Up ] Up Up section 1.2
[ > ] Forward Next section in reading order 1.2.4
[ >> ] FastForward Next chapter 2
[Top] Top Cover (top) of document  
[Contents] Contents Table of contents  
[Index] Index Index  
[ ? ] About About (help)  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:


This document was generated on September 19, 2022 using texi2html 5.0.