I am a new Linux and Unix system user. How do I display who is logged on my Linux or Unix-like operating system using shell prompt?
You need to use who command to display users who are currently logged in your server.
who command details | |
---|---|
Description | Find who is on the system |
Category | User Environment |
Difficulty level | Easy |
Root privileges | No |
OS compatibility | FreeBSD • Linux • macOS • NetBSD • OpenBSD • Unix • WSL |
Est. reading time | 4 minutes |
This command is useful to find out the following information:
- Time of last system boot.
- Current run level.
- List of logged in users and more.
Purpose
Display who is on the system.
Syntax
The basic syntax is as follows:
who who am i who [options] [File] who --help who --version who | grep 'userNameHere'
Where,
- If no non-options provided, who displays the following information for each user currently logged on:
- login name
- terminal line
- login time
- remote hostname or X display
- If you give one non-option argument, who uses that instead of a default system-maintained file such s /var/run/utmp as the name of the file containing the record of users logged on.
- If given two non-option arguments, who prints only the entry for the user running it preceded by the hostname. Traditionally, the two arguments given are ‘am i’, as in ‘who am i’.
who command examples
To show a list of all the users currently logged in to the system, type:
$ who
Sample outputs:
$ who -H
To show only hostname and user associated with stdin (usually keyboard), enter:
$ who -m
To show active processes spawned by init:
$ who -p
To show user’s message status as +, – or ?, enter:
$ who -T
Show or list users logged in
Type the command:
$ who -u
Show time of last system boot
To display time of last system boot pass the -b option to who command:
$ who -b
Sample outputs:
system boot 2014-01-05 10:02
The output in this example, shows that the system was booted since 10:02 on 05 January.
Show dead processes on the system
You need pass the -d option to who command:
$ who -d
OR
$ who -d -H
Sample outputs:
NAME LINE TIME IDLE PID COMMENT EXIT pts/1 2014-01-11 09:17 56094 id=ts/1 term=0 exit=0 pts/2 2014-01-05 15:46 11070 id=ts/2 term=0 exit=0 pts/2 2014-01-08 03:31 3614 id=/2 term=0 exit=0 pts/1 2014-01-11 16:54 64559 id=/1 term=0 exit=0 pts/3 2014-01-11 17:13 15818 id=/3 term=0 exit=0 pts/4 2014-01-25 11:02 46807 id=ts/4 term=0 exit=0
Show system login processes
To just display system login processes pass the -l option:
$ who -l
OR
$ who -l -H
Sample outputs:
NAME LINE TIME IDLE PID COMMENT LOGIN tty2 2014-01-05 10:03 8750 id=2 LOGIN tty1 2014-01-05 10:03 8748 id=1 LOGIN tty3 2014-01-05 10:03 8752 id=3 LOGIN /dev/ttyS1 2014-01-05 10:03 8747 id=v/tt LOGIN tty4 2014-01-05 10:03 8754 id=4 LOGIN tty5 2014-01-05 10:03 8756 id=5 LOGIN tty6 2014-01-05 10:03 8758 id=6
Count all login names and number of users logged on the system
To count all login names and number of users logged on:
$ who -q
Sample outputs:
Display the current runlevel
To display the current system runlevel, type:
$ who -r
Sample outputs:
run-level 3 2014-01-05 10:02
You can combine -r and -b options as follows:
$ who -r -b
Sample outputs:
system boot 2014-01-05 10:02 run-level 3 2014-01-05 10:02
Display all
The -a is same as same as -bdprtTu options as discussed earlier:
Sample outputs:
NAME LINE TIME IDLE PID COMMENT EXIT system boot 2014-01-05 10:02 run-level 3 2014-01-05 10:02 LOGIN tty2 2014-01-05 10:03 8750 id=2 LOGIN tty1 2014-01-05 10:03 8748 id=1 LOGIN tty3 2014-01-05 10:03 8752 id=3 LOGIN /dev/ttyS1 2014-01-05 10:03 8747 id=v/tt LOGIN tty4 2014-01-05 10:03 8754 id=4 LOGIN tty5 2014-01-05 10:03 8756 id=5 LOGIN tty6 2014-01-05 10:03 8758 id=6 root + pts/0 2014-01-27 03:37 . 11149 (10.1.6.120) pts/1 2014-01-11 09:17 56094 id=ts/1 term=0 exit=0 pts/2 2014-01-05 15:46 11070 id=ts/2 term=0 exit=0 pts/2 2014-01-08 03:31 3614 id=/2 term=0 exit=0 pts/1 2014-01-11 16:54 64559 id=/1 term=0 exit=0 pts/3 2014-01-11 17:13 15818 id=/3 term=0 exit=0 pts/4 2014-01-25 11:02 46807 id=ts/4 term=0 exit=0
who command options
Option | Description |
-a | Same as -b -d –login -p -r -t -T -u |
-b | Time of last system boot |
-d | Print dead processes |
-H | Print line of column headings |
-l | Print system login processes |
-m | Only hostname and user associated with stdin |
-p | Print active processes spawned by init |
-q | All login names and number of users logged on |
-r | Print current runlevel |
-t | Print last system clock change |
-T | Add user’s message status as +, – or ? |
-u | List users logged in |
Related media
This tutorial is also available in a quick video format:
Summing up
You learned about who command that show information about users who are currently logged in your Linux or Unix machine. Please read the following manual pages using the man command or help command:
man who who --help
See also
- /var/run/utmp file.
- /var/log/wtmp file.
🥺 Was this helpful? Please add a comment to show your appreciation or feedback.
How would check the top logins? For example; if you have to figure out the top 5 logins, what would be the script?
who tee users .log |wc-1
Clear my phone storage & remove wallpaper
Please 🙏
What? You are commenting on the wrong post. Want to clear or change the Android wallpaper? See this page https://guidebooks.google.com/android/customizeyourphone/changeyourwallpaper
For the storage under Android, see this page https://support.google.com/android/answer/7431795?hl=en
Are you using iOS for Apple? Try
wallpaper https://support.apple.com/en-us/HT200285
Storage https://support.apple.com/en-sg/HT201656