linux之w、who、last、lastlog

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

查看当前登录用户以及用户在做什么

[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 on

查看谁正在登录系统

[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 users

展示目前和上次登录系统的用户,读取的文件是/var/log/wtmp

[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 user

检查系统中所有用户上次登录的记录,读取的文件是/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                                       **从未登录过**

猜你喜欢

转载自blog.51cto.com/12107790/2173417