Linux is a multi‑user operating system, which means several people can be logged in at the same time locally, remotely, or through different terminals. As a system administrator, knowing how many users are online helps you troubleshoot performance issues, monitor activity, and manage sessions more effectively. Linux provides several built‑in commands that make this easy.
What Does “Users Online” Mean in Linux?
When we talk about “users online,” we are referring to accounts that have an active session on the system. This can include users connected through SSH, working on a local terminal, or logged in through remote tools. Linux records all login activity, and the system commands below help you view this information quickly.
Basic Commands to Find Logged‑In Users
Below are the most useful commands for checking user activity. Each command serves a slightly different purpose.
1. who – Show Active Login Sessions
The who command lists all users currently logged in and their session details.
Example: who
What it shows:
- Username
- Terminal/TTY
- Login time
- Remote host (if applicable)
2. w – Show Logged‑In Users with Activity
w provides a more detailed view, showing both user logins and what each user is doing.
Example: w
What it shows:
- Logged‑in users
- Idle time
- CPU usage
- Commands currently running
3. users – Quick List of Logged‑In Users
users gives a simple, space‑separated list of usernames.
Example: users
Useful when: You only need the usernames without additional details.
4. last – View Recent Login History
While not limited to current sessions, last helps you review previous logins and reboots.
Example: last
Useful for: Auditing user access over time.
5. whoami – Display the Current User
This command shows the username of the session you’re in right now.
Example: whoami
How to Count the Number of Active Users
To see the number of logged‑in users, you can combine commands with simple shell utilities.
1. Count using users + wc:
users | wc -w
2. Count using who + wc:
who | wc -l
3. Count unique users:
who | awk ‘{print $1}’ | sort -u | wc -l
Checking Detailed Information About User Sessions
Linux also stores session data in special system files:
/var/run/utmp– current logins/var/log/wtmp– login history/var/log/btmp– failed login attempts
Some commands read from these files automatically, so you rarely need to access them directly.
Monitoring Remote Users (SSH)
To specifically see SSH users:
who | grep pts
Or check SSH sessions with:
ss -t -a | grep ssh
Getting Help for User Monitoring Commands
Linux provides built‑in help for all commands:
- man who
- man w
- man users
Or use:
- <command> –help
This gives you additional examples and command‑specific options.
Conclusion
Linux offers several quick and reliable ways to check who is currently online. Commands like who, w, and users help you see active sessions, while tools like last show login history. Whether you’re monitoring an SSH server or managing multiple users on a shared machine, these built‑in commands give you everything you need to track user activity effectively.
Discover How to Rename Files in Linux – Master File Management with Our Easy-to-Follow Tutorial!