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