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 **从未登陆过**