# udev rule webcam

## trumee

Hi,

My laptop has an inbuilt webcam which points to /dev/video0, and an usb logitech webcam which appears at /dev/video1. I would like my logitech webcam to be at /dev/video5. Unfortunatelt, it didnt work as following messages show. any idea why?

```

#lsusb

Bus 002 Device 014: ID 046d:081d Logitech, Inc. HD Webcam C510

```

```

cat /etc/udev/rules.d/99-local.rules 

KERNEL=="video[0-9]*", SUBSYSTEM=="video4linux", ENV{ID_V4L_PRODUCT}=="UVC Camera (046d:081d)", NAME="video5", GROUP="video", OPTIONS="last_rule" 

```

On plugging the webcam

```

udevadm monitor

monitor will print the received events for:

UDEV - the event which udev sends out after rule processing

KERNEL - the kernel uevent

KERNEL[5304.549787] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)

KERNEL[5304.549846] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)

KERNEL[5304.549885] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.1 (usb)

KERNEL[5304.549908] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.2 (usb)

KERNEL[5304.796437] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.2/video4linux/video1 (video4linux)

KERNEL[5304.796493] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.2/input/input19 (input)

KERNEL[5304.796514] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.2/input/input19/event10 (input)

KERNEL[5304.796561] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.3 (usb)

UDEV  [5304.796876] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)

UDEV  [5304.797284] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)

UDEV  [5304.797745] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.2 (usb)

UDEV  [5304.797769] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.3 (usb)

UDEV  [5304.797781] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.1 (usb)

UDEV  [5304.798497] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.2/input/input19 (input)

UDEV  [5304.799113] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.2/input/input19/event10 (input)

UDEV  [5304.801067] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.2/video4linux/video1 (video4linux)

```

Finally 

```

#ls /dev/video*

/dev/video0  /dev/video1

```

/dev/video5 is never created!

----------

## quilosaq

 *trumee wrote:*   

> ...
> 
> ```
> 
> cat /etc/udev/rules.d/99-local.rules 
> ...

 

You can't use NAME="foo" for naming your webcam. NAME is reserved for network interface names. Use this rule:

```
KERNEL=="video[0-9]*", SUBSYSTEM=="video4linux", ENV{ID_V4L_PRODUCT}=="UVC Camera (046d:081d)", SYMLINK+="video5", GROUP="video", OPTIONS="last_rule" 
```

If it does work, try:

```
ACTION=="add", KERNEL=="video1", SUBSYSTEM=="video4linux", SYMLINK+="video5", GROUP="video", OPTIONS="last_rule" 
```

----------

## trumee

 *quilosaq wrote:*   

> 
> 
> You can't use NAME="foo" for naming your webcam. NAME is reserved for network interface names. Use this rule:
> 
> ```
> ...

 

Thanks, this did work. It created a /dev/video1 and a symlink /dev/video5.

```

# ls -la /dev/video*

crw-rw---- 1 root video 81, 0 Aug 10 06:44 /dev/video0

crw-rw---- 1 root video 81, 1 Aug 10 06:46 /dev/video1

lrwxrwxrwx 1 root root      6 Aug 10 06:46 /dev/video5 -> video1

```

Is it possible not to have /dev/video1 at all, and rather than symlink have a webcam directly addressable at /dev/video5?

----------

## PaulBredbury

Why your attachment to "video5"? That's a name to be avoided, e.g. this situation:

You plug in 5 webcams

Then you plug in the webcam that becomes video5, so where does the previous video5 go?

You're supposed to use a symlink that uses a different naming convention, e.g. "mycam" or whatever. Anything but "video$n".

----------

