The who and w commands are both used to display information about users currently logged into a Unix-like system, but they provide different levels of detail and context. Here’s a breakdown of their differences:
who Command
- Purpose: Displays a list of users currently logged into the system.
- Output: Shows basic information such as the username, terminal (TTY), login time, and the originating IP address or hostname.
- Use Case: Useful for quickly checking who is logged in without additional details about their activity.
Example Output:
labex pts/0 2023-10-01 10:00 (192.168.1.5)
w Command
- Purpose: Provides a more detailed view of logged-in users, including their current activity.
- Output: Displays the username, terminal, login time, idle time, JCPU (time used by all processes), PCPU (time used by the current process), and the command currently being executed by each user.
- Use Case: Useful for monitoring user activity and system load, as it shows what users are doing in real-time.
Example Output:
10:05:01 up 1:00, 1 user, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
labex pts/0 192.168.1.5 10:00 1.00s 0.01s 0.00s w
Summary of Differences
- Detail Level:
whoprovides basic login information, whilewincludes detailed activity and system load. - Usefulness: Use
whofor a quick check of logged-in users andwfor monitoring user activity and system performance.
If you have any further questions or need clarification on these commands, feel free to ask!
