w
For a little more context about users, the simple w
command provides a list of who’s logged in and what they’re doing. This information is displayed in a format similar to the output of who
, but the time the user has been idle, the CPU time used by all processes attached to the login TTY, and the CPU time used by just the current process. The user’s current process is listed in the final field.
Sample output:
$ w
13:45:48 up 29 days, 19:24, 2 users, load average: 0.53, 0.52, 0.54
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
seth tty2 Sun18 43:22m 0.01s 0.01s /usr/libexec/gnome-session-binary
curly pts/2 13:02 35:12 0.03s 0.03s -bash
Alternatively, you can view the user’s IP address with the -i
or --ip-addr
option.
You can narrow the output down to a single user name by specifying which user you want information about:
$ w seth
13:45:48 up 29 days, 19:27, 2 users, load average: 0.53, 0.52, 0.54
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
seth tty2 Sun18 43:25m 0.01s 0.01s /usr/libexec/gnome-session-binary
ps
Once you know who’s logged in on your system, you can use ps
to get a snapshot of current processes.
You can get all processes being run by a single user with the --user
(or -u
) option, along with the user name of who you want a report on. To give the output the added context of which process is the parent of a child process, use the --forest
option for a “tree” view:
$ ps --forst --user larry
PID TTY TIME CMD
39707 ? 00:00:00 sshd
39713 pts/4 00:00:00 \_ bash
39684 ? 00:00:00 systemd
39691 ? 00:00:00 \_ (sd-pam)