[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedAugust 14, 2023

How to use who command.

How To Use Who Command.

In this article, we explain the who command that is bundled in GNU coreutils package.

who is a command-line utility that prints a list of currently logged in users. It can also show the current run level, time of the last system boot, and more.

 

How to Use the who Command

The basic syntax for the who command is as follows:

who [OPTION]... [ FILE | ARG1 ARG2 ]

When invoked without any option or argument, the output looks something like this:

who
root     pts/0        2023-08-14 11:36 (82.79.3.187)

who will output a formatted list of all users that are currently logged on the system.

Each line contains four fields separated by one or more spaces:

  • The name of the logged user.

  • The user’s terminal.

  • The time when the user logged in.

  • The hostname or IP address from where the user is logged in. To force Ips, use the –ips option.

If you want to print the column headings, add the -H (–heading) option:

who -H
NAME     LINE         TIME             COMMENT
root     pts/0        2023-08-14 11:36 (82.79.3.187)

The command pulls information about the system and who is logged in from the /var/run/utmp file. If you want to use another file, pass the file path to the command.

who accepts two non-option arguments. When invoked with two arguments the command prints information only about the terminal associated with the current user. The same output is displayed when the -m option is used.

You can use any two arguments:

who am iwho mom lovewho foo barwho -m

Each of the commands above will print the same information:

root     pts/0        2023-08-14 11:36 (82.79.3.187)

 

who Command Options

who accepts several options that generally are rarely used.

The -b, –boot option tells who to print the time of last system boot:

who -b
         system boot  2023-06-02 14:44

To get a list of all the dead processes use the -d, –dead option:

who -d

The -r, –runlevel option, tells who to show the current runlevel:

who -r
 run-level 3  2023-06-02 14:44

To get only the user names and the number of currently logged in users, use the -q, –count option:

who -q
root
# users=1

The -a, –all option forces who to print all information:

who -a
           system boot  2023-06-02 14:44
           run-level 3  2023-06-02 14:44
LOGIN      tty1         2023-06-02 14:44               894 id=tty1
root     + pts/0        2023-08-14 11:36   .         22836 (82.79.3.187)
           pts/1        2023-07-07 17:18              1101 id=ts/1  term=0 exit=0
           pts/2        2023-08-07 14:03             21178 id=ts/2  term=0 exit=0
           pts/3        2023-07-12 16:41              6800 id=ts/3  term=0 exit=0
           pts/2        2023-08-14 11:08             22504 id=/2    term=0 exit=0
           pts/3        2023-08-14 11:09             22514 id=/3    term=0 exit=0
           pts/4        2023-08-14 11:09             22523 id=/4    term=0 exit=0
           pts/5        2023-08-14 11:09             22532 id=/5    term=0 exit=0
           pts/6        2023-08-14 11:11             22612 id=/6    term=0 exit=0
           pts/7        2023-08-14 11:11             22622 id=/7    term=0 exit=0
           pts/8        2023-08-14 11:11             22632 id=/8    term=0 exit=0
           pts/9        2023-08-14 11:11             22642 id=/9    term=0 exit=0
           pts/10       2023-08-14 11:11             22652 id=/10   term=0 exit=0
           pts/11       2023-08-14 11:14             22682 id=/11   term=0 exit=0
           pts/12       2023-08-14 11:15             22711 id=/12   term=0 exit=0
           pts/13       2023-08-14 11:18             22763 id=/13   term=0 exit=0

 

Conclusion

The who command prints a list of all currently logged in users.

Keep reading
How to Format USB Drives and SD Cards on Linux
March 14, 2023

How to Format USB Drives and SD Cards on Linux

How To Format USB Drives And SD Cards On Linux This article explains how to format a USB Drive or SD Card on Linux using the parted utility. It’s important to note that formatting is a destructive process, and it will erase all the existing data. If you have data on the UDB drive or…

Read article
How to Install and Configure an NFS Server on CentOS 8
March 14, 2023

How to Install and Configure an NFS Server on CentOS 8

How To Install And Configure An NFS Server On CentOS 8 In this tutorial, you’ll go through the steps necessary to set up an NFSv4 Server on CentOS 8. We’ll also show you how to mount an NFS file system on the client. NFS protocol is not encrypted by default, and unlike Samba, it does…

Read article
How to use dmesg command
March 14, 2023

How to use dmesg command

How To Use Dmesg Command In this tutorial, we’ll cover the basics of the dmesg command. The Linux kernel is the core of the operating system that controls access to the system resources, such as CPU, I/O devices, physical memory, and file systems. The kernel writes various messages to the kernel…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00