Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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 want to when I plug an usb device to my laptop, a script will be run just one time. So I use the udev rules system in UBUNTU 12.04. I wrote the below udev rule:

ACTION=="add", SUBSYSTEMS=="usb", RUN+="/home/hossein/Desktop/test".

The below commands is written in the test script:

echo Hello >> /home/hossein/Desktop/file.txt

my problem is that when I attach a usb device, about 13 times the word Hello is written in the file.txt while I just expect one time occurrence of Hello. What's the reason?

share|improve this question
up vote 1 down vote accepted

You need to make your udev rule more specific, try adding this to your rule:


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.