Ubuntu – Does Ubuntu log when USB devices are connected


When I connect a USB drive to an Ubuntu OS, would there be a text file which contains details of that connection and if so, where is that file located ? What is the name of that file?

Best Answer

Does Ubuntu log when USB devices are connected?

Yes, Ubuntu logs when a USB device is connected. The file is /var/log/syslog. You can also view it by issuing the command dmesg (with optional -c argument to clear the log) or graphically using Log file viewer.

Is this file deleted upon shutdown?

No, This log does not get wiped upon shutdown. After a size limit is reached the logs are rotated, meaning new logs are continually written to /var/log/syslog while older records are pushed to compressed files named /var/log/syslog.1.gz, syslog.2.gz, ... in the same /var/log directory.

You can view the /var/log directory with rotated log files below:

enter image description here

Related Question