Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

How can I tell my Ubuntu installation to execute some scripts when I connect a specific hardware?

For example: I have an external eSATA disk. When this (and only this) disk is plugged in, my notebook should execute the script.

Additionally it would be nice if I get informed about those automatic executions. The most beautiful thing would be an indicator in my gnome panel. But a terminal that pops up and shows the output of the script would also be ok.

share|improve this question
up vote 1 down vote accepted

it is possible to tell udev to execute something when the device is plugged in. Here you see how someone else has done it with a usb disk, doing it with a e-sata disk should be very similar.

share|improve this answer
wonderful article. exactly what i wanted. thanks! – Ethan Leroy Nov 7 '10 at 2:37

You'd have to have the script running as a user daemon, listening for hal events over D-Bus.

share|improve this answer

You can use RUN in a udev rule to accomplish at least part of this. See for example this howto:

That doesn't cover notification or output -- you could have the script put its results in a file, and have something else running in your account monitor that file. (There's a number of existing programs made to monitor files in a GUI -- there's a gkrellm plugin, for example.)

The suggestion of making a background process listening to dbus events is another promising approach, and is in some ways more elegant (not the least being that you don't need to mess with system-wide configuration). But it also requires a little more linux-plumbing-level knowledge and programming work.

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.