用 last 查看登录记录
看看 Mac 最近的登录、重启记录,离开电脑回来后快速核对。
运行 `last -20` 即可显示最近 20 条记录。
01命令
命令
$ last -2002作用说明
系统的登录记账日志会记录每次登录、注销和重启,last 按时间倒序输出并显示会话时长。想确认离开期间有没有人用过电脑,或者上次关机是什么时候,这是最快的办法。加上用户名(如 `last alice`)可以只看某个账户的记录。
03风险
!注意: 这里只显示系统记账日志记录的本地登录——屏幕共享和 SSH 登录会出现,但普通文件共享连接不会。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- last — indicate last logins of users and terminals (macOS man page)依据: Documents last listing sessions recorded in the system accounting file, most recent first.
最后验证: 2026-09-18 · 分类: 安全与隐私