w
可以认为是加强版的who
,果然越简洁越强大,就比如less
比more
是功能更多的。
w
不仅可以显示谁在登录,还可以打印他们在做什么。w
显示的信息如下:
官方定义为:
w - Show who is logged on and what they are doing.
用法为:
$ w [options] user [...]
常用的两个选项为:
-h
不显示各栏位的标题信息列。
-s
简洁格式列表,不显示用户登入时间,JCPU或者PCPU的时间
显示当前用户的登录信息及执行的命令
$ 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
$ 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
$ 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