whoami,who,w命令詳解

  

 

http://www.voidcn.com/blog/wszzdanm/article/p-6145895.htmlhtml

命令功能:顯示登陸用戶的信息ubuntu

命令格式:bash

經常使用選項:session

舉例:spa

w 顯示已經登陸的用戶及正在進行的操做code

[root@localhost ~]# whtm

 11:22:01 up 4 days, 21:22,  3 users,  load average: 0.00, 0.00, 0.00blog

USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHATit

root     tty1     -                Thu14    4days  0.19s  0.19s -bashio

root     pts/0    172.31.3.32      Thu14    0.00s  0.73s  0.00s w

root     pts/1    172.31.3.32      11:18    1:50   0.07s  0.02s -bash

 

who 顯示已經登陸的用戶名、終端名稱、登陸時間及登陸IP

[root@localhost ~]# who

root     tty1         2015-11-12 14:00

root     pts/0        2015-11-12 14:03 (172.31.3.32)

root     pts/1        2015-11-17 11:18 (172.31.3.32)

 

whoami 顯示當前用戶的用戶名

[zzd@localhost ~]$ whoami

zzd

 

who am i 顯示登陸系統的時候的用戶名,即便已經切換到其餘用戶也顯示登陸時的用戶

         結果同who -m

[zzd@localhost ~]$ whoami

zzd

[zzd@localhost ~]$ who am i

root     pts/1        2015-11-17 11:18 (172.31.3.32)

[zzd@localhost ~]$ who -m

root     pts/1        2015-11-17 11:18 (172.31.3.32)

 

顯示當前用戶

w  //顯示當前用戶,不顯示登陸位置 19:50:14 up 9:27, 4 users, load average: 0.31, 0.26, 0.18 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty7 :0 Thu12 31:39m 10:10 0.60s gnome-session root pts/0 :0.0 17:09 2:18m 15.26s 0.15s bash root pts/1 192.168.1.17 18:51 1.00s 1.24s 0.14s -bash root pts/2 192.168.1.17 19:48 60.00s 0.05s 0.05s -bash

不顯示登陸位置

w -f 19:53:59 up 9:31, 4 users, load average: 0.05, 0.16, 0.15 USER TTY LOGIN@ IDLE JCPU PCPU WHAT root tty7 Thu12 31:43m 10:10 0.60s gnome-session root pts/0 17:09 2:21m 15.26s 0.15s bash root pts/1 18:51 0.00s 1.04s 0.14s -bash root pts/2 19:48 4:45 0.05s 0.05s -bash

以精簡模式顯示

w -s 19:54:37 up 9:31, 4 users, load average: 0.24, 0.19, 0.16 USER TTY FROM IDLE WHAT root tty7 :0 31:43m gnome-session root pts/0 :0.0 2:22m bash root pts/1 192.168.1.17 0.00s -bash root pts/2 192.168.1.17 5:23 -bash

不顯示標題

w -h root tty7 :0 Thu12 31:44m 10:10 0.60s gnome-session root pts/0 :0.0 17:09 2:23m 15.26s 0.15s bash root pts/1 192.168.1.17 18:51 0.00s 1.05s 0.14s -bash root pts/2 192.168.1.17 19:48 5:54 0.05s 0.05s -bash
yexiang@ubuntu:<sboot>$ w -u yexiang
 14:02:04 up 9 days,  4:40,  3 users,  load average: 0.99, 1.25, 0.99
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
yexiang  pts/1    10.0.4.198       10:19    3.00s  0.19s  0.00s w -u yexiang
相關文章
相關標籤/搜索