Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect when a flash drive is plugged in under Linux?

Tags:

python

linux

How can I detect when a flash drive is plugged in? I'm using a bare Debian installation, without any GUI and want to be notified in my Python script when a new flash drive appears... I know that D-BUS distributes such information, but i dont want to use D-BUS. Is there a more bare access to that information? Shouldn't that be available under /proc or /sys? How can I "connect" to that source?

Bye falstaff

like image 840
falstaff Avatar asked Oct 05 '09 07:10

falstaff


People also ask

How do I check my USB plug in history?

If you don't know the name of your computer, go to Settings > System > About. Your computer name is shown at the top. Click the Start button to see the USB history. You can then expand the results to see details such as the time and date it was last used.


1 Answers

All mayor Linux distros include udev, that allows you to write custom scripts on hardware events.

like image 131
PeterMmm Avatar answered Oct 29 '22 01:10

PeterMmm