Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would, preferably, like to know of a command I can run that will let me know whether a webcam is on/off or recording/not recording, etc. Maybe a way to see if any programs are currently accessing it would work as well. If there is no command line option, I'm not opposed to writing a small c or c++ program to do this, but I haven't been able to find a way to do that either.

share|improve this question

migrated from serverfault.com Nov 2 '12 at 14:42

This question came from our site for system and network administrators.

2 Answers 2

up vote 3 down vote accepted

I think lsof /dev/video0 should find the process which has the webcam (the first webcam should default to /dev/video0 but if you have more then one you may have a /dev/video1 /dev/video2 and so on, also some errors may cause 0 to be skipped).`

share|improve this answer
This worked great, thank you! lsof -t /dev/video0 returns the PID of whatever is accessing the camera. –  studio Nov 2 '12 at 10:59

Video devices in Linux are accessed using v4l interface(Video 4 Linux). There's a library and a command line tool called v4l2-ctl in the v4l-utils package. However, I don't think there's a way to tell if a process is recording from it, just whether a process is connected, as described by @RomanA.Taycher

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.