w command tutorial in linux/unix with examples and use cases

linux w command – Show who is logged on and what they are doing.

The header displays three parts of information:
1. The current time, how long the system has been running.
2. How many users are currently logged on.
3. The system load averages for the past 1, 5, and 15 minutes.

The following entries are displayed for each user:
1. login name
2. the tty name
3. the remote host
4. login time
5. idle time
6. JCPU
7. PCPU
8. The command line of their current process

The JCPU time is the time used by all processes attached to the tty. It does not include past background jobs, but does include currently running background jobs.
The PCPU time is the time used by the current process, named in the “what” field.

Syntax

w [options] user [...]

Options

  • -h, –no-header
    Don’t print the header.
  • -u, –no-current
    Ignores the username while figuring out the current process and cpu times. To demonstrate this, do a “su” and do a “w” and a “w -u”.
  • -s, –short
    Use the short format. Don’t print the login time, JCPU or PCPU times.
  • -f, –from
    Toggle printing the from (remote hostname) field.
  • –help
    Display help text and exit.
  • -i, –ip-addr
    Display IP address instead of hostname for from field.
  • -V, –version
    Display version information.
  • -o, –old-style
    Old style output. Prints blank space for idle times less than one minute.
  • user
    Show information about the specified user only.

Related system files

  • /var/run/utmp
    information about who is currently logged on
  • /proc
    process information

examples

Show current user

➜  ~ w

Do not display header information

➜  ~ w -h

Do not display the from field

➜  ~ w -f 

Display the short format

➜  ~ w -s

Add a Comment

Your email address will not be published.