Skip to main content

Module 6: User & Permission Management

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

3. Print Login Names and Total Number of Users

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’