linux如何查看日志

2022年 10月 29日 发表评论
腾讯云正在大促:点击直达 阿里云超级红包:点击领取
免费/便宜/高性价比服务器汇总入口(已更新):点击这里了解

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

具体操作步骤:

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 #守护进程启动和停止相关的日志消息

小咸鱼

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: