who(1)
NAME
who − who is on the system
SYNOPSIS
who [-muTlHqpdbrtasAcR] [file]
who am i
who am I
DESCRIPTION
who can list the user’s name, terminal line, login time, elapsed time since input activity occurred on the line, the user’s host name, and the process-ID of the command interpreter (shell) for each current system user. It examines the /etc/utmp file to obtain its information. If file is given, that file is examined. Usually, file is /etc/wtmp, which contains a history of all the logins since the file was last created.
who with the am i or am I option identifies the invoking user.
Except for the default -s option, the general format for output entries is:
name [state] line time activity pid [comment] [exit]
With options, who can list logins, logoffs, reboots, and changes to the system clock, as well as other processes spawned by the init process.
Options
-m Output only information about the current terminal. This option is equivalent to the am i and am I options described above.
-u Lists only those users who are currently logged in. name is the user’s login name. line is the name of the line as found in directory /dev. The time field indicates when the user logged in.
activity is the number of hours and minutes since input 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 login process. 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, etc. If no such information is found, then who prints, as the comment, the user’s host name as it was stored in the /etc/utmp or named file. Note that the user’s host name is printed instead of comments from the /etc/inittab file if the -u option is used in conjunction with the -R option.
-T Same as the -u option, except that the state of the terminal line is printed. 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 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.
-H Prints column headings above the regular output.
-q A quick who, displaying only the names and the number of users currently logged in. When this option is used, all other options are ignored.
-p 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 activity fields have no meaning. The comment field shows the id field of the line from /etc/inittab that spawned this process. See inittab(4).
-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 of the dead process (as returned by wait() — see wait(2)). This can be useful in determining why a process terminated.
-b Indicates the time and date of the last reboot.
-r Indicates the current run-level of the init process. The last three fields contain the current state of init , the number of times that state has been previously entered, and the previous state. These fields are updated each time init changes to a different run state.
-t Indicates the last change to the system clock (via the date command) by root. See su(1).
-a Processes /etc/utmp or the named file with all options turned on.
-s (default) Lists only the name, line, and time fields.
-A When the /etc/wtmp file is specified, this option indicates when the accounting system was turned on or off using the startup or shutacct commands (see acctsh(1M)). The name field is .. The line field is acctg on, acctg off, or a reason that was given as an option to the shutacct command. The time is the time that the on/off activity occurred.
-c Displays information about an entire SM HP Cluster. If file is given and is context dependent (see cdf(4)), data from all elements of the CDF are displayed. If file is given and is not a CDF, the -c option has no effect.
-R Displays the user’s host name. If the user is logged in on a tty, who displays the string returned from gethostname() (see gethostname(2)). If the user is not logged in on a tty and the host name stored in the /etc/utmp or named file has not been truncated when stored (meaning that the entire host name was stored with no loss of information), it is displayed as it was stored. Otherwise, the gethostbyaddr() function is called with the internet address of the host (see gethostent(3N)). The host name returned by gethostbyaddr() is displayed unless it returns an error, in which case the truncated host name is displayed.
EXTERNAL INFLUENCES
Environment Variables
LC_TIME determines the format and contents of date and time strings.
If LC_TIME is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG. If any internationalization variable contains an invalid setting, who behaves as if all internationalization variables are set to "C". See environ(5).
International Code Set Support
Single-byte character code sets are supported.
EXAMPLES
Check who is logged in on the system:
who
Check whether or not you can write to the terminal that another user is using:
who -T
and look for a plus (+) after the user ID.
AUTHOR
who was developed by AT&T and HP.
FILES
/etc/inittab
/etc/utmp
/etc/wtmp
SEE ALSO
date(1), login(1), init(1), mesg(1), su(1), gethostname(2), wait(2), gethostent(3N), cdf(4), inittab(4), utmp(4).
STANDARDS CONFORMANCE
who: SVID2, XPG2, XPG3
Hewlett-Packard Company — HP-UX Release 9.0: August 1992