How to list all users who are currently logged into the Linux system?

The who command is a fundamental Linux utility used to display information about users who are currently logged into the system. It shows details such as login names, terminal lines, login times, and remote hostnames. The who command is closely related to the w command, which displays additional information about user processes.

Syntax

The general syntax of the who command is −

who [OPTION]... [ FILE | ARGUMENT1 ARGUMENT2 ]

Common Options

Option Description
-a, --all Same as -b -d --login -p -r -t -T -u
-b, --boot Display last system boot time
-d, --dead Display dead processes and details
-H, --heading Display line of column headings
-l, --login Display system login processes
-q, --count Display all login names and number of users logged on
-s, --short Display only name, line, and time (default)
-t, --time Display last system clock change
-T, -w, --mesg Add user's message status as +, −, or ?
-u, --users Display list of users logged in

Examples

Basic Usage

To display the names of users currently logged in, terminal line numbers, login time, and remote hostname −

$ who
vikash   :0           2021-01-11 09:40 (:0)
john     pts/0        2021-01-11 10:15 (192.168.1.100)
alice    pts/1        2021-01-11 11:30 (192.168.1.101)

Display with Headers

To enhance the output with column headings, use the -H option −

$ who -H
NAME     LINE         TIME             COMMENT
vikash   :0           2021-01-11 09:40 (:0)
john     pts/0        2021-01-11 10:15 (192.168.1.100)

Display System Boot Time

To display when the system was last booted −

$ who -b
         system boot  2021-01-11 09:37

Count Logged-in Users

To display only the usernames and total count of logged-in users −

$ who -q
vikash john alice
# users=3

Alternative Commands

whoami Command

To display the current login user −

$ whoami
vikash

w Command

For more detailed information including user processes −

$ w
 11:45:23 up  2:08,  3 users,  load average: 0.15, 0.20, 0.18
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
vikash   :0       :0               09:40   ?xdm?  25:43   0.01s /usr/lib/gdm3/gdm-x-session
john     pts/0    192.168.1.100    10:15    0.00s  0.05s  0.01s w
alice    pts/1    192.168.1.101    11:30    5:00   0.02s  0.02s bash

Key Points

  • The who command displays currently logged-in users without showing their running processes

  • Use -H option for better readability with column headers

  • The w command provides more comprehensive information including system load and user processes

  • Information is read from /var/run/utmp and /var/log/wtmp files

Conclusion

The who command is essential for system administrators to monitor user activity and system status. It provides quick insights into who is logged in, when they logged in, and from where they connected. Combined with options like -H for headers and -b for boot time, it becomes a powerful tool for system monitoring.

Updated on: 2026-03-17T09:01:38+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements