查詢當前登入系統的使用者

2022-09-24 03:39:10 字數 1661 閱讀 1180

查詢當前登入系統的使用者 who 

[root@lyy ~]# who 

root     tty1         2010-12-09 19:16 

root     pts/0        2010-12-09 19:29 (192.168.197.1) 

第一列 登入的使用者 

第二列終端名 

第三列 登入時間 

查詢每個使用者最近登入時間 lastlog 

[root@lyy ~]# lastlog 

使用者名稱         埠     來自             最後登陸時間 

root             pts/0    192.168.197.1    四 12月 9 19:29:15 +0800 2010 

bin                                        **從未登入過** 

daemon                                     **從未登入過** 

pcca             tty1                      二 12月 7 22:09:21 +0800 2010 

pcca1            tty1                      二 12月 7 22:09:26 +0800 2010 

pcca2                                      **從未登入過** 

lastlog會從/var/log/lastlog檔案中把資料讀取出來 

使用者之間對話 write 

格式:write 使用者 終端介面 

例:使用者pc 傳送資訊給使用者 pcca 

1.在pc終端上檢視pcca終端的介面 

[pc@lyy ~]$ who 

root     tty1         2010-12-09 19:16 

pcca     pts/0        2010-12-09 19:34 (192.168.197.1)       # pcca終端介面為pts/0 

pc       pts/1        2010-12-09 19:37 (192.168.197.1) 

2.利用write傳送資訊 hello world 

[pc@lyy ~]$ write pcca  pts/0 

hello world!!! 

[pc@lyy ~]$ 

輸入完成後按 ctrl+d 來結束。 

3.看pcca終端的情況 

[pcca@lyy ~]$ 

message from pc@lyy on pts/1 at 19:42 ... 

hello world!!! 

eof 

如果不想接受資訊可以用 mesg n 來關閉,除root外的資訊不接收。 

對所有登入的使用者傳送廣播資訊 wall 

[pc@lyy ~]$ wall "i will shutdown my linux server." 

broadcast message from pc (pts/1) (thu dec  9 19:47:35 2010): 

i will shutdown my linux server. 

這樣所有的人都可以收到了。  

作者 yingbin920

wp 當前使用者 登入使用者

當前使用者 get currentuserinfo echo 使用者名稱 current user user login n echo 名字 current user user firstname n echo 姓氏 current user user lastname n echo 公開顯示名 c...

寫了個函式,獲取當前登入系統的使用者名稱

今天要在工程中用到這個,順便寫了下,方便使用,源 如下 option explicit private declare function getusername lib advapi32.dll alias getusernamea byval lpbuffer as string,nsize as...

新增使用者查詢當前使用者所有表

今天在bbs上看到一位提出 新增使用者只能查詢當前使用者所有表,於是簡單地測試了一下 sql create user aaa identified by bbb 使用者已建立。sql grant select any table to aaa 授權成功。sql grant connect to aa...