73

I have an integrated webcam in my laptop. I know that it works and that ubuntu recognized it because at installation it asked if I wanted a photo taken for some kind of image associated with my account. When I look in system settings, I do not see any webcam in the hardware section. I would like to disable the webcam like you can do in Windows, but as I can't find it in my hardware section, how can I disable it? I cannot even unplug it as it is integrated into the monitor. Am I looking in the wrong place?? I am using 12.04

Braiam
  • 69,112
bazz
  • 1,179

5 Answers5

69

Cameras are controlled by the uvcvideo kernel module.

You can disable the camera until reboot by opening a terminal and typing sudo modprobe -r uvcvideo. You will be asked for your password, and after typing it, if there are no errors shown in the terminal, your webcam should be disabled.

If you got the error message: modprobe: FATAL: Module uvcvideo is in use. after trying to remove the uvcvideo module, you can try to force its removal with the following: sudo rmmod -f uvcvideo (thanks thiagowfx)

To enable your webcam again, type sudo modprobe uvcvideo into terminal.

If you want the camera to be disabled when you reboot, then press ALT+F2 and paste this command:

gksu gedit /etc/modprobe.d/blacklist.conf

You will be asked for your password. After giving it, a text file should open. Paste at the end of the text file on a new line:

blacklist uvcvideo

Then save the file and exit. Next time you start Ubuntu, the webcam should be disabled.

undecim
  • 1,063
53

How to disable all webcams:

  1. Run (for pre ubuntu 18.04):
gksu gedit /etc/modprobe.d/blacklist.conf

Or run (for ubuntu 18.04 and later):

gedit admin:///etc/modprobe.d/blacklist.conf
  1. Then add...
blacklist uvcvideo

...at the bottom. Save the file and quit the text editor.

How to disable a single webcam:

  1. Find your webcam with lsusb. My output:
Bus 002 Device 002: ID 0bda:0328 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 8087:0a2b Intel Corp.
Bus 001 Device 002: ID 0bda:568c Realtek Semiconductor Corp.
Bus 001 Device 042: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

If it isn't clear which device is your webcam, you can try lsusb -t and look for Class=Video or Driver=uvcvideo or similar to guess which one it is. My output:

/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
    |__ Port 4: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    |__ Port 2: Dev 42, If 2, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 2: Dev 42, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 2: Dev 42, If 1, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 5: Dev 2, If 1, Class=Video, Driver=uvcvideo, 480M
    |__ Port 5: Dev 2, If 0, Class=Video, Driver=uvcvideo, 480M
    |__ Port 7: Dev 3, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 7: Dev 3, If 1, Class=Wireless, Driver=btusb, 12M
  1. Next, find the vendor id and device id from the output of lsusb surrounding the colon:
Bus 001 Device 002: ID 0bda:568c Realtek Semiconductor Corp.

So in my case, the vendor id is 0bda and the product id is 568c.

  1. Next go to:
cd /sys/bus/usb/devices/
  1. To find the correct directory do a grep there with the product id and if you get multiple results then also with the vendor id:
grep 568c */idProduct

returned:

1-5/idProduct:568c

and

grep 0bda */idVendor

returned:

1-5/idVendor:0bda
2-4/idVendor:0bda

In my case 1-5 is what I need.

  1. cd into the directory from the previous step.

  2. The file bConfigurationValue in this directory needs to contain a 0 to disable the device or a 1 to enable it. But this file is owned by root so to alter it (change the 0 to a 1 to enable) ...

echo 0 | sudo tee bConfigurationValue

...to disable. You can check the camera and it will be disabled.

  1. This is not permanent yet. A reboot will set it back to what it was before. To make it permanent:
echo 0 | sudo tee /sys/bus/usb/devices/1-5/bConfigurationValue

(where 1-5 is the directory we used and use a 1 to enable)

Carolus
  • 600
Rinzwind
  • 309,379
42

How about just taping it with some black colored tape? Take some black tape and put it on the webcam. Webcam disabled successfully! Unlike the answers above, this method works against malware attacks that try to enable your webcam as well!

HaroldW
  • 439
3

I had luck with going into the BIOS for my laptop (Dell XPS 15 9570), where there was an option to disable the built-in webcam and microphone.

0

TL;DR Execute the following command: echo 1 | sudo tee $(readlink -f $(readlink -f /sys/class/video4linux/video0/device)/../port)/disable

I had a similar problem on Arch Linux and was able to solve it thanks Robert Siemer's answer on Unix StackExchange. Since it uses only standard commands and interfaces, it should also work for Ubuntu.

You should be able to identify your webcam device via lsusb as Rinzwind's suggested. If the webcam is listed there, you should be able to disable the camera by disabling the USB port the camera is connected to. I prefer this solution over Rinzwind's answer, since it also hides the disabled webcam from the system (eg. lsusb output).

First we need to find the sys-path that represents the USB port. All cameras of a system are represented in the /sys/class/video4linux tree. From there we can get the path of the USB port by resolving two sym-links. Here is an example for the first camera of a system (video0):

$ readlink -f $(readlink -f /sys/class/video4linux/video0/device)/../port

This returns the sys-path of the USB port the webcam is connected to. In my case it is:

/sys/devices/pci0000:00/0000:00:14.0/usb3/3-0:1.0/usb3-port8

Now we can simply enable and disable the USB port with the following commands:

$ USBPATH=$(readlink -f $(readlink -f /sys/class/video4linux/video0/device)/../port)
$ echo 1 | sudo tee $USBPATH/disable # disable the webcam port
$ echo 0 | sudo tee $USBPATH/disable # enable the port again

The changes would be lost after a reboot, but you could add the disable-command to a simple script and run it on boot. I am using the following systemd service:

[Unit]
Description=Disable the built-in camera.

[Service] Type=oneshot Environment="USBPATH=/sys/devices/pci0000:00/0000:00:14.0/usb3/3-0:1.0/usb3-port8" RemainAfterExit=true ExecStart=/bin/bash -c "echo 1 > $USBPATH/disable" ExecStop=/bin/bash -c "echo 0 > $USBPATH/disable"

[Install] WantedBy=default.target

Don't forget to adapt USBPATH to your system when copying the service.

Please note that the fn-key cannot be used to re-enable the camera, if it has been disabled via the command above. It needs to be enabled via the sys-tree again.

Torben
  • 281