What is the state-of-the-art method for automatically executing custom scripts upon USB device plug-in under current Linux distributions like Debian/CentOS/Fedora?For example if you want to automatically mount/copy some files/umount a USB mass storage device based on its UUID (or device ID etc.).
How to run custom scripts upon USB device plug-in?
usb;udev;uuid
Put a line like this in a file in /etc/udev/rules.d:KERNEL==sd*, ATTRS{vendor}==Yoyodyne, ATTRS{model}==XYZ42, ATTRS{serial}==123465789, RUN+=/pathto/scriptAdd a clause like NAME=subdir/mydisk%n if you want to use a custom entry path under /dev.Run udevadm info -a -n sdb to see what attributes you can match against (attribute==value; replace sdb by the device name automatically assigned to the disk, corresponding to the new entry created in /dev when you plug it in). Note that you can use ATTRS clauses from any one stanza: you can pick any stanza, but the ATTRS clauses must all come from the same stanza, you can't mix and match. You can mix ATTRS clauses with other types of clauses listed in a different stanza.