who - display who is on the system
who [-mu] -s [-bHlprt] [ file ]
who [-mTu] [-abdHlprt] [ file ]
who -qn x [ file ]
who am i
who am I
who 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, and must have the filename end
with the letter x) is examined. Usually, file will be /var/adm/wtmpx,
which contains a history of all the logins since the file was last
Note that who shows only users of ttys and it does not report any logged
in users who are simply running X applications from their desktop menus.
who with the am i or am I operands identifies the invoking user.
With options, who can list logins, logoffs, reboots, and changes to the
system clock, as well as other processes spawned by the init process.
These options are:
-u This option 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
(roughly, the last time something was written on that 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 /etc/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 on.
-T This option is the same as the -u option, except that the state of
the terminal line is printed. The state describes whether someone
else can write to that terminal. A + appears if the terminal is
writable by anyone; a - appears if it is not. root can write to
all lines having a + or a - in the state field. If a bad line is
encountered, a ? is printed.
-l This option 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 This option outputs only information about the current terminal.
-H This option will print column headings above the regular output.
-q This is a quick who, displaying only the names and the number of
users currently logged on. When this option is used, all other
options are ignored.
-p This option lists any other process which 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 /etc/inittab. The state,
line, and idle fields have no meaning. The comment field shows the
id field of the line from /etc/inittab that spawned this process.
-d This option 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(2)],
of the dead process. This can be useful in determining why a
-b This option indicates the time and date of the last reboot.
-r This option indicates the current run-level of the init process.
In addition, it produces the current state, the number of previous
times the system had been in the current state, and the previous
state under the idle, pid, and comment headings, respectively.
-t This option indicates the last change to the system clock (via the
date command) by root. See su(1M).
-a This option processes /var/adm/utmpx or the named file with all
options turned on.
-s This option is the default and lists only the name, line, and time
-n x This option takes a numeric argument, x, which specifies the number
of users to display per line. x must be at least 1. The -n option
must be used with -q.
Note to privileged users: after a shutdown to the single-user state, who
returns a prompt; the reason is that 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. who am i, however, returns the correct
ENVIRONMENT VARIABLES [Toc] [Back]
The following environment variables affect the execution of who:
LANG provide a default value for the internationalization variables that
are unset or null. If LANG is unset or null the corresponding value
from the implementation-specific default locale will be used. If any
of the internationalization variables contains an invalid setting,
the utility will behave as if none of the variables had been
if set to a non-empty string value, override the values of all the
other internationalization variables.
determine the locale for the interpretation of sequences of bytes of
text data as characters (for example, single - as opposed to multibyte
- characters in arguments).
determine the locale that should be used to affect the format and
contents of diagnostic messages written to standard error.
determine the location of message catalogs for the processing of
The general format for output is:
name <b>[state<b>] line time <b>[idle<b>] [pid<b>] [comment<b>] [exit<b>]
The name, line, and time information is produced by all options except
-q; the state information is produced only by -T; the idle and pid
information is produced only by -u, -l, and -T; and the comment and exit
information is produced only by -a. The information produced for -p, -d,
and -r is explained during the discussion of each option.
The following format is used for the -T option:
"%s %c %s %s\n", <name>, <terminal state>, <terminal name>, <time of
where <terminal 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
The following exit values are returned:
0 successful completion
>0 an error occurred
w(1) and who(1) can report different idle times for the same line. w
will report the time elapsed since input occurred, while who will report
the time elapsed since output occurred (roughly speaking). If there is a
job running that produces output, the idle times will differ between the
babylon: who -Hu
NAME LINE TIME IDLE PID COMMENTS root
ttyd1 Jul 6 10:37 . 1955 alt console
User tty from login@ idle JCPU PCPU what root d1
10:37am 5:54 23 23 tail -f SYSLOG
language-specific message file [See LANG on environ (5).]
date(1), login(1), mesg(1), su(1M), init(1M), inittab(4), utmpx(4),
PPPPaaaaggggeeee 4444 [ Back ]