首页 > 系统相关 >linux_文件跟踪查看/实时查看添加到⽂件中的内容/linux日志查看(outline)

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

时间:2022-10-03 12:40:14浏览次数:143  
标签:Logs log 查看 Linux sudo session linux cxxuAli outline


文章目录

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

追踪更新中的文件

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

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

  • ​nl <logFile> tail -n <lineNumbers>​

查看linux内核日志

相关参考

  • /var/log
  • Viewing logs with less
  • Viewing logs with dmesg
  • Viewing logs with tail

日志查看示例

查看开机日志

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.


标签:Logs,log,查看,Linux,sudo,session,linux,cxxuAli,outline
From: https://blog.51cto.com/u_15672212/5730075

相关文章

  • Linux---冯诺依曼体系结构和操作系统
    文章目录​​前言​​​​冯诺依曼体系结构​​​​操作系统(OperatorSystem)​​​​概念​​​​设计OS的目的​​​​定位​​​​总结​​​​系统调用和库函数概念​......
  • 第一季:12Linux常用服务类相关命令【Java面试题】
    第一季:12Linux常用服务类相关命令【Java面试题】​​前言​​​​推荐​​​​第一季:12Linux常用服务类相关命令​​​​题目​​​​分析​​​​service(centos6)​​​......
  • 【Linux】学习-04-硬链接和软链接
    硬链接:相当于复制一个文件,但跟复制不同的是,当你修改其中任意一个文件后,另外一个文件也会跟着变动。软链接:相当于创建了一个快捷方式lna.txtb.txt:创建一个硬链接touch......
  • 02-Elasticsearch-基于Linux安装ES
    基于Linux安装ES下载官网https://www.elastic.co/cn/downloads/past-releases#elasticsearch使用7.4.2安装上传到Linux#解压tar-zxvfelasticsearch-7.4.2-......
  • archlinux安装到美化
    1、archlinux的基本安装1.1、停止reflector服务禁止自动更新服务器列表systemctlstopreflector.service1.2、检查电脑是否支持UEFI引导模式ls/sys/firmware/efi/e......
  • Linux Docker 操作命令汇总
    1.docker随linux系统自动启动设置:systemctlenabledocker.service2、docker容器自动启动设置在运行docker容器时可以加如下参数来保证每次docker服务重启后容器也自动重启:d......
  • Linux小技巧丨个性化显示命令提示符,PS1变量相关知识
    内容摘要:今天偶然出现服务器SSH连接后不显示用户名主机名和目录信息的情况,查询得PS1变量设置有误,根据一篇博客的内容,解决了这个问题,顺便分享一下个性化设置的学习笔记。......
  • Linux搜索查找类
    Linux搜索查找类find指令find指令将从指定目录下向下递归的遍历其各个子目录,将满足条件的文件或者目录显示在终端基本语法:find搜索范围选项选项说明-name查询......
  • Unix/Linux系统编程学习笔记-5
    笔记第十一章EXT2文件系统EXT2文件系统TheSecondExtendedFileSystem(ext2)文件系统是Linux系统中的标准文件系统,是通过对Minix的文件系统进行扩展而得到的,其存取......
  • kali linux 环境配置
    kalilinux环境配置起源于一次hadoop的安装和环境配置因为环境调了很久,具体的细节记不清了,一直在几个文件中反复横跳vim~/.local_profilevim/etc/profilevim~/.z......