命令
who
描述
show who is logged on
显示当前登录的用户信息
用法
1
| who [OPTION]... [ FILE | ARG1 ARG2 ]
|
选项
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Options: -a, --all 显示完整信息 -b, --boot 显示系统启动时间 -d, --dead 显示死亡进程 -H, --heading 显示标题 -l, --login 显示系统登录进程 -m 仅显示当前用户 -p, --process 显示由init产生的活动进程 -q, --count 统计所有登录的用户和用户数 -r, --runlevel 显示当前运行级别 -s, --short 简化显示,默认选项 -t, --time 显示上次系统时间更改的时间 -T, -w, --mesg 显示用户消息状态 -u, --users 显示登录的用户的进程PID
|
注意
默认读取的是/var/run/utmp
,还可以读取文件/var/log/wtmp
的内容
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| $ who root tty1 2021-03-20 20:19 root pts/0 2021-03-20 20:47 (192.168.80.1) root pts/1 2021-03-20 20:22 (192.168.80.1) $ who -a system boot 2021-03-20 20:15 run-level 3 2021-03-20 20:15 root + tty1 2021-03-20 20:19 00:26 947 root + pts/0 2021-03-20 20:47 00:04 1841 (192.168.80.1) root + pts/1 2021-03-20 20:22 . 1346 (192.168.80.1)
$ who -b system boot 2021-03-20 20:15
$ who -H NAME LINE TIME COMMENT root tty1 2021-03-20 20:19 root pts/0 2021-03-20 20:47 (192.168.80.1) root pts/1 2021-03-20 20:22 (192.168.80.1) $ who -Ha NAME LINE TIME IDLE PID COMMENT EXIT system boot 2021-03-20 20:15 run-level 3 2021-03-20 20:15 root + tty1 2021-03-20 20:19 00:38 947 root + pts/0 2021-03-20 21:28 00:02 3495 (192.168.80.1) root + pts/1 2021-03-20 20:22 . 1346 (192.168.80.1)
$ who -m root pts/0 2021-03-20 20:47 (192.168.80.1) $ whoami root $ who am i root pts/0 2021-03-20 21:28 (192.168.80.1) $ who are you root pts/0 2021-03-20 21:28 (192.168.80.1)
$ who -q root root root
$ who -r run-level 3 2021-03-20 20:15
$ who -u root tty1 2021-03-20 20:19 00:26 947 root pts/0 2021-03-20 20:47 00:05 1841 (192.168.80.1) root pts/1 2021-03-20 20:22 . 1346 (192.168.80.1)
$ who /var/log/wtmp root tty1 2021-01-07 22:45 root pts/0 2021-01-07 22:45 (192.168.80.1) root pts/1 2021-01-07 22:46 (192.168.80.1) $ who -Ha /var/log/wtmp NAME LINE TIME IDLE PID COMMENT EXIT system boot 2021-01-07 14:53 root + pts/0 2021-01-07 14:53 00:06 1095 (192.168.80.1) run-level 3 2021-01-07 14:53 tty1 2021-01-07 14:53 900 id=tty1 LOGIN tty1 2021-01-07 14:53 900 id=tty1 tty1 2021-01-07 14:54 900 id=tty1 term=2 exit=15 system boot 2021-03-20 20:15 run-level 3 2021-03-20 20:15 tty1 2021-03-20 20:15 947 id=tty1 LOGIN tty1 2021-03-20 20:15 947 id=tty1 root + pts/0 2021-03-20 20:18 00:06 1198 (192.168.80.1) root + tty1 2021-03-20 20:19 00:42 947 root + pts/1 2021-03-20 20:22 . 1346 (192.168.80.1) pts/0 2021-03-20 20:47 1196 id= term=0 exit=0 root + pts/0 2021-03-20 20:47 00:06 1841 (192.168.80.1) pts/0 2021-03-20 21:28 1839 id= term=0 exit=0 root + pts/0 2021-03-20 21:28 00:06 3495 (192.168.80.1)
|