Bootstrap FreeKB - Linux Commands - View logged in users using the who command
Linux Commands - View logged in users using the who command

Updated:   |  Linux Commands articles

The who command can be used to:

The who commandwithout any options can be used to view the users that are logged in. The w and last commands are similar to the w command. In this example, there are two users logged in, root and john.doe. The second column shows the virtual console being used. In this example, john.doe is using /dev/pts/0 and root is using /dev/pts/1. The who command will include the date and time that the user logged into the system.

[root@server1 ~]# who
john.doe pts/0    2017-01-09  13:00 (:0)
root     pts/1    2017-01-09  12:54 (example.com)

 

The -s or --short option is exactly the same as the who command with no options.

[root@server1 ~]# who -s
john.doe pts/0    2017-01-09  13:00 (:0)
root     pts/1    2017-01-09  12:54 (example.com)

 


Header

The -H or --heading option adds a heading.

[root@server1 ~]# who
NAME  LINE     TIME                            COMMENT
john.doe pts/0    2017-01-09  13:00 (:0)
root     pts/1    2017-01-09  12:54 (example.com)

 


Add additional information

The -a or --all options can be used to add extra detail to the output. It can be helpful to include the -H option, so that you know what each new column is.

[root@server1 ~]# who -aH
NAME  LINE     TIME        IDLE   PID    COMMENT  EXIT
john.doe pts/0    2017-01-09  13:00         2891     (:0)
root     pts/1    2017-01-09  12:54  12462           (example.com)

 


Count the number of signed in users

The -q or --count option can be used to display the number of signed in users.

[root@server1 ~]# who -q
# users=2

 


Last boot

The -b or --boot option can be used to display the date and time the system was booted. Check out my article Display when system was last rebooted using the who command.

[root@server1 ~]# who --boot
system boot 2017-04-14 17:48

 

 Similarly, the uptime command can be used to show how long the system has been up.

[root@server1 ~]# uptime
02:37:41 up 1 day, 23:55, 1 user, load average: 0.05, 0.06, 0.14

 


Runlevel

The -r or --runlevel option can be used to display the current system runlevel.

[root@server1 ~]# who -r
run-level 3 2017-04-14 17:49

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


January 21 2023 by Isad9489@gmail.com
mmm

Add a Comment


Please enter 8fc46a in the box below so that we can be sure you are a human.