What it does
who reads the login records (utmp) and lists the current sessions: user, terminal (tty1, pts/0 …), login time and the remote address for SSH logins.
With options it also shows the last boot time, the runlevel, or only a count. who am i (or who -m) shows only your own session.
How to write it
who [OPTION]... [FILE | ARG1 ARG2]Options 16
Most used
Nothing matches this filter.
Examples 11
$ run as a normal user# run as root (or with sudo)
1Who is logged in?
who student tty2 2026-10-25 08:10 (tty2) admin pts/0 2026-10-25 09:02 (192.168.122.1)tty = local console, pts = terminal window or SSH (with the client address).
2With headings and idle times
who -HuThe IDLE column shows how long a session has been quiet.
3When did the system boot?
who -b system boot 2026-10-25 07:58Same idea as
uptime -s.4Count the users
who -q student admin # users=2Quick number for a status script.
5Show only my own session
who am i admin pts/0 2026-10-25 09:02 (192.168.122.1)Shows from where you are connected.
6Check for unexpected SSH sessions (security)
who | grep -v '192.168.122.'Sessions from outside your admin network deserve a look.
7Who accepts messages
who -T+=writeandwallmessages reach the user.8Show the current runlevel / target
who -r"run-level 5" means the graphical target; 3 = multi-user (text).
9Warn everyone before a reboot
who | wc -l; wall "Reboot in 5 minutes"See how many people are online, then send a message.
10List users with the DNS name of their client
who --lookupReadable names instead of IPs (if reverse DNS exists).
11Compare with the history of logins
who; last -n 5who= now,last= history.
Nothing matches this filter.
Watch out
whoonly shows sessions that write login records. Some tools (likessh host command) do not create one.
Files
/var/run/utmp- The current sessions.
/var/log/wtmp- The history (used by last).
Tips to remember
- who = now, last = before, w = now + what they do.