last命令--Linux命令应用大词典729个命令解读

内容来源于人民邮电出版社《Linux命令应用大词典》

讲述729个命令,1935个例子

学习Linux系统的参考书、案头书,遇到不懂的命令或命令选项一查即可

争取每天都发布内容


本文出自 “airfish2000” 博客,更多命令查看博客:

http://airfish2000.blog.51cto.com/10829608/1881634


last命令

使用last命令可以显示用户最后登录的信息,该命令是通过读取/var/log/wtmp文件内容,并把该文件内记录的用户最后登录信息,全部显示出来。

命令语法:

last [选项] [用户][终端]

命令中各选项的含义如表所示。

                                   last命令选项含义

选项

含义

-t <终端>

只显示指定终端上的登录情况

-n  <K>

指定输出记录的条数,这里K是数字

-t  YYYYMMDDHHMMSS

显示在指定的时间登录的状态

-w

显示输出的完整的用户名和域名

-x

显示系统shutdown记录和运行级别的变化

-a

在最后一列显示主机名

-F

显示完整的登录和退出的时间和日期。

-R

不显示主机字段

 

例:显示用户root在控制台终端的所有登录信息。

[root@rhel~]# last root console

root     pts/0        192.168.0.200    Mon Aug 19 02:10   still logged in

root     pts/0        192.168.0.200    Mon Aug 19 02:06 - down   (00:01)

root     tty7         :0               Mon Aug 19 01:08 - 01:09  (00:00)

root     tty1         :0               Mon Aug 19 01:07 - 01:08  (00:00)

root     pts/0        192.168.0.200    Mon Aug 19 00:53 - down   (00:07)

root     tty1         :0               Mon Aug 19 00:53 - down   (00:08)

root     pts/1        192.168.0.200    Mon Aug 19 00:49 - down   (00:00)

root     pts/0        :0.0             Mon Aug 19 00:48 - down   (00:02)

root     tty1         :0               Mon Aug 19 00:47 - down   (00:02)

 

wtmpbegins Mon Aug 19 00:45:10 2013

例:显示近期系统重新引导间的时间。

[root@rhel~]# last reboot

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 02:08 - 04:00  (01:51)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 01:02 - 02:07  (01:05)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 00:51 - 01:01  (00:10)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 00:45 - 00:50  (00:04)

 

wtmpbegins Mon Aug 19 00:45:10 2013

例:显示近期用户登录情况。

[root@rhel ~]# last

root     pts/0        192.168.0.200    Mon Aug 19 02:10   still logged in

reboot   system boot  2.6.32-358.el6.x Mon Aug 19 02:08 - 04:02  (01:53)

root     pts/0        192.168.0.200    Mon Aug 19 02:06 - down   (00:01)

root     tty7         :0               Mon Aug 19 01:08 - 01:09  (00:00)

root     tty1         :0               Mon Aug 19 01:07 - 01:08  (00:00)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 01:02 - 02:07  (01:05)

root     pts/0        192.168.0.200    Mon Aug 19 00:53 - down   (00:07)

root     tty1         :0               Mon Aug 19 00:53 - down   (00:08)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 00:51 - 01:01  (00:10)

root     pts/1        192.168.0.200    Mon Aug 19 00:49 - down   (00:00)

root     pts/0        :0.0             Mon Aug 19 00:48 - down   (00:02)

root     tty1         :0               Mon Aug 19 00:47 - down   (00:02)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 00:45 - 00:50  (00:04)

 

wtmp begins Mon Aug 1900:45:10 2013

例:显示用户root所有登录信息的前6行记录。

[root@rhel~]# last -n 6

root     pts/0        192.168.0.200    Mon Aug 19 02:10   still logged in

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 02:08 - 04:00  (01:52)

root     pts/0        192.168.0.200    Mon Aug 19 02:06 - down   (00:01)

root     tty7         :0               Mon Aug 19 01:08 - 01:09  (00:00)

root     tty1         :0               Mon Aug 19 01:07 - 01:08  (00:00)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 01:02 - 02:07  (01:05)

 

wtmpbegins Mon Aug 19 00:45:10 2013

例:显示系统shutdown记录和运行级别的变化。

[root@rhel~]# last -x

root     pts/0        192.168.0.200    Mon Aug 19 02:10   still logged in

runlevel(to lvl 5)   2.6.32-358.el6.x Mon Aug 1902:08 - 04:06  (01:57)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 02:08 - 04:06  (01:57)

shutdownsystem down  2.6.32-358.el6.x Mon Aug 1902:07 - 02:08  (00:00)

runlevel(to lvl 6)   2.6.32-358.el6.x Mon Aug 1902:07 - 02:07  (00:00)

root     pts/0        192.168.0.200    Mon Aug 19 02:06 - down   (00:01)

root     tty7        :0               Mon Aug 19 01:08 - 01:09  (00:00)

root     tty1         :0               Mon Aug 19 01:07 - 01:08  (00:00)

runlevel(to lvl 5)   2.6.32-358.el6.x Mon Aug 1901:02 - 02:07  (01:05)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 01:02 - 02:07  (01:05)

shutdownsystem down  2.6.32-358.el6.x Mon Aug 1901:01 - 01:02  (00:00)

runlevel(to lvl 6)   2.6.32-358.el6.x Mon Aug 1901:01 - 01:01  (00:00)

root     pts/0        192.168.0.200    Mon Aug 19 00:53 - down   (00:07)

root     tty1        :0               Mon Aug 19 00:53 - down   (00:08)

runlevel(to lvl 5)   2.6.32-358.el6.x Mon Aug 1900:51 - 01:01  (00:10)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 00:51 - 01:01  (00:10)

shutdownsystem down  2.6.32-358.el6.x Mon Aug 1900:50 - 00:51  (00:00)

runlevel(to lvl 6)   2.6.32-358.el6.x Mon Aug 1900:50 - 00:50  (00:00)

root     pts/1        192.168.0.200    Mon Aug 19 00:49 - down   (00:00)

root     pts/0        :0.0             Mon Aug 19 00:48 - down   (00:02)

root     tty1        :0               Mon Aug 19 00:47 - down   (00:02)

runlevel(to lvl 5)   2.6.32-358.el6.x Mon Aug 1900:45 - 00:50  (00:04)

reboot   system boot 2.6.32-358.el6.x Mon Aug 19 00:45 - 00:50  (00:04)

 

wtmpbegins Mon Aug 19 00:45:10 2013

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值