用 ausearch 查询 Linux 审计日志

用 ausearch 搜索内核审计日志,查清服务器上谁登录过、改过什么文件、执行过什么命令,输出人类可读。

Linux日志安全审计中风险
运行 sudo ausearch -k logins --interpret,即可查看所有标记为 logins 的审计事件的可读结果。

01命令

命令
$ sudo ausearch -k logins --interpret

02作用说明

auditd 按 auditctl 设置的规则记录事件(例如 -w /etc/passwd -p wa -k passwd-changes),ausearch 则用来查询这些日志。-k 按规则里定义的 key 过滤事件,--interpret 会把用户 ID、时间戳、系统调用号翻译成人类可读的内容——不加的话输出几乎全是数字。其他常用过滤还有 -ua 用户名(按用户)、-f 路径(按文件)和 -ts today(按时间)。

03风险

风险中风险
使用条件auditd installed and running (sudo apt install auditd / sudo dnf install audit) with rules defined via auditctl
!注意: ausearch 只能查到审计规则真正记录下来的内容——没有加载任何规则时日志基本是空的,想追踪什么就要先用 auditctl 建对应规则。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • ausearch(8) — Ubuntu manual page
    Canonical · community · 2026-09-17
    依据: Documents ausearch -k <key> to query audit records by rule key and --interpret to decode numeric fields into readable text.
  • auditctl(8) — Ubuntu manual page
    Canonical · community · 2026-09-17
    依据: Shows how audit rules are created with -k keys, which ausearch later uses to filter matching events.

最后验证: 2026-09-18 · 分类: 安全与隐私

06相关方案