WebMasterCampus
WEB DEVELOPER Resources

Linux who Command

Learn Linux who Command with examples


Linux who Command

In Linux, we can use “who” command prints a list of currently logged in users.

It can also show the current run level, time of the last system boot, and more.

who Command Syntax

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

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 Command Example

>> who

root     pts/0        2020-11-17 20:10 (10.10.0.1)

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.

who -H (Print Column Headings)

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

>> who -H

NAME      LINE         TIME             COMMENT
root      pts/0        2020-11-17 20:10 (10.10.0.1)

who -b Command (print the time of last system boot)

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

~$ who -b

who -d Command

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

>> who -d

who -r Command

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

>> who -r

run-level 5  2020-07-20 19:02

who -q Command

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

>> who -q

who -a Command

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

>> who -a

who -u Command

This command will help us to display the whole list of the logged-in users.

>> who -u  

who -T Command

This command will help us to display the status of the user’s message. Syntax of this command given below.

>> who -T -H  

who -p -h Command

To display information about all active processes that are spawned by the NIT process-

>> who -p -h

Who -m Command

Command to display the hostname and user associated with the input/output devices like a keyboard.

>> Who -m -H

who -l Command

To display system login process details.

>> who -l -H

whoami

To display the system’s username-

>> whoami

who Command in Linux (Documentation)

~$ man who

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

       --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

       -q, --count
              all login names and number of users logged on

       -r, --runlevel
              print current runlevel

       -s, --short
              print only name, line, and time (default)

       -t, --time
              print last system clock change

       -T, -w, --mesg
              add user's message status as +, - or ?

       -u, --users
              list users logged in

       --message
              same as -T

       --writable
              same as -T

       --help display this help and exit

       --version
              output version information and exit

       If FILE is not specified, use /var/run/utmp.  /var/log/wtmp as FILE is
       common.   If  ARG1  ARG2 given, -m presumed: 'am i' or 'mom likes' are
       usual.
Created with love and passion.