Definition of WHO Command in Unix
In Unix, “who” command allows to show or print the number of users who has been logged into your Unix computer system currently. The main usage of who command in Unix without command-line parameter is to show the name of the users who are logged in currently. Also, based on the Unix system, we can also get the information to print the terminal and time at which they have logged in. The who command is used to print the information about all the users who are currently logged in.
Who command in Unix is used to determine the below information:
- Time at which the last system boot was done.
- Run level of current timestamp of the system.
- List of users who are logged in to the system and many more.
How does WHO Command Work in Unix?
Usage: who [OPTION]... [ FILE | ARG1 ARG2 ]
Description: Provides the information of the users who has been logged in currently. Below are a few options and its description that are available with ‘who’ command-line.
The syntax of who command in Unix is given as below:
who [option]..[file] [am I ]
Examples of WHO Command in Unix
Following are the examples are given below:
1. No Option
Who command without any input arguments, will display system’s information like user name, login time, terminal of user, and also the host name on the system.
The above example gives the below information regarding the user:
- Name of the user who has logged in.
- line numbers in the terminal.
- time at which the user was logged in the system.
- host name of the user who has logged in.
2. Option -H
This option -H, is used to display the headings of the columns that were displayed in who command.
3. Option -q
This option will allow to display the login names and total number of users logged on the system.
4. Option -m
To display only the hostname and user linked with stdin, we can use option -m as shown below.
5. Option -b
We can see the user and time at which the system was last booted. When -b option is used with option -c, it will allow for listing of users logged in the output.
6. Option -r
To check the current processing run-level, we can use -r option as below.
7. Option -d
This option will help to determine the dead processes in the system.
To check all active processes that are INIT spawned processing.
who -p -H
8. To print system’s username
We can display the current system’s username who has logged into by the following syntax.
who am I
To print all the information regarding the current logged user.
9. Option w
‘w’ command gives us more additional information regarding the current logged user. Username, current login time, number of idle days of the users, etc. example of this option is given below:
The main usage of who command in unix without command-line parameter is to show the name of the users who are logged in currently. Also, based on the Unix system, we can also get the information to print the terminal and time at which they have logged in. The who command is used to print the information about all the users who are currently logged in.
This is a guide to WHO Command in Unix. Here we also discuss the definition and how does who command works in unix along with different examples and its code implementation. You may also have a look at the following articles to learn more –