我问这个问题是因为,虽然互联网上有很多答案表明who -a是一种选择,但没有人解释如何读取输出。如果你能提供一个在线网站的链接来解释这一点,那同样是一个很棒的答案。下面是我想解密的一个例子:
[bo@hostname ~]$ who -a
Jun 17 03:47 590 id=si term=0 exit=0
system boot Jun 17 03:47
run-level 3 Jun 17 03:47 last=S
Jun 17 03:48 4424 id=l3 term=0 exit=0
LOGIN tty1 Jun 17 03:48 5503 id=1
LOGIN tty2 Jun 17 03:48 5504 id=2
LOGIN tty3 Jun 17 03:48 5505 id=3
LOGIN tty4 Jun 17 03:48 5506 id=4
LOGIN tty5 Jun 17 03:48 5507 id=5
LOGIN tty6 Jun 17 03:48 5508 id=6
pts/0 Oct 19 16:27 15250 id=ts/0 term=0 exit=0
bo + pts/1 Oct 23 12:24 . 19776 (10.10.10.93)
pts/2 Oct 23 13:07 8551 id=ts/2 term=0 exit=0
pts/3 Oct 22 10:36 5813 id=ts/3 term=0 exit=0
pts/4 Oct 10 09:06 13002 id=ts/4 term=0 exit=0发布于 2012-10-23 21:09:53
你可以从man who找到
-a, --all
same as -b -d --login -p -r -t -T -u所以让我们来看一下细节:
-b, --boot
time of last system boot这是字符串system boot Jun 17 03:47
-d, --dead
print dead processes这是最后带有exit=0的字符串
-l, --login
print system login processes这是登录ttys (开头带有LOGIN的字符串)
-p, --process
print active processes spawned by init这
-r, --runlevel
print current runlevel我是run-level 3 Jun 17 03:47 last=S
下一个是
-T, -w, --mesg
add user's message status as +, - or ?
-u, --users
list users logged in这两根绳子
bo + pts/1 Oct 23 12:24 . 19776 (10.10.10.93)希望现在更清楚的是如何解析这个输出。
https://unix.stackexchange.com/questions/52712
复制相似问题