Cheatsheets
HomeWriteupsResourcesCheatsheets
Linux
Linux
  • Know Yourself and Your System
    • id
    • logname
    • uname
    • w
    • who
    • whoami
  • Surfing / Knowing Your File System
    • cd
    • df
    • du
    • ls
    • pwd
    • stat
    • tree
  • Knowing About Files / Commands
    • alias
    • file
    • info
    • whatis
    • apropos
    • man
    • help
    • history
    • script
  • Manipulating Files / Directories
    • touch
    • mkdir
    • rm
    • rmdir
    • cp
    • mv
    • ln
  • Interacting with Files
    • cat
    • head
    • less
    • middle
    • more
    • tail
  • STROPS / Text Manipulation
    • awk
    • cut
    • grep
    • jq
    • join
    • paste
    • sed
    • sort
    • tr
    • uniq
    • xargs
    • xclip
    • wc
    • tee
    • echo
    • comm
    • diff
    • patch
    • aspell
    • Combos
  • Formatting the Output
    • nl
    • fold
    • fmt
    • pr
    • printf
  • Searching / Finding
    • find
    • locate
    • which
    • whereis
    • type
  • Web Interaction
    • curl
    • wget
  • xxd
  • References
Powered by GitBook
On this page
  • Introduction
  • Syntax
  • Important Flags
  • Examples

Was this helpful?

  1. Know Yourself and Your System

w

w linux command cheatsheet by Thamizhiniyan C S

PreviousunameNextwho

Last updated 12 months ago

Was this helpful?

Introduction

This command is used to show who is logged on and what they are doing.


Syntax

w [options] [user]

Using the w command without any additional options produces an output similar to this:

Source:

The first line of the output shows system information:

  • System time: The current system time.

  • Up time: How long the system has logged in.

  • Number of users: The number of users currently logged in.

  • Average system load: The average number of jobs running on the system in the last 1, 5, and 15 minutes, respectively.

The second line shows user and process information:

  • USER: The names of currently logged in users.

  • TTY: The name of the terminal the user is logging in from.

  • LOGIN@: The time the user logged in, in a 24-hour format.

  • IDLE: The time since the user last used the terminal; displays ?xdm? if the user is currently active.

  • PCPU: Elapsed time for the user's current process.

  • WHAT: The name of the user's current process.


Important Flags

Flag
Description

-h, --no-header

Print output without the header.

-u, --no-current

Ignore username when calculating current process times and load.

-s, --short

Print output in the short format.

-f, --from

Toggle printing the FROM (remote hostname) field.

--help

Display help text.

-i, --ip-addr

Replace the hostname in the FROM field with the IP address.

-V, --version

Display current command version.

-o, --old-style

Print old-style output (blank space for idle times shorter than 1 minute).


Examples

Command
Description

Display the short format version of the w command output.

List the w command output without printing the header.

Ignore usernames when calculating current process and CPU times.

Check the current version of the w command.

Display the user's IP address in the FROM field.

Display the output in the old style, leaving blank spaces for short idle times.

Toggle the FROM field in the w command output.

Display the w command output for a specific user.

Display all the available options for the w command.

FROM: The name or of the terminal or host the user is logging in from.

JCPU: The total run time of all attached to the user's terminal.

w -s
w -h
w -u
w -V
w -i
w -o
w -f
w [username]
w --help
IP address
system processes
https://phoenixnap.com/kb/w-command-in-linux
Elements of the w command output