`w` vs`who` commands.
In Unix-like operating systems, the w
and the who
are command-line utilities used to display information about users currently logged into the system.
While they achieve similar objectives, their level of detail and information varies.
🎧
Here's a breakdown of the differences between the two:
w
Command
The w
command provides a more detailed overview of the system's current state, including information about users and their actions.
Here's an example:
$ w
23:05:03 up 25 days, 3:24, 3 users, load average: 0.23, 0.35, 0.61
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
snub pts/0 192.168.1.3 11:23 1:03m 0.00s 0.00s bash
monkey pts/1 192.168.1.4 11:34 3:11m 0.01s 0.01s ssh
ghost pts/2 192.168.1.5 20:09 4:15m 0.02s 0.02s ssh
- Time and Uptime: Displays the current time, how long the system has been running (uptime), and the number of users logged in.
- Load Average: Shows the system's load average for the past 1, 5, and 15 minutes.
- USER: The username of the logged-in user.
- TTY: The terminal associated with the user session.
- FROM: The remote host or IP address from where the user is logged in.
- LOGIN@: The time when the user logged in.
- IDLE: The idle time (how long since the user last interacted with the terminal).
- JCPU: The total CPU time used by all processes attached to the terminal.
- PCPU: The CPU time used by the current process.
- WHAT: The command currently being executed by the user.
who
Command
The who
command provides a simpler and more focused output, showing who is currently logged into the system.
Here's an example:
$ who
snub pts/0 2024-07-04 11:23 (192.168.1.3)
monkey pts/1 2024-07-04 11:34 (192.168.1.4)
ghost pts/2 2024-07-04 20:09 (192.168.1.5)
- USER: The username of the logged-in user.
- TTY: The terminal associated with the user session.
- DATE and TIME: The date and time when the user logged in.
- HOST: The remote host or IP address from where the user is logged in (if applicable).
Comparison
- Detail Level:
w
: Provides more detailed information about system load, user activity, and processes.who
: Provides basic information about users who are currently logged in.
- Use Cases:
w
: Useful for administrators who need a quick overview of system activity, including what users are doing and the system load.who
: Useful for quickly checking which users are currently logged into the system without additional details.
Using Options:
w
with options:
w -h # Hide the header
w -s # Short format, does not display JCPU and PCPU times
who
with options:
who -b # Show the last system boot time
who -m # Show information only about the current terminal
who -q # Quick output, only displays usernames and number of users
By understanding the differences between the w
and who
commands, you can choose the one that best fits the level of detail you need regarding logged-in users and system activity.
Thanks for checking in, and we hope this tip was helpful!