Toggling webcam from commandline?

I am trying to figure out if its possible to – from within the command-line – enable/disable the webcam, with a command that can be ran through a keybind? My laptop, a Thinkpad T450 doesn’t have a hard switch to turn off the webcam, and it is a security feature I’d really like to have. Preferably something that can be done without a computer restart would be ideal!


Hi @ZachFros04, and welcome to the community! If you haven’t already, check out the #start-here category when you have the time, it contains useful information on using the forum.

To your question: The safest way is probably to disable the webcam’s driver, as that will prevent any program running without root privileges from turning it back on. You can use modprobe for that:

$ sudo modprobe -r uvcvideo

removes the driver from the kernel (disables the cam), while

$ sudo modprobe uvcvideo

reinserts it (enables the cam). These settings don’t persist after reboot, so I would additionally add the driver to the module blacklist by adding

# disable webcam
blacklist uvcvideo

to /etc/modules.d/blacklist.conf. This way, the cam will be disabled by default, and you can turn it on using the command above when needed, and rest assured that it will be turned back off at the next boot in case you forget.

1 Like

Awesome, thank you!!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.