Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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
up vote 3 down vote accepted

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.

share|improve this answer
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
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'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.

Not a big deal, just nice to know when your bashing your head against the wall. Har har!

share|improve this answer

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/", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sda1",RUN+="/bin/sh /usr/bin/udev/", OPTIONS="last_rule"

adding the OPTIONS=last_rule parameter did the trick.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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