当前位置: 首页 > news >正文

linux_文件跟踪查看/实时查看添加到⽂件中的内容/linux日志查看(outline)

文章目录

  • 文件跟踪查看/实时查看添加到⽂件中的内容/linux日志查看
      • 追踪更新中的文件
      • 查看某个文件的末尾N行,并带上源文件中的行号
    • 查看linux内核日志
      • 相关参考
    • 日志查看示例
      • 查看开机日志
      • ubuntu
      • 授权日志
    • Conclusion

文件跟踪查看/实时查看添加到⽂件中的内容/linux日志查看

追踪更新中的文件

  • tail -f -n <lineNumbers> <logFile> | nl

查看某个文件的末尾N行,并带上源文件中的行号

  • nl <logFile> tail -n <lineNumbers>

查看linux内核日志

相关参考

  • What are Linux Logs? Code Examples, Tutorials & More (stackify.com)

    • A Definition of Linux Logs
    • How to View Linux Logs
    • Most Important Linux Logs
    • Critical, Must Monitor Logs
    • Sample Output
    • Additional Resources and Tutorials on Linux Logs
  • Classic SysAdmin: Viewing Linux Logs from the Command Line

    • /var/log
    • Viewing logs with less
    • Viewing logs with dmesg
    • Viewing logs with tail
  • How to View System Log Files in Linux (linuxhint.com)

  • Analyzing and Managing System Log Files | System Analysis and Tuning Guide | SUSE Linux Enterprise Server 12 SP4

  • How to View & Read Linux Log Files
    • What are Linux Log Files?
    • How to View Linux Logs
    • Important Linux System Logs
      • System Logs
      • System Logging Daemon
      • Application Logs
      • Non-Human-Readable Logs
    • Supplemental GUIs for Viewing Linux Log Files
    • How to Configure Log Files on Ubuntu and CentOS
    • Execute Log Rotation

日志查看示例

查看开机日志

ubuntu

  • sudo tail -f /var/log/boot.log
# cxxu @ cxxuAli in /var/log [19:00:25] C:1
$ sudo tail -f boot.log
[sudo] password for cxxu:
[  OK  ] Started Permit User Sessions.
[  OK  ] Started ECS enable networking multiqueue.
[  OK  ] Started resolvconf-pull-resolved.service.
[  OK  ] Started OpenBSD Secure Shell server.
[  OK  ] Started chrony, an NTP client/server.
[  OK  ] Started LSB: starts the nginx web server.
[  OK  ] Started LSB: Record successful boot for GRUB.
[  OK  ] Started Accounts Service.
         Starting Terminate Plymouth Boot Screen...
         Starting Hold until boot process finishes up...

授权日志

# cxxu @ cxxuAli in /var/log [19:02:53]
$ sudo tail /var/log/auth.log
Sep 29 18:59:37 cxxuAli sshd[24798]: pam_unix(sshd:session): session opened for user cxxu by (uid=0)
Sep 29 18:59:37 cxxuAli systemd-logind[584]: New session 23215 of user cxxu.
Sep 29 19:00:35 cxxuAli sudo:     cxxu : TTY=pts/0 ; PWD=/var/log ; USER=root ; COMMAND=/usr/bin/tail -f boot.log
Sep 29 19:00:35 cxxuAli sudo: pam_unix(sudo:session): session opened for user root by cxxu(uid=0)
Sep 29 19:00:45 cxxuAli sudo: pam_unix(sudo:session): session closed for user root
Sep 29 19:02:53 cxxuAli sudo:     cxxu : TTY=pts/0 ; PWD=/var/log ; USER=root ; COMMAND=/bin/cat /var/log/auth.log
Sep 29 19:02:53 cxxuAli sudo: pam_unix(sudo:session): session opened for user root by cxxu(uid=0)
Sep 29 19:02:53 cxxuAli sudo: pam_unix(sudo:session): session closed for user root
Sep 29 19:03:10 cxxuAli sudo:     cxxu : TTY=pts/0 ; PWD=/var/log ; USER=root ; COMMAND=/usr/bin/tail /var/log/auth.log
Sep 29 19:03:10 cxxuAli sudo: pam_unix(sudo:session): session opened for user root by cxxu(uid=0)

Conclusion

  • Examining various log files can help in debugging system freeze and crash issues, especially when new and unsupported hardware is present in the PC.
  • These log files are also useful for finding out security breaches or security loopholes if there are any.
  • If you are getting unexpected behavior from software installed on your system or frequent reboots and crashes, the first thing you should do is to examine various system log files.

相关文章:

  • CDH Kerberos启动后hue报错Couldn‘t renew kerberos ticket
  • 学Spring5源码之入门
  • Maven - 3、详解maven解决依赖问题
  • 1行代码提取6种TCGA表达矩阵和临床信息
  • 直升飞机领衔、三百辆婚车开道,三十台巨型吊车,小伟婚礼超豪华
  • 【2023秋招面经】OPPO 前端 一面(40min)
  • Nifi05 Nifi单节点、集群部署以及迁移
  • SQL server发布订阅事务复制新增表的解决方案(不重新初始化)
  • Tableau2——折线图,饼图
  • 对话腾讯天琴赵伟峰:当音乐与科技结合,会碰撞出怎样的火花?
  • codePen前端编码神器
  • Android 10.0 系统settings系统属性控制一级菜单显示隐藏
  • Linux多路I/O复用入门必读 -- epoll实现原理以及使用方法
  • systemverilog中的bind
  • 【视频】逆变换抽样将数据标准化和R语言结构化转换:BOX-COX、凸规则变换方法
  • 实现windows 窗体的自己画,网上摘抄的,学习了
  • [分享]iOS开发 - 实现UITableView Plain SectionView和table不停留一起滑动
  • 【翻译】Mashape是如何管理15000个API和微服务的(三)
  • 【跃迁之路】【699天】程序员高效学习方法论探索系列(实验阶段456-2019.1.19)...
  • 8年软件测试工程师感悟——写给还在迷茫中的朋友
  • AzureCon上微软宣布了哪些容器相关的重磅消息
  • css系列之关于字体的事
  • Debian下无root权限使用Python访问Oracle
  • JavaScript 事件——“事件类型”中“HTML5事件”的注意要点
  • JavaWeb(学习笔记二)
  • js正则,这点儿就够用了
  • Python连接Oracle
  • Python爬虫--- 1.3 BS4库的解析器
  • 阿里云前端周刊 - 第 26 期
  • 发布国内首个无服务器容器服务,运维效率从未如此高效
  • 前端技术周刊 2018-12-10:前端自动化测试
  • 微信小程序:实现悬浮返回和分享按钮
  • 无服务器化是企业 IT 架构的未来吗?
  • 一个JAVA程序员成长之路分享
  • 一起来学SpringBoot | 第三篇:SpringBoot日志配置
  • 怎么把视频里的音乐提取出来
  • 正则表达式小结
  • 继 XDL 之后,阿里妈妈开源大规模分布式图表征学习框架 Euler ...
  • ​flutter 代码混淆
  • #设计模式#4.6 Flyweight(享元) 对象结构型模式
  • (1/2)敏捷实践指南 Agile Practice Guide ([美] Project Management institute 著)
  • (173)FPGA约束:单周期时序分析或默认时序分析
  • (9)STL算法之逆转旋转
  • (cos^2 X)的定积分,求积分 ∫sin^2(x) dx
  • (动态规划)5. 最长回文子串 java解决
  • (四)Controller接口控制器详解(三)
  • (转)http-server应用
  • (转)mysql使用Navicat 导出和导入数据库
  • (转)ObjectiveC 深浅拷贝学习
  • (转)从零实现3D图像引擎:(8)参数化直线与3D平面函数库
  • .NET Core 控制台程序读 appsettings.json 、注依赖、配日志、设 IOptions
  • .net core 连接数据库,通过数据库生成Modell
  • .NET Remoting Basic(10)-创建不同宿主的客户端与服务器端
  • .net访问oracle数据库性能问题
  • .net解析传过来的xml_DOM4J解析XML文件