"who | w" - Logged-in Users and Their Running Commands

This section provides a tutorial example on how to display logged-in users and their running commands using 'who' and 'w' commands on Ubuntu systems.

If the system shared with other users, you may want to know who else are logged in to the system at this moment using the "who" command. Here is an examples of "who" command output on my Ubuntu computer:

herong$ who -H

NAME     LINE     TIME               COMMENT
herong   pts/0    2024-08-10 20:02   (192.168.5.1)
john     pts/1    2018-03-16 19:27   (192.168.5.9)

You can also add the "-a" option to print out more information:

herong$ who -H -a

NAME       LINE         TIME             IDLE          PID COMMENT  EXIT
           system boot  2025-09-01 07:12
           run-level 5  2025-09-01 07:12
herong   ? :0           2025-09-01 07:13   ?          1795 (:0)
...

Note that the "-a" option is a combination of "-b -d -l -p -r -t -T -u" options, which are described below:

-b    time of last system boot
-d    print dead processes
-l    print system login processes
-p    print active processes spawned by init
-r    print current runlevel
-t    print last system clock change
-T    add user's message status as +, - or ?
-u    list users logged in

If you want to see what commands are logged-in users running, you can use the "w" command:

herong$ w

 20:48:49 up 159 days,  5:52,  1 user,  load average: 0.04, 0.05, 0.02

USER   TTY   FROM        LOGIN@ IDLE  JCPU  PCPU  WHAT
herong pts/0 192.168.5.1 20:02  1.00s 0.01s 0.00s top

Table of Contents

 About This Book

Introduction to Ubuntu Systems

 What is Ubuntu

 hostnamectl - Display System Information

 "free" - Display Free and Used Memory

"who | w" - Logged-in Users and Their Running Commands

 GNOME - Desktop Interface and Environment

 Shell - The Command-Line Interpreter

 Process Management

 Memory Management

 Files and Directories

 APT (Advanced Package Tool)

 Network Connection on Ubuntu

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Administrative Tasks

 References

 Full Version in PDF/EPUB