Ubuntu: Command to mute and unmute a microphone


During voice / video conversations online I would like to mute/unmute the microphone without having to go through all these steps each time:

  • Sound indicator, Sound preferences, Select Input, Mute or unmute the microphone.

I'm looking for either:

  • an application that can do this from the commandline,
  • a way I can assign a keyboard shortcut that can mute/unmute the microphone


Go to

System Preferences then Keyboard and click Shortcuts then Custom Shortcuts:

Click on Add

Fill in:

Toggle microphone  


amixer set Capture toggle  

For usb webcams you need to chose device (-c 1), or maybe another number.

amixer -c 1 sset Mic toggle  

Click Apply and then associate a new key with this command (e.g. the Pause/Break key).


pacmd is the command line interface to PulseAudio (the sound subsystem used in recent releases). I don't know what the exact command is you'd need but I think you'd want to play with the set-sink-input-mute function.

pacmd is interactive when run without instructions so you have a good opportunity to play around with it and convert that into a one-line function for toggling mute.


You can mute the microphone with

amixer set Capture nocap  

and unmute the microphone with

amixer set Capture cap  


amixer set Capture toggle && amixer get Capture | grep '\[off\]' && notify-send "MIC switched OFF" || notify-send "MIC switched ON"  


You can mute with:

/usr/bin/amixer -q -c 0 sset 'Master',0 mute  


/usr/bin/amixer -q -c 0 sset 'Master',0 unmute  

You just need to replace 'Master' with the appropriate mixer name, on the terminal use "amixer" to get a list of mixer devices.

About setting the keyboard shortcut check the answers for How can I find which command is bound to a given keyboard shortcut?


the gnome-shell extension nothing to say, which can be installed from its extensions.gnome.org page, provides a microphone icon, mouse and keyboard control, and walkie-talkie style push-to-talk.


Simply mute/unmute with this command:

amixer -q -D pulse sset Capture toggle  

Inspired by Mark Rooney's comment for muting/unmuting sound.


To toggle mute of default microphone in pulseaudio:

  1. Make sure that you have pacmd (from pulseaudio-utils package) and notify-send (from libnotify-bin).
  2. Use this script:
#!/bin/sh    pacmd list-sources | awk '\  BEGIN {default_found=0;}    /^[\t ]*\*/ {default_found=1;}    /^[\t ]*name:/ {      if (default_found) {          name=$2;          gsub("[<>]", "", name);      }  }    /^[\t ]*muted:/ {      if (default_found) {          if ($2=="yes") {              mute=0;              icon="microphone-sensitivity-medium";              status="unmuted"          } else {              mute=1;              icon="microphone-sensitivity-muted";              status="muted"          }          system("pacmd set-source-mute " name " " mute);          system("notify-send --expire-time 1000 --icon " icon " Microphone: " status);          exit;      }  }    /^[\t ]*index:/{if (default_found) exit;}'  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »