码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • linux_文件跟踪查看/实时查看添加到⽂件中的内容/linux日志查看(outline)


    文章目录

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

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

    追踪更新中的文件

    • tail -f -n | nl

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

    • nl tail -n

    查看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.
  • 相关阅读:
    猿创征文 | 关于游戏开发的那些工具
    Hadoop总结
    华为数通方向HCIP-DataCom H12-831题库(单选题:121-140)
    vue 学习 -- day36(分析工程结构)
    2023第二届陇剑杯网络安全大赛 SS Writeup
    展讯模块读写IMEI
    SpringBoot 整合 RabbitMQ 通过插件实现延迟队列 (四) 有图 有源码
    Metasploit介绍
    设计模式-迭代器模式
    阿里云跨账号建立局域网
  • 原文地址:https://blog.csdn.net/xuchaoxin1375/article/details/127112255
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号