For example, I have device /dev/sdb. How do I find out it's udev subsystem?
If you specifically want the subsystem:
When you're writing udev rules, the most useful command is
This prints out rules that you can use to match the device in udev rules. The first block is about the device itself, and the subsequent blocks are about its ancestors in the device tree. The only caveat is that you cannot mix keys that correspond to different ancestors. For example, given this excerpt
then you can match this device with
Another way to obtain information for use in rules is with
This prints device property values of the form
If your device doesn't have a
(not a useful example in this case — this is useful for devices whose category isn't common and don't have an entry under
When you change udev rules, they are read automatically; however, they are only applied to devices that are subsequently plugged into the system. To apply the new rules to an already-connected device, use
NOTE: the above queries the UDEV database for device information,
Differences between these 2 commands
@sepero's answer is showing information just pertaining to the UDEV device at the leaf node.
My answer shows the attributes as it walks the entire
You can see the difference between these two.
NOTE: I'm running on Fedora 19, using version 204 of