温馨提示×

linux如何查看日志

小新
1816
2021-04-17 16:34:08
栏目: 智能运维

linux查看日志的方法:1、打开终端;2、通过“tail”、“head”、“cat”命令查看日志即可。

linux如何查看日志

具体操作步骤:

1、首先通过快捷键【Ctrl+Alt+T】打开终端命令行模式。

2、输入以下命令查看日志即可。

#tail命令

tail -100f test.log #实时监控100行日志

tail -n 10 test.log #查看日志尾部最后10行的日志

tail -n +10 test.log #查看10行之后的所有日志

#head命令

head -n 10 test.log #查看日志文件中的头10行日志

head -n -10 test.log #查看日志文件除了最后10行的其他所有日志

#cat

cat -n test.log |grep "debug" #查看指定关键字的日志信息

日志文件相关说明:

/var/log/message #系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一

/var/log/secure #与安全相关的日志信息

/var/log/maillog #与邮件相关的日志信息

/var/log/cron #与定时任务相关的日志信息

/var/log/spooler #与UUCP和news设备相关的日志信息

/var/log/boot.log #守护进程启动和停止相关的日志消息

0