I'm trying to create a udev rule to unlock my computer when I connect my phone by USB. I could not find that that rule was being ran and so I tried a much simpler rule. This is the rule (anonymized) :

KERNEL=="sd?1", ATTRS{idVendor}=="****", ATTRS{idProduct}=="****", SYMLINK+="phone", RUN+="touch /home/user/udev.touch"

I know that the rule is running because the link phone -> sdc1 is being created but the file is not being created. Are there security setting that I have to enable for the file to run an external program?

  • Have you tried using the full path? /usr/bin/touch – arrange Oct 10 '11 at 20:31
  • I just tried it. That is now working. Why does udev not search the path? and does that mean that I will have to have the full path for every command in the script that I want to run as well? – Andrew Redd Oct 10 '11 at 20:49

You must use full path in the RUN key because (man udev)

If no absolute path is given, the program is expected to live in /lib/udev, otherwise the absolute path must be specified. Program name and arguments are separated by spaces. Single quotes can be used to specify arguments with spaces.

Nevertheless the (bash) script itself should behave as normal, that is you don't need to specify the path.

  • It seems that only the very simplest of commands works. Scripts don't run either even when the entire path is given – Andrew Redd Oct 10 '11 at 22:03
  • 1
    Please post the full script you're trying to run. Be aware that the script is run as root, not as a regular user. – arrange Oct 11 '11 at 7:56
  • I found I had a bad path to bash. The script on add works now but the remove rule does not run. I'll ask as a different question. – Andrew Redd Oct 11 '11 at 22:41

I was having the same problem with udev. I tried almost everything to get to scripts to work when adding and removing devices.

This is the code I made:

ACTION=="add", KERNEL=="sda1", SUBSYSTEMS=="scsi", ATTRS{model}=="AVV207-0        ", SYMLINK+="Lacie", MODE="0666", RUN+="/bin/sh /usr/bin/udev/lacie-add.sh", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sda1", RUN+="/bin/sh /usr/bin/udev/lacie-del.sh", OPTIONS="last_rule"

Adding the OPTIONS="last_rule" parameter did the trick.


I've had this issue as well, and I can confirm as of 12.04 you need to specify the full bash path and full bash script for the RUN command to work.

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.