[/donotprint] This command is useful to find out the following information:
Time of last system boot.
Current run level.
List of logged in users and more.
Display who is on the system.
The basic syntax is as follows:
who who am i who [options] [File] who --help who --version who | grep 'userNameHere'
If no non-options provided, who displays the following information for each user currently logged on:
remote hostname or X display
If you give one non-option argument, who uses that instead of a default system-maintained file such s /var/run/utmp as the name of the file containing the record of users logged on.
If given two non-option arguments, who prints only the entry for the user running it preceded by the hostname. Traditionally, the two arguments given are ‘am i’, as in ‘who am i’.
who command examples
To show a list of all the users currently logged in to the system, type: $ who Sample outputs:
The sample output in this example shows that the user vivek is logged in on pts/0, and has been on since 14:10 on 27 January. To display line of column headings pass the -H option: $ who -H To show only hostname and user associated with stdin (usually keyboard), enter: $ who -m To show active processes spawned by init: $ who -p To show user’s message status as +, – or ?, enter: $ who -T
Show or list users logged in
Type the command: $ who -u
Show time of last system boot
To display time of last system boot pass the -b option to who command: $ who -b Sample outputs:
system boot 2014-01-05 10:02
The output in this example, shows that the system was booted since 10:02 on 05 January.
Show dead processes on the system
You need pass the -d option to who command: $ who -d OR $ who -d -H Sample outputs:
The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.