green and black digital device

Understanding the ‘who’ Command in Linux

When it comes to working with the Linux operating system, there are numerous commands that can help you navigate and manage your system efficiently. One such command is the ‘who’ command. In this blog post, we will explore the ‘who’ command and its various uses.

What is the ‘who’ command?

The ‘who’ command in Linux is a simple yet powerful tool that allows you to view information about users who are currently logged into your system. It provides details such as the username, terminal, login time, and remote IP address. This information can be extremely useful, especially when you need to keep track of multiple users or troubleshoot any issues.

How to use the ‘who’ command

Using the ‘who’ command is straightforward. Simply open your terminal and type ‘who’ followed by the enter key. The command will display a list of currently logged in users along with their respective details.

For example:

$ who
user1  tty1    2021-07-15 09:30
user2  pts/0   2021-07-15 10:15 (192.168.1.100)
user3  pts/1   2021-07-15 11:00 (192.168.1.101)

In the above example, we can see that there are three users currently logged in. User1 is logged in on tty1, while user2 and user3 are logged in through remote connections via IP addresses 192.168.1.100 and 192.168.1.101, respectively.

Additional options

The ‘who’ command also supports various options that allow you to customize the output according to your needs. Here are a few commonly used options:

  • -a: Displays information about all users, including system users.
  • -b: Displays the time of the last system boot.
  • -d: Shows the dead processes that have not been cleaned up.
  • -q: Displays only the number of users currently logged in.
  • -r: Shows the current runlevel of the system.

To use these options, simply append them to the ‘who’ command. For example, to display information about all users, you can use the following command:

$ who -a

This will provide you with a detailed list of all users, including system users.

Conclusion

The ‘who’ command in Linux is a valuable tool for keeping track of users who are currently logged into your system. By providing essential information such as usernames, terminals, login times, and IP addresses, it helps you monitor user activity and troubleshoot any issues. Additionally, the ‘who’ command offers various options to customize the output according to your requirements.

Next time you need to check who is using your Linux system, give the ‘who’ command a try and see how it simplifies the process.


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *