w Command

The w command in Linux is used to display information about the users currently logged on to the machine, and what they are doing. It provides a quick overview of system activity, including uptime, load averages, and details about each logged-in user's session.

Syntax

w [options] [user]

Description

w shows information about the users currently on the machine, and their processes. The header shows the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

For each user, it displays:

  • USER: The login name of the user.
  • TTY: The terminal device name.
  • FROM: The remote host from which the user is logged in.
  • LOGIN@: The time the user logged in.
  • IDLE: The idle time (time since last input).
  • JCPU: Time used by all processes attached to the tty.
  • PCPU: Time used by the current process.
  • WHAT: The current command line being executed by the user.

Common Options

Option Description
-h, --no-header Don't print the header line.
-u, --no-current Ignores the username while figuring out the current process and cpu times.
-s, --short Use the short format. Don't print the JCPU and PCPU times, or the LOGIN@ and IDLE times.
-f, --from Display the from (remote host) field.
-o, --old-style Old style output, as in uptime.

Examples

Show all logged-in users and their activity

w

Displays a summary of who is logged in and what they are doing.

Show information for a specific user

w username

Displays activity for a particular user.

Display short format output (no JCPU/PCPU)

w -s

Provides a more concise output, omitting some CPU time columns.

Display without header

w -h

Useful for scripting when you only need the user data.

Display from (remote host) field

w -f

Shows the remote host from which each user is logged in.

See also