linux查看用户登录信息-w命令

NAME
w - Show who is logged on and what they are doing.

SYNOPSIS
w - [husfV] [user]

DESCRIPTION
w displays information about the users currently on the machine, and their processes. The header shows, in
this order, 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.

The following entries are displayed for each user: login name, the tty name, the remote host, login time, idle
time, JCPU, PCPU, and 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.
COMMAND-LINE OPTIONS
-h Don't print the header.

-u 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 Use the short format. Don't print the login time, JCPU or PCPU times.

-f Toggle printing the from (remote hostname) field. The default as released is for the from field to not be
printed, although your system administrator or distribution maintainer may have compiled a version in
which the from field is shown by default.

-V Display version information.

user Show information about the specified user only.
-----------------------------------

[root@rusky opt]# w
 16:14:50 up 4 days, 11:09,  4 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.1.110   14:13    0.00s  0.28s  0.00s w
rusky1   pts/1    192.168.1.110   15:58    8:27   0.03s  0.02s bash
rusky1   pts/2    192.168.1.110   16:00   13:56   0.02s  0.02s -bash
test     pts/3    192.168.1.111  16:04    1:51   0.05s  0.02s vim vi

[root@rusky opt]# w --help
w: invalid option -- '-'
usage: w -hlsufV [user]
    -h    skip header
    -l    long listing (default)
    -s    short listing
    -u    ignore uid of processes
    -f    toggle FROM field (default on)
    -V    display version

[root@rusky opt]# w -h
root     pts/0    192.168.1.110   14:13    0.00s  0.28s  0.00s w -h
rusky1   pts/1    192.168.1.110   15:58    8:46   0.03s  0.02s bash
rusky1   pts/2    192.168.1.110   16:00   14:15   0.02s  0.02s -bash
test     pts/3    192.168.1.222    16:04    2:10   0.05s  0.02s vim vi

[root@rusky opt]# w -l
 16:15:20 up 4 days, 11:10,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.1.110   14:13    0.00s  0.28s  0.00s w -l
rusky1   pts/1    192.168.1.110   15:58    8:57   0.03s  0.02s bash
rusky1   pts/2    192.168.1.110   16:00   14:26   0.02s  0.02s -bash

[root@rusky opt]# w -s
 16:15:29 up 4 days, 11:10,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM               IDLE WHAT
root     pts/0    192.168.1.110    0.00s w -s
rusky1   pts/1    192.168.1.110    9:06  bash
rusky1   pts/2    192.168.1.110   14:35  -bash

[root@rusky opt]# w -u
 16:15:36 up 4 days, 11:10,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.1.110   14:13    0.00s  0.28s  0.00s w -u
rusky1   pts/1    192.168.1.110   15:58    9:13   0.03s  0.02s bash
rusky1   pts/2    192.168.1.110   16:00   14:42   0.02s  0.02s -bash

[root@rusky opt]# w -f
 16:15:47 up 4 days, 11:10,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0     14:13    0.00s  0.28s  0.00s w -f
rusky1   pts/1     15:58    9:24   0.03s  0.02s bash
rusky1   pts/2     16:00   14:53   0.02s  0.02s -bash

[root@rusky opt]# w -V
procps version 3.2.8

 

posted on 2014-12-31 16:26  遠離塵世の方舟  阅读(514)  评论(0编辑  收藏  举报

导航