The who command without 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.
[root@server1 ~]# who -b
system boot 2017-04-14 17:48
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