在 CentOS Stream 8 中,你可以使用多种方法来查看系统日志。以下是一些常用的命令和工具:
journalctl:这是 systemd 的日志管理工具,可以用来查看系统和服务的日志。
查看所有日志:
journalctl 查看最近的日志条目:
journalctl -n 100 # 显示最近的100条日志 实时查看日志更新:
journalctl -f 查看特定服务的日志(例如 sshd):
journalctl -u sshd 查看某个时间段的日志:
journalctl --since "2023-10-01" --until "2023-10-02" /var/log/messages:这是一个传统的日志文件,包含许多系统消息。
cat、less 或 tail 查看内容:cat /var/log/messages less /var/log/messages tail -f /var/log/messages /var/log/syslog:在某些系统上,系统日志可能存储在这个文件中。
其他服务特定的日志文件:许多服务和应用程序会在 /var/log 下有其自己的日志文件。例如:
Apache HTTP 服务器日志:
/var/log/httpd/ MySQL 日志:
/var/log/mysqld.log PostgreSQL 日志:
/var/log/postgresql/ 根据你的需求选择合适的工具和文件来查看日志。