15.who命令和w命令

  • Post author:
  • Post category:其他


who命令:显示目前登录系统的用户信息

选项:
            -H 显示一个头(标题)
      -r 显示当前进程的运行级别
            -b 指出最近系统启动的时间和日期
            -q 打印一份在本地系统上的用户和用户数的快速清单
            -u 或 -i 显示每个当前用户的用户名、tty、登录时间、线路活动和进程标识
            -s 仅列出名字、线路和时间字段。这个标志是缺省值;因此,who 和 who -s 命令是等效的

    实例:
            [root@localhost ~]# who -H
                        名称   线路       时间           备注
                        root     pts/0        2019-01-12 18:42 (192.168.0.2)
                        centos   pts/1        2019-01-12 18:47 (192.168.0.2)
                    gentoo   pts/2        2019-01-12 18:45 (192.168.0.2)
                        root     pts/3        2019-01-12 18:52 (192.168.0.2)

            [root@localhost ~]# who -r
                         运行级别 5 2019-01-12 18:27

            [root@localhost ~]# who -b
                            系统引导 2019-01-13 02:27

            [root@localhost ~]# who -q
                            root centos gentoo root
                            # 用户数=4

        [root@localhost ~]# who -u
                        root     pts/0        2019-01-12 18:42  旧的       13617 (192.168.0.2)
                        centos   pts/1        2019-01-12 18:47  旧的       18016 (192.168.0.2)
                        gentoo   pts/2        2019-01-12 18:45  旧的       16656 (192.168.0.2)
                        root     pts/3        2019-01-12 18:52  旧的       22391 (192.168.0.2)

      [root@localhost ~]# who -s
                        root     pts/0        2019-01-12 18:42 (192.168.0.2)
                        centos   pts/1        2019-01-12 18:47 (192.168.0.2)
                        gentoo   pts/2        2019-01-12 18:45 (192.168.0.2)
                        root     pts/3        2019-01-12 18:52 (192.168.0.2)

        w命令:

                    选项:
                            -h:不打印头信息;
                            -u:当显示当前进程和cpu时间时忽略用户名;
                            -s:使用短输出格式;
                            -f:显示用户从哪登录;
                            -V:显示版本信息。

            实例:

                    [root@localhost ~]# w 
                             20:06:49 up  1:39,  5 users,  load average: 0.22, 0.12, 0.07
                            USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
                            root     pts/0    192.168.0.2      18:42    1.00s  0.20s  0.00s w
                            centos   pts/1    192.168.0.2      18:47    1:19m  0.01s  0.01s -bash
                            gentoo   pts/2    192.168.0.2      18:45    1:20m  0.02s  0.02s -bash
                            root     pts/3    192.168.0.2      18:52    7:45   0.07s  0.07s -bash
                            root     pts/4    192.168.0.2      19:59    7:37   0.02s  0.02s -bash

                    [root@localhost ~]# w -s
                             20:06:55 up  1:39,  5 users,  load average: 0.20, 0.12, 0.07
                            USER     TTY      FROM              IDLE WHAT
                            root     pts/0    192.168.0.2       7.00s w -s
                            centos   pts/1    192.168.0.2       1:19m -bash
                            gentoo   pts/2    192.168.0.2       1:20m -bash
                            root     pts/3    192.168.0.2       7:51  -bash
                            root     pts/4    192.168.0.2       7:43  -bash

转载于:https://blog.51cto.com/itxuezhe/2342020