在linux下竟然还有这么一条指令,以前一直不知道。这指令相似的还有who/whoami,都是用来显示“你是谁”的。
whoami显示当前用户名,比如root,而who am i则是显示登录用户名,即使你当前通过sudo su切换到了管理员root模式,还是只显示登录用户名。下面是一个例子:
root@ubuntu:/home/test/STL/Ch9# who
test tty7 2010-10-06 18:02 (:0)
test pts/0 2010-10-06 19:24 (:0.0)
root@ubuntu:/home/test/STL/Ch9# who am i
test pts/0 2010-10-06 19:24 (:0.0)
root@ubuntu:/home/test/STL/Ch9# whoami
root
root@ubuntu:/home/test/STL/Ch9# exit
exit
test@ubuntu:~/STL/Ch9$ who
test tty7 2010-10-06 18:02 (:0)
test pts/0 2010-10-06 19:24 (:0.0)
test@ubuntu:~/STL/Ch9$ who am i
test pts/0 2010-10-06 19:24 (:0.0)
test@ubuntu:~/STL/Ch9$ whoami
test
whoami显示当前用户名,比如root,而who am i则是显示登录用户名,即使你当前通过sudo su切换到了管理员root模式,还是只显示登录用户名。下面是一个例子:
root@ubuntu:/home/test/STL/Ch9# who
test tty7 2010-10-06 18:02 (:0)
test pts/0 2010-10-06 19:24 (:0.0)
root@ubuntu:/home/test/STL/Ch9# who am i
test pts/0 2010-10-06 19:24 (:0.0)
root@ubuntu:/home/test/STL/Ch9# whoami
root
root@ubuntu:/home/test/STL/Ch9# exit
exit
test@ubuntu:~/STL/Ch9$ who
test tty7 2010-10-06 18:02 (:0)
test pts/0 2010-10-06 19:24 (:0.0)
test@ubuntu:~/STL/Ch9$ who am i
test pts/0 2010-10-06 19:24 (:0.0)
test@ubuntu:~/STL/Ch9$ whoami
test