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'd like to run a script every time that a DVD is inserted into the drive.

Ideally, it would be auto-mounted and then a script would be run. The script would NOT be on the drive (not looking for autorun functionality a la Windows).

A command line solution would be optimal!

share|improve this question
up vote 3 down vote accepted
  • Insert a dvd and when this screen pops up

enter image description here

  • Select open with other application You will then see this window

enter image description here

  • browse to your script and add and select it then tick the always perform this action tick box

enter image description here

You can change this back later by opening nautilus preferences and changing the media handling preference.

enter image description here

Hope this helps.

share|improve this answer
Excellent. This is a headless box without x installed - I found information on /etc/udev/rules.d/70-persistent-cd.rules which seems to allow me to do this as well from the bash prompt. – tkone Mar 2 '11 at 12:25
@todd if you update your question I will add an alternate command line solution to my answer – Allan Mar 2 '11 at 12:46
@Todd Or you can add an answer yourself for a cli solution. (Tip: Next time have that kind of detail in your question) – Jorge Castro Mar 5 '11 at 15:44
In mine (ubuntu 12.10) there is no option to run a custom command. The "media" tab is also missing from the preferences. – matt burns Jan 21 '13 at 13:38

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.