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 have one camera USB which on connect makes a place as /dev/video0, now using other applications while its reading /dev/video0 works fine, after some time like couple of hours later, automatically the /dev/video0 disappear and it becomes /dev/video1. As a result the same application stop working to capture it because there is no more /dev/video0.

How is it possible to apply a BASH loop to have a clone of /dev/video0 and /dev/video1 always. Like if video0 is lost but video1 is present then the script will clone exactly one another.

Any idea, how to fix it so that we have always /dev/video0 and /dev/video1 clone of any one another?

Follow up:

Well answered too

share|improve this question
up vote 4 down vote accepted

This is pretty common, but basically you shouldn't mess with stuff under /dev it's a special file system that gets regenerated causing just the problem your talking about. instead you need to set up a udev rule to make sure your devices are always getting the same name.

Use this information from comment 5, to setup your rules file.

It's a bit complicated to phase correctly in this site, but basically:

  1. Get your device info with udevinfo -a -p $(udevinfo -q path -n /dev/video0) for each device.
  2. Find something different about the devices
  3. Head to /etc/udev/rules.d and make a new rules file (with a low number like 11)
  4. modify the file to use your new attribute and give your device a new/static name

It's very complicated, but works quite well.

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.