0%

什么?谁?w (who & what)

什么?谁?w (who & what)

.. code::
去年花里逢君别,今日花开已一年。
韦应物《寄李儋元锡》

w可以认为是加强版的who,果然越简洁越强大,就比如lessmore是功能更多的。

w不仅可以显示谁在登录,还可以打印他们在做什么。w显示的信息如下:

  • 登录的用户;
  • 运行的程序;
  • 第一行显示的信息:当前时间、系统运行的时间、多少用户登录、系统的负载(分贝为1,5,15分钟)

官方定义为:

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

用法为:

1
$ w [options] user [...]

常用的两个选项为:

  • -h  不显示各栏位的标题信息列。

  • -s  简洁格式列表,不显示用户登入时间,JCPU或者PCPU的时间

默认的显示

显示当前用户的登录信息及执行的命令

1
2
3
4
5
6
7
8
9
$ w
16:29:03 up 26 days, 2:49, 6 users, load average: 1.00, 0.97, 0.96
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
user pts/4 :1 07Sep21 20days 9:59 1:53m bash
user pts/0 :2 08Sep21 6days 0.70s 1:53m zsh
user pts/1 :3 08Sep21 20days 1:13m 1:53m bash
user :0 :0 15Sep21 6days 27days 21.36s zsh
user pts/2 :0 15Sep21 14days 0.25s 0.25s zsh
user pts/3 :3 16Sep21 24:45m 0.22s 0.22s bash

不显示标题行

1
2
3
4
5
6
7
8
9
$ w -h
16:29:16 up 26 days, 2:49, 6 users, load average: 1.20, 0.67, 0.76
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
user pts/4 :1 07Sep21 20days 9:59 1:53m bash
user pts/0 :2 08Sep21 6days 0.70s 1:53m zsh
user pts/1 :3 08Sep21 20days 1:13m 1:53m bash
user :0 :0 15Sep21 6days 27days 21.36s zsh
user pts/2 :0 15Sep21 14days 0.25s 0.25s zsh
user pts/3 :3 16Sep21 24:45m 0.22s 0.22s bash

简洁模式显示

1
2
3
4
5
6
7
8
9
$ w -s
16:29:26 up 26 days, 2:49, 6 users, load average: 1.50, 0.67, 0.36
USER TTY FROM IDLE WHAT
user pts/4 :1 20days bash
user pts/0 :2 6days zsh
user pts/1 :3 20days bash
user :0 :0 6days zsh
user pts/2 :0 14days zsh
user pts/3 :3 24:45m bash
处无为之事,行不言之教;作而弗始,生而弗有,为而弗恃,功成不居!

欢迎关注我的其它发布渠道