
在 Linux 系统中,last 命令用于查看用户最近的登录记录。
当不带参数直接运行 last 指令时,它会读取 /var/log/ 目录下的 wtmp 文件,并列出所有文件中记录的用户登录信息。
<pre class="brush:php;toolbar:false;">last [选项] [用户名...] [终端...]
常用参数说明:
选项:
用户名:
终端:
展示两行记录并隐藏主机名列:
<pre class="brush:php;toolbar:false;"># last -R -2 root pts/0 Thu Apr 28 18:06 still logged in root pts/0 Tue Apr 26 09:06 - 19:36 (10:30) <p>wtmp begins Sun Apr 3 13:11:25 2022
同样效果的另一个示例:
<pre class="brush:php;toolbar:false;">~# last -R -2 root pts/0 Thu Apr 28 18:06 still logged in root pts/0 Tue Apr 26 09:06 - 19:36 (10:30)</p><p>wtmp begins Sun Apr 3 13:11:25 2022
常规方式显示:
<pre class="brush:php;toolbar:false;"># last ... root pts/4 Thu May 13 17:25 still logged in<br /> root pts/2 Thu May 13 17:23 - 17:25 (00:02)<br /> root pts/1 Thu May 13 16:46 still logged in<br /> ...
简洁显示并设置输出条目数量:
<pre class="brush:php;toolbar:false;"># last -n 5 -R root pts/4 Thu May 13 17:25 still logged in<br /> root pts/2 Thu May 13 17:23 - 17:25 (00:02)<br /> root pts/1 Thu May 13 16:46 still logged in<br /> root pts/7 Thu May 13 15:36 still logged in<br /> root pts/9 Thu May 13 15:35 still logged in </p><p>wtmp begins Thu May 13 18:55:40 2014
显示包含源 IP 地址的最后一列:
<pre class="brush:php;toolbar:false;"># last -n 5 -a -i root pts/4 Thu May 13 17:25 still logged in 192.168.1.10 root pts/2 Thu May 13 17:23 - 17:25 (00:02) 192.168.1.10 root pts/1 Thu May 13 16:46 still logged in 192.168.1.10 root pts/7 Thu May 13 15:36 still logged in 192.168.1.10 root pts/9 Thu May 13 15:35 still logged in 192.168.1.10</p><p>wtmp begins Thu May 13 18:55:40 2014
以上就是linux显示最近登录用户是什么-last 命令使用与实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号