الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

w

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

المستوى
لينكس اليومي
المجموعة
المستخدمون والمجموعات
يحتاج root
لا
الحزمة
procps-ng

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

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).

طريقة الكتابة

w [OPTIONS] [USER]

الخيارات 10

الأكثر استخدامًا

-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.

أمثلة 11

$ مستخدم عادي# بصلاحية root (أو مع 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.

نصائح للحفظ

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