Linux / Unix: w Command Examples

Linux / Unix: w Command Examples

The w command is a utility that displays information about the users who are currently logged into the system.

To use the w command, you can simply type w at the command prompt and press Enter. This will display a list of users who are currently logged into the system, along with the following information:

  • The username of the user.
  • The terminal or console that the user is logged in on.
  • The remote hostname or IP address from which the user is logged in (if applicable).
  • The login time of the user.
  • The current time.
  • The elapsed time since the user logged in.
  • The current working directory of the user.
  • The command that the user is currently running.

For example:

refe‮ot r‬:lautturi.com
$ w
 22:24:03 up  6:34,  2 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
user1    tty1                      22:24    ?xdm?  3:20   0.00s /usr/lib/gdm3/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu gnome-session --session=ubuntu
user2    tty2    localhost         22:24    6:34   0.00s  0.00s -bash

This will display the list of users user1 and user2 who are currently logged into the system, along with the information about their terminal, login time, elapsed time, current working directory, and current command.

The w command also displays the current time and the system uptime.

The w command has several options that allow you to customize the output. For example, you can use the -h option to suppress the display of the header, or the -f option to display the full user name and domain name of the users.

For more information about the w command and its options, you can consult the documentation for your specific Unix or Linux system.

Created Time:2017-10-29 22:09:00  Author:lautturi