Table of Contents
In this article, we will look into 15 popular who command examples on Linux. Usually, there are plenty of tools available on a Linux based system to check the currently logged in users. Some of the tool includes w, lslogins, users, last and who command. While we will see other utilities in later articles, here we will keep our focus on who tool only. We will see some real world examples below to know more about the usage of who command in Linux.
Synopsis
who [OPTION]... [ FILE | ARG1 ARG2 ]
who command examples on Linux
Also Read: 9 Useful wall command examples on Linux{Displays a Message}
Example 1: How to Check who command version
If you want to check who utility version then you need to run who --version
command as shown below.
root@localhost:~# who --version who (GNU coreutils) 8.30 Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Joseph Arceneaux, David MacKenzie, and Michael Stone.
Example 2: How to Use who command on Linux
You can simply run who
command to check currently logged in users. It will display information like name of logged in users, terminal information, time of login etc as displayed below.
root@localhost:~# who cyberithub :0 2021-06-04 21:10 (:0) cyberithub pts/2 2021-06-05 08:47 (192.168.29.241)
Example 3: How to Check Currently Logged On Users
If you want to check all currently logged in users with their login terminal information then you need to use who -a command as shown below.
root@localhost:~# who -a system boot 2021-06-04 21:08 run-level 5 2021-06-04 21:09 cyberithub ? :0 2021-06-04 21:10 ? 1259 (:0) pts/1 2021-06-05 08:56 2048 id=ts/1 term=0 exit=0 cyberithub - pts/2 2021-06-05 08:47 . 2494 (192.168.29.241)
Example 4: How to System Last Boot Time
If you want to check your System last boot time then you need to use who -b
command as shown below.
root@localhost:~# who -b system boot 2021-06-04 21:08
Example 5: How to Show all the Dead Processes
If you want to show all the dead processes, then you need to use who -d
command as shown below.
root@localhost:~# who -d pts/1 2021-06-05 08:56 2048 id=ts/1 term=0 exit=0
Example 6: How to Show Lines of Column Heading
If you want to check lines of column heading then you need to use who -H
command as shown below.
root@localhost:~# who -H NAME LINE TIME COMMENT cyberithub :0 2021-06-04 21:10 (:0) cyberithub pts/2 2021-06-05 08:47 (192.168.29.241)
Example 7: How to Show all the System Login Processes
If you want to show all the system login processes then you need to use who -l command as shown below.
root@localhost:~# who -l
Example 8: How to Show Active Processes Spawned by init
If you want to check all the active processes spawned by init then you need to use who -p
command as shown below.
root@localhost:~# who -p
Example 9: How to Show Current Run Level
If you want to check current run level, then you need to use who -r
command as shown below.
root@localhost:~# who -r run-level 5 2021-06-04 21:09
Example 10: How to Show the Count of all logged in Users
If you want to check the count of all currently logged in users then you need to use who -q
command as shown below.
root@localhost:~# who -q cyberithub cyberithub # users=2
Example 11: How to Show hostname and user associated with stdin
If you want to show hostname and user associated with stdin then you need to use who -m
command as shown below. More on who command Man Page.
root@localhost:~# who -m cyberithub pts/2 2021-06-05 08:47 (192.168.29.241)
Example 12: How to Show Last System Clock Change
If you want to show last system clock change, then you need to use who -t
command as shown below.
root@localhost:~# who -t
Example 13: How to Show List of Currently Logged In Users
If you want to check list of currently logged in users then you need to use who -u
command as shown below.
root@localhost:~# who -u cyberithub :0 2021-06-04 21:10 ? 1259 (:0) cyberithub pts/2 2021-06-05 08:47 . 2494 (192.168.29.241)
Example 14: How to Check all the options available with who command
If you want to check all the options available with who command then you need to use who --help
command as shown below.
root@localhost:~# who --help Usage: who [OPTION]... [ FILE | ARG1 ARG2 ] Print information about users who are currently logged in. -a, --all same as -b -d --login -p -r -t -T -u -b, --boot time of last system boot -d, --dead print dead processes -H, --heading print line of column headings --ips print ips instead of hostnames. with --lookup, canonicalizes based on stored IP, if available, rather than stored hostname -l, --login print system login processes --lookup attempt to canonicalize hostnames via DNS -m only hostname and user associated with stdin -p, --process print active processes spawned by init
Example 15: How to Check Man Page of who command
If you want to check the man page of who command then you need to run man who
command as shown below.
root@localhost:~# man who WHO(1) User Commands WHO(1) NAME who - show who is logged on SYNOPSIS who [OPTION]... [ FILE | ARG1 ARG2 ] DESCRIPTION Print information about users who are currently logged in. -a, --all same as -b -d --login -p -r -t -T -u -b, --boot time of last system boot -d, --dead print dead processes -H, --heading print line of column headings