Sometimes, while working on the command line, you might want to know more about logged in users. There exists a command line utility who which you can
Sometimes, while working on the command line, you might want to know more about logged in users. There exists a command line utility who which you can use to access this kind of information. In this tutorial, we will discuss the basics of who using some easy to understand examples.
But before we do that, it’s worth mentioning that all examples here have been tested on Ubuntu 16.04 LTS.
As already mentioned, the who command shows who all are logged in. Here’s its syntax:
who [OPTION]… [ FILE | ARG1 ARG2 ]
And following is what the tool’s man page says about it:
Print information about users who are currently logged in.
Following are some Q&A-styled examples that will give you a good idea on how this utility works.
Q1. How who command works?
Basic usage is pretty straightforward – just execute the ‘who‘ command.
For example, on my system, the following output was produced:
And on a server machine, following output was produced:
So the outputs basically shows user ‘himanshu’ and ‘ubuntu’ logged in on tty7 and pts/0 (respectively) on February 16 at 09:07 and 09:35 (respectively). The last column shows IP address related information.
Q2. How to access time of last system boot?
For this, use the -b command line option.
This info can be accessed using the -d command line option.
Q4. How to print system login processes?
For this, use the -l command line option.
Q5. How to print active processes spawned by init?
To display all the init-spawned, active processes, use the -p command line option.
Q6. How to print number of users logged in?
In case you want to print names of all users logged in as well as the total count, use the -q command line option.
Q7. How to print last system clock change?
To print the last system clock change, use the -t command line option.
To print the current run level value, use the -r command line option.
As you’d agree, the who command is pretty easy to understand and use. It does provide a lot of command line options, but the learning curve isn’t steep at all. We’ve discussed the majority of options here. When you’re done practicing these, you can learn more about the tool by heading to its man page.
Share this page: