I would like to enable or disable the microphone in the Terminal. How can I do it? For example, I use sudo modprobe -r uvcvideo to disable the webcam and sudo modprobe uvcvideo to enable it. Is there a command to to the same thing with the microphone?


You could try

amixer sset Capture toggle

which will toggle the capture of your mic (on/off). You could even connect it to a key (e.g. XF86AdioMicMute -if you've got a key that invokes this event), so you would not even have to open a terminal for this.

  • I need to add the "-D pulse" option to make it work in my system.Otherwise I would get the "amixer: Unable to find simple control 'Capture',0" error. – Parsa Mousavi Jun 12 '20 at 20:10
  • 1
    depends how you configured your /etc/pulse/default.pa (load-module module-alsa-source device=hw:1,0,0) - but yes, it won't hurt – kanehekili Jun 12 '20 at 20:18
  • Can I do enable/disable directly instead of toggle? – fedeUbuntu Jun 12 '20 at 21:11
  • No, not that I know of.. Alsa (which is below pulse) can only toggle. If my answer solves your problem, I would be happy if you accept it... – kanehekili Jun 13 '20 at 1:00
  • @fedeUbuntu If "Front Left: Capture" also points to your mic, you can use this command (e.g. as an autostart script) to disable the mic when it is on only: mic="$(amixer | grep "Front Left: Capture" | awk -F' ' '{print $7}' | sed -e "s/\[//" -e "s/\]//")"; if [[ "$mic" == "on" ]]; then amixer sset Capture toggle; fi – Sadi Mar 24 at 13:17
wutang@shaolin:~$ gsettings list-recursively | grep mic
org.gnome.desktop.privacy disable-microphone false
org.gnome.shell.overrides dynamic-workspaces true
org.gnome.settings-daemon.plugins.media-keys mic-mute ['']
org.gnome.settings-daemon.plugins.media-keys mic-mute-static ['XF86AudioMicMute']
com.canonical.unity.settings-daemon.plugins.media-keys mic-mute 'XF86AudioMicMute'
org.gnome.mutter dynamic-workspaces true
wutang@shaolin:~$ gsettings set org.gnome.desktop.privacy disable-microphone true

I actually don't know the effect of this... I am using MATE and a lot of gnome stuff doesn't have any effect on MATE so I cannot confirm. There is usually an org.mate counterpart, but not for this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.