Which command lists all users currently on system: A Comprehensive Guide
For anyone managing a computer system, especially those running on Linux or macOS, knowing who is currently logged in is a fundamental task. Whether you're a system administrator troubleshooting an issue, a developer checking on resource usage, or simply a curious user, understanding the command to list active users can be incredibly useful. So, to directly answer the question: Which command lists all users currently on system?
The most common and widely used command for this purpose on Linux and macOS is the who command.
Understanding the who Command
The who command displays information about users who are currently logged in to the system. It provides a snapshot of who is online, when they logged in, and from where they connected.
Basic Usage of who
Simply typing who in your terminal will give you a list of logged-in users. The output typically includes the following columns:
- Username: The login name of the user.
- Terminal: The terminal device the user is connected to (e.g.,
tty1for a local console,pts/0for a pseudo-terminal usually used for SSH or graphical terminal emulators). - Login Time: The date and time when the user logged in.
- Remote Host (optional): If the user logged in from another machine (e.g., via SSH), this will show the hostname or IP address of the remote system.
Here's an example of what the output might look like:
john pts/0 2026-10-27 10:30 (192.168.1.100)
jane tty1 2026-10-27 09:15
admin pts/1 2026-10-27 11:05 (server.example.com)
Variations and Useful Options for who
The who command is quite flexible and offers several options to refine the output:
who -a (Show All Information)
This option displays all available information about users, including details about system boot times and idle times. It's often more verbose than the standard output.
who -b (Show Boot Time)
This option displays the time the system was last booted. This can be helpful to understand how long the system has been running.
who -r (Show Run Level)
This shows the current run level of the system. Run levels are a concept in older Unix-like systems indicating different states of the system (e.g., single-user mode, multi-user mode with networking).
who -u (Show Idle Time and PID)
This option adds information about how long the user has been idle (indicated by a "." if active or a timestamp if idle) and the process ID (PID) of their login shell.
who -H (Show Header)
This option prints a header line above the user information, making the columns more readable.
Other Commands to Consider
While who is the primary command, there are other related commands that can provide similar or complementary information:
w Command
The w command is similar to who but provides more detailed information, including what each user is currently doing. It combines the functionality of who with the output of the uptime command.
The output of w typically includes:
- System uptime and current load average.
- A list of logged-in users with their login name, terminal, remote host, login time, idle time, JCPU (time used by all processes attached to the terminal), and PCPU (time used by the current process).
- The current command being executed by each user.
Using w is often preferred when you need to understand not just who is logged in, but also what they are actively working on.
users Command
The users command is a simpler command that just lists the login names of all users currently logged into the system, one after another, separated by spaces. It doesn't provide details like login times or terminals.
Example output:
john jane admin
Checking System User Accounts (Not Just Logged-in Users)
It's important to distinguish between users *currently logged in* and users *created on the system*. To see a list of all user accounts that exist on the system (whether they are logged in or not), you typically look at the /etc/passwd file. You can view this file using commands like cat /etc/passwd or less /etc/passwd.
Each line in /etc/passwd represents a user account and contains information like username, user ID, group ID, home directory, and default shell.
Conclusion
In summary, when you need to know Which command lists all users currently on system, the who command is your go-to tool. For more detailed insights, including what users are actively doing, the w command is an excellent choice. And for a quick list of just the usernames, users suffices. Understanding these commands is a key step in navigating and managing your system effectively.
Frequently Asked Questions (FAQ)
Q: How can I see who is logged in remotely via SSH?
The who command will show this information. When a user logs in via SSH, the terminal column will typically show pts/X (where X is a number), and the remote host column will display the IP address or hostname of the machine they connected from.
Q: Why would I need to know who is logged in?
Knowing who is logged in is crucial for system administration. It helps in monitoring system activity, identifying potential unauthorized access, troubleshooting performance issues by seeing which users are consuming resources, and managing user sessions.
Q: How do I see users who are always on the system, not just currently logged in?
To see all user accounts that exist on the system, you need to look at the user database, usually found in the /etc/passwd file. Commands like cat /etc/passwd or less /etc/passwd will display this information.
Q: What's the difference between who and w?
The who command primarily lists who is logged in, their terminal, and login time. The w command is more comprehensive; it provides the same information as who but also includes system uptime, load averages, idle times, and the current command each user is running.

