I want to know how I can list all udev rules.

I know that in they can be potentially stored as lines (one line = one rule) in *.rules files in these directories


Therefore I though I can find all rules by simple concating all the *.rules files in those directories. This seems not to be working (because some rules are executed which I cannot find anyware as rules in these directories).

At best I thought that there is a command to the udevadm interface which will let me print out all the rules that udev currently has.

To be certain I did a review of man udevadm and especially the part about udevadm info [parameters] does not seem to yield any result.

Given that udev allows for a multitude of files and rules all targeted for the very same device, it is frustrating not to know an efficient/feasible way to compose all the rules for a device.

  • 4
    Unfortunately, if you are using systemd, it's version of udev has a complex "persistent naming scheme" that's hard coded into udevd, so you are right, just parsing the rules.d stuff could leave a lot of mysteries. – goldilocks Feb 1 '15 at 15:46

If you use:

udevadm monitor

you get an entry for each action taken by KERNEL and UDEV. Typically add, change, remove. If you include the --property option:

udevadm monitor --property

You will get a listing of what properties are used.

As one can test udev rules with udevadm:

udevadm test $(udevadm info -q path -n <device>)

one could test out something as this:

udevadm test $(udevadm info -q path -n <device>) 2>&1 | \
sed -n 's/.* \(\/[^ ]*\)\.rules:\([0-9]\+\)/\1.rules \2/p' | \
while read -r f n; do printf "%03d:%-50s " $n "$f"; sed -n ${n}p $f; done

but not sure how reliable this is. Anyhow, using e.g. video1 for <device> that could yield something like:

031:/lib/udev/rules.d/50-udev-default.rules            SUBSYSTEM=="video4linux", GROUP="video"
007:/lib/udev/rules.d/60-persistent-v4l.rules          IMPORT{program}="v4l_id $devnode"
009:/lib/udev/rules.d/60-persistent-v4l.rules          SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"
010:/lib/udev/rules.d/60-persistent-v4l.rules          KERNEL=="video*", ENV{ID_SERIAL}=="?*", SYMLINK+="v4l/by-id/$env{ID_BUS}-$env{ID_SERIAL}-video-index$attr{index}"
016:/lib/udev/rules.d/60-persistent-v4l.rules          IMPORT{builtin}="path_id"
017:/lib/udev/rules.d/60-persistent-v4l.rules          ENV{ID_PATH}=="?*", KERNEL=="video*|vbi*", SYMLINK+="v4l/by-path/$env{ID_PATH}-video-index$attr{index}"
015:/lib/udev/rules.d/73-seat-late.rules               TAG=="uaccess", ENV{MAJOR}!="", RUN{builtin}+="uaccess"
006:/etc/udev/rules.d/83-webcam.rules                  KERNEL=="video[0-9]", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", SYMLINK+="video-webcam1"

But guess looking at the test as a whole is better. Also note the message:

This program is for debugging only, it does not run any program specified by a RUN key. It may show incorrect results, because some values may be different, or not available at a simulation run.

You can also set


in udev.conf and restart udev (reload udev) to get a somewhat more verbose output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.