To check information about users who are currently logged into the system, we use the who command in the Linux system.
The who command is used to display the users logged into the system. The who command related to the w command that is used to display information about the users currently on the machine and their processes.
The general syntax of the who command is as follows −
who [OPTION]... [ FILE | ARGUMENT1 ARGUMENT2 ]
Brief description of options available in the who command.
|Sr.No.||Option & Description|
Same as -b -d --login -p -r -t -T -u
Display last rebooted time of system
Display dead processes and details
Display line of column headings
Display system login processes
Attempt to canonicalize hostnames via DNS
Display all login names and number of users logged on
Display only name of user, line, and time (default)
Display last system clock change
|10||-T, -w, --mesg|
Add user’s message status as +, - or ?
Display list users logged in
Same as -T
Same as -T
Displays a help message and then exits.
It gives info about the version and then exits.
To displays the name of users currently logged in, terminal line numbers, login time of the users in the system, and remote hostname of the user in the Linux system, we use the who command without any options and arguments as shown below.
vikash@tutorialspoint:~$ who vikash :0 2021-01-11 09:40 (:0)
To enhance the output and print information in standard input, we use -H option with the who command as shown in below.
vikash@tutorialspoint:~$ who -H NAME LINE TIME COMMENT vikash :0 2021-01-11 09:40 (:0)
To display the last booted time of the Linux/Unix system using the terminal, we use -b or -- boot option with the who command as shown below.
vikash@tutorialspoint:~$ who –boot System boot 2021-01-11 09:37
vikash@tutorialspoint:~$ who -b System boot 2021-01-11 09:37
To display the current login user in the Linux system, we use the whoami command without any option and arguments as shown below.
vikash@tutorialspoint:~$ whoami vikash
To display more information about the command, we use --help option with the who command as shown in below.
$ who --help