A Quick Guide to the Linux who
Command: Showing Logged-in Users
The who
command is an essential tool for displaying the users logged in to the Linux system. Whether you are using a personal computer or a server with multiple users, this command provides valuable information about active sessions.
In most cases, as a single user on a personal computer, you will likely be the only one logged in. However, if you have opened multiple shells or terminal windows, each instance will be counted as a separate access, and who
will display these details accordingly.
Here is an example output of the who
command:
1 | $ who |
The displayed information includes the username, the terminal name (pts/0
and pts/1
in this case), and the date and time when the session started.
To obtain more detailed information, you can use the -aH
flags with the who
command. This will include additional details such as idle time and the process ID (PID) of the terminal:
1 | $ who -aH |
Here, the output tells us that the first user (pts/0
) is still logged in, while the second user (pts/1
) has been idle for 5 minutes.
Additionally, you can use the special who am i
command to retrieve details about the current terminal session:
1 | $ who am i |
The output provides the same information as the regular who
command but is specifically limited to the current user.
It’s important to note that the who
command is not limited to Linux systems. It works seamlessly on macOS, Windows Subsystem for Linux (WSL), and any UNIX-based environment. So, regardless of your setup, you can rely on who
to keep track of the logged-in users.
tags: [“Linux commands”, “who command”, “logged-in users”, “system administration”, “terminal session”]