描述

The who utility can list the user's name, terminal line, login time,
elapsed time since activity occurred on the line, and the process-ID of
the command interpreter (shell) for each current UNIX system user. It examines
the /var/adm/utmpx file to obtain its information. If file is given, that file
(which must be in utmpx(4) format) is examined. Usually, file will be /var/adm/wtmpx,
which contains a history of all the logins since the file was
last created.

选项

Displays all processes that have expired and not been respawned by init. The exit field appears for dead processes and contains the termination and exit values (as returned by wait(3C)), of the dead process. This can be useful in determining why a process terminated.

-H

Outputs column headings above the regular output.

-l

Lists only those lines on which the system is waiting for someone to login. The name field is LOGIN in such cases. Other fields are the same as for user entries except that the state field does not exist.

-m

Outputs only information about the current terminal.

-nx

Takes a numeric argument, x, which specifies the number of users to display per line. x must be at least 1. The -n option can only be used with -q.

-p

Lists any other process that is currently active and has been previously spawned by init. The name field is the name of the program executed by init as found in /usr/sbin/inittab. The state, line, and idle fields have no meaning. The comment field shows the id field of the line from /usr/sbin/inittab that spawned this process. See inittab(4).

-q

(Quick who) Displays only the names and the number of users currently logged on. When this option is used, all other options are ignored.

-r

Indicates the current run-level of the init process.

-s

(Default) Lists only the name, line, and time fields.

/usr/bin/who

-T

Same as the -s option, except that the stateidle, pid, and comment, fields are also written. state is one of the following characters:

+

The terminal allows write access to other users.

-

The terminal denies write access to other users.

?

The terminal write-access state cannot be determined.

/usr/xpg4/bin/who

-T

Same as the -s option, except that the state field is also written. state is one of the characters listed under the /usr/bin/who version of this option. If the -u option is used with -T, the idle time is added to the end of the previous format.

-t

Indicates the last change to the system clock (using the date utility) by root. See su(1M) and date(1).

-u

Lists only those users who are currently logged in. The name is the user's login name. The line is the name of the line as found in the directory /dev. The time is the time that the user logged in. The idle column contains the number of hours and minutes since activity last occurred on that particular line. A dot (.) indicates that the terminal has seen activity in the last minute and is therefore current. If more than twenty-four hours have elapsed or the line has not been used since boot time, the entry is marked old. This field is useful when trying to determine whether a person is working at the terminal or not. The pid is the process-ID of the user's shell. The comment is the comment field associated with this line as found in /usr/sbin/inittab (see inittab(4)). This can contain information about where the terminal is located, the telephone number of the dataset, type of terminal if hard-wired, and so forth.

操作数

The following operands are supported:

ami

amI

In the C locale, limits the output to describing the invoking user, equivalent to the -m option. The am and i or I must be separate arguments.

file

Specifies a path name of a file to substitute for the database of logged-on users that who uses by default.

环境变量

See environ(5) for descriptions of the following environment variables that affect the
execution of who: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, LC_TIME, and NLSPATH.

另请参见

附注

Superuser: After a shutdown to the single-user state, who returns a prompt.
Since /var/adm/utmpx is updated at login time and there is no login
in single-user state, who cannot report accurately on this state. The command, whoam i, however, returns the correct information.