How to list all users who are currently logged into the Linux system?

LinuxOpen SourceOperating System

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.

Syntax

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
1-a, --all
Same as -b -d --login -p -r -t -T -u
2-b, --boot
Display last rebooted time of system
3-d, --dead
Display dead processes and details
4-H, --heading
Display line of column headings
5-l, --login
Display system login processes
6--lookup
Attempt to canonicalize hostnames via DNS
7-q, --count
Display all login names and number of users logged on
8-s, --short
Display only name of user, line, and time (default)
9-t, --time
Display last system clock change
10-T, -w, --mesg
Add user’s message status as +, - or ?
11-u, --users
Display list users logged in
12--message
Same as -T
13--writable
Same as -T
14--help
Displays a help message and then exits.
15--version
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

Or

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
raja
Published on 01-Jul-2021 14:17:18
Advertisements