Introduction
In the world of Linux, the ‘w’ command is a handy tool for viewing information about users who are currently logged into the system. This information includes the username, terminal, host they are connected from, login time, idle time, JCPU (time used by the system) and PCPU (time used by the process). Let’s dive deeper into how to use this command effectively.
Syntax
The syntax for the ‘w’ command is quite simple. Just type ‘w’ in the terminal and hit enter. This will display a list of users currently logged in, along with their details.
Example Codes
- To display a list of users currently logged in:
1
w
- To display a specific user’s information:
1
w username
- To display the header information only:
1
w -h
Explanation
- The first example code will show you a list of all users currently logged in.
- The second example code allows you to view details about a specific user by providing their username as an argument.
- The third example code will display just the header information, omitting the user details.
Versions
The ‘w’ command is available on most Linux distributions. It is a part of the GNU Core Utilities package, which is installed by default on many systems. You can use ‘man w’ to get more information about the command and its options.
Conclusion
The ‘w’ command in Linux is a useful tool for monitoring user activity on a system. By utilizing its simple syntax and options, you can easily view who is logged in, how long they have been idle, and more. Next time you need to check on user activity, give the ‘w’ command a try.