CHECKLIST
Linux 关键日志位置速查
排查登录、提权、Web 攻击、数据库异常时,该看哪个文件、用什么命令。
Debian/Ubuntu 与 RHEL/CentOS 的日志路径不同,表中已标注。使用 journalctl 时注意时区。
| 日志 | 路径 | 内容 | 常用命令 |
|---|---|---|---|
| 认证日志 | /var/log/auth.log(Debian) | SSH、sudo、账号变更 | grep Accepted /var/log/auth.log |
| 认证日志 | /var/log/secure(RHEL) | 同上 | lastb | head -20 |
| 登录历史 | /var/log/wtmp | 登录/注销记录 | last -ai |
| 失败登录 | /var/log/btmp | 失败尝试 | lastb |
| 最后登录 | /var/log/lastlog | 每用户最后登录 | lastlog |
| Web 访问 | /var/log/nginx/access.log | HTTP 请求 | awk '{print $7}' | sort | uniq -c |
| Web 错误 | /var/log/nginx/error.log | PHP/上游错误 | tail -f |
| 系统日志 | journalctl | 服务启停、内核 | journalctl -u nginx --since today |
| 数据库 | /var/log/mysql/error.log | 启动、错误、权限拒绝 | grep -i denied |
| 审计 | /var/log/audit/audit.log | auditd 规则命中 | ausearch -k identity |
使用说明:日志时间必须与系统时区一致,并尽量转发到独立日志平台。被入侵机器上的本地日志只能作为参考。