last [options] [
参数
含义
-
显示多少行
-a, --hostlast
last在最后一列中显示主机名
-d, --dns
将IP号转换回主机名
-f, --file
<读取特定文件而不是 /var/log/wtmp
-F, --fulltimes
打印完整的登录和注销时间和日期
-i, --ip
以数字和点表示法显示ip编号
-n, --limit
限制要显示的行数
-R, --nohostname
不显示hostname字段
-s, --since
显示指定时间以来的行
-t, --until
显示指定时间之前的行
-p, --present
显示在指定时间出现的人员
-w, --fullnames
显示完整的用户名和域名
-x, --system
显示系统关闭条目和运行级别更改
-h, --help
帮助
-V, --version
版本
last -5 -a -d -F
可以看到不加 -F,时间一列的区别
last -R
last -5 -w -s 202106041733300
last -5 -t 20210606000000
执行 last 命令时,默认读取 /var/log/wtmp 文件
还有另外一个命令,lastb
/var/run/utmp
/var/log/lastlog
last -f /var/log/wtmp
等价于只敲 last
last -f /var/log/btmp
last -f /var/run/utmp
当前就一个 root 用户登录,加上一个系统信息
last -f /var/log/lastlog
直接用 last -f 好像并不会显示信息,应该是因为读取的文件的数据结构不一致的原因
lastlog
后面查了下,可以直接用 lastlog 查看 /var/log/lastlog
通过 last 找到用户的终端信息,然后用 fuser kill 掉
last
fuser -k /dev/pts/0
重新 ssh 连接服务器,查看之前的登录信息
https://www.cnblogs.com/poloyy/p/14846179.html
fuser -k $(last -w | grep name | awk '{print "/dev/"$2}')
自己换掉 name
ps -ef|grep name | awk '{print $2}' | xargs kill -9
手机扫一扫
移动阅读更方便
你可能感兴趣的文章