Answers:
是的,Ubuntu会在连接USB设备时记录日志。文件是/var/log/syslog
。您也可以通过发出命令dmesg -c
或使用来查看它Log file viewer
。
否,关机后不会清除此日志。达到大小限制后的日志旋转,这意味着新的日志被不断写入/var/log/syslog
,而较旧的记录都推到命名压缩文件/var/log/syslog.1.gz
,syslog.2.gz
...在同一个/var/log
目录下。
您可以在/var/log
下面查看带有旋转日志文件的目录:
tail -f /var/log/syslog
清除屏幕,然后连接USB设备。
dmesg -c
将显示并清除dmesg日志:(
我看的区域是:
sudo cat /var/log/kern.log | grep usb
输出如下所示:
May 25 07:38:51 mycomputer kernel: [ 607.296847] scsi7 : usb-storage 3-1:1.0
May 25 07:38:54 mycomputer kernel: [ 609.790892] usb 3-2: new high-speed USB device number 3 using xhci_hcd
May 25 07:38:54 mycomputer kernel: [ 609.817462] usb 3-2: ep 0x81 - rounding interval to 32768 microframes, ep desc says 0 microframes
May 25 07:38:54 mycomputer kernel: [ 609.817474] usb 3-2: ep 0x2 - rounding interval to 32768 microframes, ep desc says 0 microframes
May 25 07:38:54 mycomputer kernel: [ 609.818399] usb-storage 3-2:1.0: Quirks match for vid 13fe pid 3600: 4000
May 25 07:38:54 mycomputer kernel: [ 609.818529] scsi8 : usb-storage 3-2:1.0
您也可以使用以下命令搜索kern.log的压缩日志:
sudo zcat /var/log/kern.log.2.gz | grep usb
输出将采用与上面示例相同的格式。
您还可以按以下方式搜索系统日志:
sudo cat /var/log/syslog.1 | grep usb
这将为您提供如下结果:
May 25 07:31:25 tardis-w520 kernel: [ 161.469096] usb 1-1.5.5: new high-speed USB device number 8 using ehci_hcd
May 25 07:31:25 tardis-w520 mtp-probe: checking bus 1, device 8: "/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.5/1-1.5.5"
May 25 07:31:25 tardis-w520 kernel: [ 161.658587] scsi6 : usb-storage 1-1.5.5:1.0
May 25 07:31:25 tardis-w520 kernel: [ 161.658685] usbcore: registered new interface driver usb-storage
May 25 07:31:25 tardis-w520 kernel: [ 161.795563] usbcore: registered new interface driver uas
May 25 07:38:51 tardis-w520 kernel: [ 607.268280] usb 3-1: new high-speed USB device number 2 using xhci_hcd
May 25 07:38:51 tardis-w520 kernel: [ 607.293280] usb 3-1: ep 0x81 - rounding interval to 32768 microframes, ep desc says 0 microframes
May 25 07:38:51 tardis-w520 kernel: [ 607.293292] usb 3-1: ep 0x2 - rounding interval to 32768 microframes, ep desc says 0 microframes
要列出.gz日志文件,您将:
sudo zcat /var/log/syslog.2.gz | grep usb
结果输出将与先前的格式相同。
如果这是出于取证目的,可能会有更好的方法。