The who command in Linux gives you information about the currently active users. In this tutorial, we will learn how to use this command. We will also learn about a list of options available along with the who command.
Let’s get started!
Running the who command without arguments
When you use the who command without any arguments, you get the following output.
The fields in the output are as follows :
- User login name.
- User’s terminal number.
- User’s last login date and time.
- Remote Host-Name of the user.
You can in fact generate the same output with headings over each column. Let’s see how to do that in the next section.
Display Output with Column Headings
To display headings over each column, use the -H flag along with who command.
We can see that the output now has column headings. Next let’s see how to get a more detailed output from who command.
Generate verbose output from who command
To generate a more detailed output use the -a flag along with who command.
Using -a flag displays all the available information for each user.
Display terminal status for each user
You can display the terminal status next to each user by using the -T flag along with who command.
Terminal status can be one of the following three :
- “+” if the terminal is writable.
- “–” f the terminal is not writable.
- “?” if a bad line is encountered.
Let’s see it in action.
Output time of last system boot
Using the who command you can also output the time of the last system boot. This is another utility that “who” provides apart from listing all the active users.
To output the time of last system boot use -b flag along with who command.
Output current user name
Lastly, you can also output the current username by running ‘whoami‘ on your terminal. Here’s a complete article on the whoami command:
This tutorial was about who command in Linux. We learned how to use this command for displaying information about currently active users. You can also display information about a particular user by using the finger command.