The “w” command in Linux is used to display information about the currently logged-in users and their activities. It provides a summary of various details such as the username, terminal, login time, idle time, and the current process being executed by each user.
Here is the basic syntax of the “w” command:
w [options]
Here are some practical examples of how to use the “w” command:
- Display information about currently logged-in users:
w
Running the “w” command without any options will display a summary of information about all currently logged-in users. It shows details such as the username, terminal, remote host (if applicable), login time, idle time, JCPU (total CPU time used by all processes), PCPU (CPU time used by the current process), and the current command or process being executed.
Example:
15:48:27 up 1 day, 4:52, 4 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
john tty1 - 14:22 3:25m 0.20s 0.02s sshd: john [priv]
jane pts/0 :0.0 14:35 1:20m 0.12s 0.12s /usr/bin/gnome-shell
jacob pts/1 192.168.0.10 14:48 2:34 0.15s 0.15s vi myscript.sh
alex pts/2 :0.0 15:10 5:36 0.05s 0.05s bash
In this example, the “w” command displays information about the currently logged-in users, including their usernames, terminals, login times, idle times, and the commands or processes they are running.
- Display information for a specific user:
w username
Replace “username” with the actual username of the user you want to check. This command will display information specifically for that user.
Example:
$ w jane
15:48:27 up 1 day, 4:52, 4 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
jane pts/0 :0.0 14:35 1:20m 0.12s 0.12s /usr/bin/gnome-shell
In this example, the “w” command displays information specifically for the user “jane”.
The “w” command provides a quick overview of the logged-in users and their activities, making it useful for system administrators or users who want to monitor user sessions, check idle times, or identify active processes associated with specific users.