📅  最后修改于: 2023-12-03 14:47:51.042000             🧑  作者: Mango
tail journalctl last 100 lines
简介在Linux系统中,journalctl命令可用于查看系统日志。而使用tail journalctl last 100 lines
命令可以查看最后100行的系统日志。
tail journalctl last 100 lines
此命令由以下组成:
tail
命令用于显示文件末尾的内容journalctl
命令用于显示系统日志last 100 lines
指定要查看的最后100行日志以下是tail
命令中常用的参数说明:
-n <行数>
:指定要显示的行数,例如-n 100
表示显示最后100行内容-f
:实时跟踪文件末尾的内容,并在文件有新内容时实时显示以下是journalctl
命令中常用的参数说明:
-u <unit>
:显示指定服务或单元的日志,例如-u sshd
表示显示sshd服务的日志-p <priority>
:显示指定优先级的日志,例如-p err
表示显示错误日志--since/-S <时间>
:显示指定时间以来的日志,例如--since "1 hour ago"
表示显示一小时以来的日志使用tail journalctl last 100 lines
命令返回的是最后100行的系统日志,可以通过参数来定制要查看的内容。
以下是返回值的示例代码片段:
Apr 15 09:38:58 mypc kernel: usb 1-1: new full-speed USB device number 2 using xhci_hcd
Apr 15 09:38:58 mypc kernel: usb 1-1: New USB device found, idVendor=0cf3, idProduct=3004, bcdDevice= 0.01
Apr 15 09:38:58 mypc kernel: usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Apr 15 09:38:58 mypc kernel: usb 1-1: ep 0x81 - rounding interval to 1024 microframes, ep desc says 2040 microframes
Apr 15 09:38:58 mypc mtp-probe[2367]: checking bus 1, device 2: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1"
Apr 15 09:38:58 mypc mtp-probe[2367]: bus: 1, device: 2 was not an MTP device
Apr 15 09:38:58 mypc kernel: usbcore: registered new interface driver btusb
Apr 15 09:38:58 mypc /usr/lib/gdm3/gdm-x-session[2221]: (II) config/udev: Adding input device BCM20702A0:00 0489:E062 Mouse (/dev/input/mouse0)
Apr 15 09:38:58 mypc /usr/lib/gdm3/gdm-x-session[2221]: (II) No input driver specified, ignoring this device.
Apr 15 09:38:58 mypc /usr/lib/gdm3/gdm-x-session[2221]: (II) This device may have been added with another device file.
以上返回值显示了最后100行系统日志中的某些内容,可以根据实际情况进行设置。