The who command in Linux tells you who is currently logged in to your system along with some other useful details. It shows a list that includes the name of the users who are currently logged in, the terminal (Line) they are using, the date and time of login, and from where they are login. You can also use it's options to display additional information about the system.The who command is a part of the GNU Core Utilities that is available on almost any Linux system. It uses the /var/run/utmp file to display information about currently logged in users. Show
In this article, we will explain the basics of who command, explain it's output, and use some of its command-line options. Basic Usage of Who CommandUsing the who command is very simple. You can start using the who command by simply calling it from the command line terminal. Who Command Output ExplainedLet’s explain the output of the who command shown in the above screenshot:
Linux Who Command OptionsThe who command has a lot of command line options to further expand it's usefulness. Some of the functionality of these options overlap with other commands. However, since who is part of the Core Utilities package, you can be sure of it's wide availability across different Linux and UNIX systems. Display Date & Time of System Last BootWith the
Display Headings above the ColumnsYou can choose to display headings above each column in the who command output. To do so, simply use the
It will help you to know what information each column is displaying. Print System Login ProcessesUsing the
Print Count and Name of All UsersUsing the
Display User’s Message StatusUsing either of the
The message status has the following meaning:
Display Idle Time of UsersThe who command can display the idle time of logged in user along with other information when using the
The output also includes the PID in the second last column which is the process ID of the login shell. This comes in handy if you want to kick a user off of a Linux system. Display Dead ProcessesUsing the
Display System’s Run LevelIn Linux, a runlevel is a mode that defines the state of the system based on a certain number of services available to them.
Display All InformationInstead of using the separate command-line options for displaying different information, you can display all information at once using the
Save Who command Output to a FileYou can save the output of who command by redirecting its output to a file. For example, the following command will save the output of who commands in a file named “samplefile”.
ConclusionThere you have the who command. In this article we have explained the basics of the who command and some of its command-line options. It is a simple command that lists information about who is logged in, where they logged in from, and when they logged in. Also, it displays a lot more useful information some of which we have discussed above. Resources
|