linux之w、who、last、lastlog

w:Show who is logged on and what they are doingmysql

查看當前登陸用戶以及用戶在作什麼sql

[root@www ~]# w
 11:02:41 up 4 days,  2:05,  3 users,  load average: 0.00, 0.00, 0.00        #系統啓動時間,運行多久,幾個用戶登陸,平均負載
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.146.1    03:45    0.00s  0.38s  0.00s w
root     pts/1    192.168.146.1    09:09    2:00   0.04s  0.00s -bash
zhangsan pts/2    192.168.146.1    11:01    1:40   0.00s  0.00s -bash

who:show who is logged onbash

查看誰正在登陸系統ide

[root@www ~]# who
root     pts/0        2018-09-05 03:45 (192.168.146.1)
root     pts/1        2018-09-05 09:09 (192.168.146.1)
zhangsan pts/2        2018-09-05 11:01 (192.168.146.1)

last:show listing of last logged in usersit

展現目前和上次登陸系統的用戶,讀取的文件是/var/log/wtmpast

[root@www ~]# last
zhangsan pts/2        192.168.146.1    Wed Sep  5 11:01   still logged in
root     pts/1        192.168.146.1    Wed Sep  5 09:09   still logged in
root     pts/0        192.168.146.1    Wed Sep  5 03:45   still logged in
root     pts/1        192.168.146.1    Sun Sep  2 11:24 - 11:34  (00:09)
root     pts/0        192.168.146.1    Sun Sep  2 11:20 - 11:34  (00:14)
                                      開始登陸的時間   離開的時間   登陸的總時間

lastlog:reports the most recent login of all users or of a given userclass

檢查系統中全部用戶上次登陸的記錄,讀取的文件是/var/log/lastlog登錄

[root@www ~]# lastlog
用戶名           端口     來自             最後登錄時間
root             pts/0    192.168.146.1    三 9月  5 11:13:30 +0800 2018
mysql                                      **從未登陸過**
zhangsan         pts/2    192.168.146.1    三 9月  5 11:01:01 +0800 2018
lisi                                       **從未登陸過**
相關文章
相關標籤/搜索