1

Is there any method by which I can track down a list of flash drives that my laptop has accessed - namely their brand name, capacity and/or the name of the USB flash drive itself or the content it was carrying? Does my ubuntu or linux create history logs of the flash drives that have been plugged in? If so, what other information would this log contain?

Gitesh
  • 23

1 Answers1

4

When USB devices are connected to a Ubuntu Linux system, entries are placed in /var/log/dmesg. You can view those entires with dmesg | grep -i usb, but you won't find the details you are looking for there. E.g., I've included output from that command on a Ubuntu system below.

$ dmesg | grep -i usb
[    0.329504] usbcore: registered new interface driver usbfs
[    0.329538] usbcore: registered new interface driver hub
[    0.329662] usbcore: registered new device driver usb
[    0.754161] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.754430] ehci_hcd 0000:00:1d.7: new USB bus registered, assigned bus number 1
[    0.784367] ehci_hcd 0000:00:1d.7: USB 2.0 started, EHCI 1.00
[    0.784776] hub 1-0:1.0: USB hub found
[    0.784966] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.785009] uhci_hcd: USB Universal Host Controller Interface driver
[    0.785282] uhci_hcd 0000:00:1d.0: new USB bus registered, assigned bus number 2
[    0.785715] hub 2-0:1.0: USB hub found
[    0.786046] uhci_hcd 0000:00:1d.1: new USB bus registered, assigned bus number 3
[    0.786496] hub 3-0:1.0: USB hub found
[    0.786858] uhci_hcd 0000:00:1d.2: new USB bus registered, assigned bus number 4
[    0.787293] hub 4-0:1.0: USB hub found
[    0.787563] usbcore: registered new interface driver libusual
[1393889.831389] usbcore: registered new interface driver usblp
[10444614.128059] usb 1-6: new high-speed USB device number 2 using ehci_hcd
[10444614.329012] Initializing USB Mass Storage driver...
[10444614.337558] scsi2 : usb-storage 1-6:1.0
[10444614.337827] usbcore: registered new interface driver usb-storage
[10444614.337834] USB Mass Storage support registered.
$

You will also find entries in /var/log/syslog, but you won't find that level of detail there, either. You will just see something like the following which shows entries related to a USB flash drive I plugged into the Ubuntu system a few minutes ago:

$ grep -i usb /var/log/syslog
Feb 16 09:57:39 Neptune kernel: [10444614.128059] usb 1-6: new high-speed USB device number 2 using ehci_hcd
Feb 16 09:57:39 Neptune mtp-probe: checking bus 1, device 2: "/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-6"
Feb 16 09:57:39 Neptune kernel: [10444614.329012] Initializing USB Mass Storage driver...
Feb 16 09:57:39 Neptune kernel: [10444614.337558] scsi2 : usb-storage 1-6:1.0
Feb 16 09:57:39 Neptune kernel: [10444614.337827] usbcore: registered new interface driver usb-storage
Feb 16 09:57:39 Neptune kernel: [10444614.337834] USB Mass Storage support registered.

You can also find log entries inserted into kern.log when USB devices are attached with sudo cat /var/log/kern.log | grep -i usb, but those are similar to what you see above without the details you wish to see.

$ sudo cat /var/log/kern.log | grep -i usb
Feb 16 09:57:39 Neptune kernel: [10444614.128059] usb 1-6: new high-speed USB device number 2 using ehci_hcd
Feb 16 09:57:39 Neptune kernel: [10444614.329012] Initializing USB Mass Storage driver...
Feb 16 09:57:39 Neptune kernel: [10444614.337558] scsi2 : usb-storage 1-6:1.0
Feb 16 09:57:39 Neptune kernel: [10444614.337827] usbcore: registered new interface driver usb-storage
Feb 16 09:57:39 Neptune kernel: [10444614.337834] USB Mass Storage support registered.

Similar queries regarding the information that can be obtained regarding USB device attachments to a Ubuntu system have been asked in the past at the sister Stack Exchange site Ask Ubuntu. E.g.:

Can I view the history of connected usb?

Mounted Devices History

Does Ubuntu log when USB devices are connected?

At the Unix & Linux Stack Exchange site, in a response to Monitor history of USB flash drives someone suggested writing a script to record more details and provided details on what to include in the script, but as Ramhound stated, that won't give you information about past connections, since the entries that are created by default in system log files don't have that level of detail.

moonpoint
  • 5,168
  • suppose a flash drive was inserted in my laptop I really don't know about that but I want to know which all flash drive was inserted (with names and specification) a log kind of things . I just want to know that log or history stuff. – Gitesh Feb 17 '16 at 05:40