Lesson 58: who Command
In this lesson, you'll learn how to use the who command to display information about users currently logged on to a Linux system.
The who command displays users who are currently logged on to a Linux system, including the terminals they are connecting from.
Let's discuss some useful examples of the who command for its better understanding.
who Command Syntax
The basic syntax for using the who command is as follows:
$ who [OPTION]... [FILE | ARG1 ARG2]
who Command Options
| Option | Description |
|---|---|
-H |
Print the heading of the columns displayed |
-q |
Print the login names and total number of logged-on users |
-m |
Show only the hostname and user associated with stdin |
-T |
Add the user's message status as +, -, or ? |
-b |
View the time of the last system boot |
-u |
List logged-on users alongside other information |
-r |
Show the current run level |
-d |
Print dead processes |
-p |
Show active processes spawned by init |
-a |
Print default output combined with information from all options |
1. Display Currently Logged-on Users
If you run the who command without any arguments, it will display account information (user login name, user's terminal, time of login, as well as the host the user is logged in from) on your system, similar to the following output.
# who
ubuntu tty2 2023-09-28 12:47 (tty2)
ubuntu pts/1 2023-10-01 18:56
2. Print Column Headings
To print the heading of the columns displayed, use the -H flag as shown.
# who -H
NAME LINE TIME COMMENT
ubuntu tty2 2023-09-28 12:47 (tty2)
ubuntu pts/1 2023-10-01 18:56