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

20. User information

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


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

20.1 id: Print user identity

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. In addition, if SELinux is enabled and the POSIXLY_CORRECT environment variable is not set, then print `context=c', where c is the security context.

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 group ID and 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.

`-Z'
`--context'

Print only the security context of the current user. If SELinux is disabled then print a warning and set the exit status to 1.

An exit status of zero indicates success, and a nonzero value indicates failure.

Primary and supplementary groups for a process are normally inherited from its parent and are usually unchanged since login. This means that if you change the group database after logging in, id will not reflect your changes within your existing login session. Running id with a user argument causes the user and group database to be consulted afresh, and so will give a different result.


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

20.2 logname: Print current login name

logname prints the calling user's name, as found in a system-maintained file (often `/var/run/utmp' or `/etc/utmp'), and exits with a status of 0. If there is no 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.

An exit status of zero indicates success, and a nonzero value indicates failure.


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

20.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.

An exit status of zero indicates success, and a nonzero value indicates failure.


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

20.4 groups: Print group names a user is in

groups prints the names of the primary and any supplementary groups for each given username, or the current process if no names are given. If more than one name is given, the name of each user is printed before the list of that user's groups and the user name is separated from the group list by a colon. Synopsis:

 
groups [username]…

The group lists are equivalent to the output of the command `id -Gn'.

Primary and supplementary groups for a process are normally inherited from its parent and are usually unchanged since login. This means that if you change the group database after logging in, groups will not reflect your changes within your existing login session. Running groups with a list of users causes the user and group database to be consulted afresh, and so will give a different result.

The only options are `--help' and `--version'. See section Common options.

An exit status of zero indicates success, and a nonzero value indicates failure.


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

20.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 a system-maintained file (often `/var/run/utmp' or `/etc/utmp'). If a file argument is given, users uses that file instead. A common choice is `/var/log/wtmp'.

The only options are `--help' and `--version'. See section Common options.

An exit status of zero indicates success, and a nonzero value indicates failure.


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

20.6 who: Print who is currently logged in

who prints information about users who are currently logged on. 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 a default system-maintained file (often `/var/run/utmp' or `/etc/utmp') as the name of the file containing the record of users logged on. `/var/log/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'.

Time stamps are listed according to the time zone rules specified by the TZ environment variable, or by the system default rules if TZ is not set. See (libc)TZ Variable section `Specifying the Time Zone with TZ' in The GNU C Library Reference Manual.

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

`-a'
`--all'

Same as `-b -d --login -p -r -t -T -u'.

`-b'
`--boot'

Print the date and time of last system boot.

`-d'
`--dead'

Print information corresponding to dead processes.

`-H'
`--heading'

Print a line of column headings.

`-l'
`--login'

List only the entries that correspond to processes via which the system is waiting for a user to login. The user name is always `LOGIN'.

`--lookup'

Attempt to canonicalize hostnames found in utmp through a DNS lookup. This is not the default because it can cause significant delays on systems with automatic dial-up internet access.

`-m'

Same as `who am i'.

`-p'
`--process'

List active processes spawned by init.

`-q'
`--count'

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

`-r'
`--runlevel'

Print the current (and maybe previous) run-level of the init process.

`-s'

Ignored; for compatibility with other versions of who.

`-t'
`--time'

Print last system clock change.

`-u'

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

`-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

An exit status of zero indicates success, and a nonzero value indicates failure.


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

This document was generated on January, 20 2010 using texi2html 1.76.