Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

w

Show who is logged in and what each user is doing now, plus the uptime and load of the system.

Niveau
Dagelijks Linux
Groep
Gebruikers en groepen
Root nodig
Nee
Pakket
procps-ng

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

w combines uptime and who, and adds the current program of each session. The first line shows the time, how long the system is up, the number of users and the load average (1, 5 and 15 minutes).

Columns: USER, TTY, FROM (remote address), LOGIN@ (login time), IDLE, JCPU (CPU of all processes of the terminal), PCPU (CPU of the current process) and WHAT (the current command).

Zo schrijf je het

w [OPTIONS] [USER]

Opties 10

Meest gebruikt

-h, --no-header
Do not print the header lines.
-s, --short
Short format: no login time, JCPU and PCPU.
-f, --from
Show or hide the FROM column (the default depends on the build).
-i, --ip-addr
Show IP addresses instead of host names in FROM.
-p, --pids
Show the process ID of the current process.
-u, --no-current
Ignore the user name when finding the current process and CPU times.
-o, --old-style
Old output style (blank space for short idle times).
USER
Show only this user.
--help
Show help.
-V, --version
Show the version.

Voorbeelden 11

$ als gewone gebruiker# als root (of met sudo)

  1. 1Who does what?

    w
     09:12:01 up  1:14,  2 users,  load average: 0.08, 0.12, 0.10
    USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
    student  tty2     tty2             08:10    1:02m  0.05s  0.03s /usr/libexec/gnome-session-binary
    admin    pts/0    192.168.122.1    09:02    0.00s  0.04s  0.00s w

    Load average under the number of CPUs is normal.

  2. 2Only one user

    w admin

    Sessions and current commands of admin.

  3. 3Without the header, for a script

    w -h

    One line per session.

  4. 4Short form

    w -s

    Fewer columns, easier to read on a small screen.

  5. 5IP addresses instead of names

    w -i

    Useful when reverse DNS is slow or wrong.

  6. 6Show the process IDs of the current commands

    w -p

    Then you can look at a process with ps -fp PID or stop it.

  7. 7Find who runs a heavy command

    w | sort -k6 -r | head

    Sort on JCPU to see the busy sessions.

  8. 8Check the load before a big job

    w | head -1

    If the load is high, start the backup later.

  9. 9Find idle sessions to clean up

    w -h | awk '$4 ~ /days/'

    Sessions idle for days. Ask the users or end them with pkill -t pts/N.

  10. 10Spot a suspicious session (security)

    w -i | grep -v '192.168.122.'

    A login from an unknown network with a strange WHAT command needs attention.

  11. 11Compare with uptime

    uptime; w | head -1

    The first line of w is the uptime output.

Tips om te onthouden

  • w = uptime + who + what. Look at load average and WHAT.