Command to mute and unmute a microphone

During voice / video conversations 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 command line,
  • a way I can assign a keyboard shortcut that can mute/unmute the microphone

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?

Answered By: João Pinto

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.

Answered By: Oli

Go to System Preferences then Keyboard and click Shortcuts then Custom Shortcuts:

Keyboard shortcuts

Click on Add

Custom shortcut

Fill in:

Toggle Microphone


amixer set Capture toggle

For USB webcams you need to chose the 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).

You can mute the microphone with

amixer set Capture nocap

and unmute the microphone with

amixer set Capture cap
Answered By: Hickersson
amixer set Capture toggle && amixer get Capture | grep '[off]' && notify-send "MIC switched OFF" || notify-send "MIC switched ON"
Answered By: vladimirich

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

Answered By: wouter bolsterlee

Simply mute/unmute with this command:

amixer -D pulse sset Capture toggle

You can also add notification to make sure it’s on or off, as per vladimirich answer to the same question

amixer -D pulse sset Capture toggle && amixer get Capture | grep '[off]' && notify-send "MIC switched OFF" || notify-send "MIC switched ON"

Inspired by Mark Rooney’s answer on muting/unmuting sound.

Answered By: kujaw

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:

pacmd list-sources | awk '
BEGIN {default_found=0;}

/^[t ]**/ {default_found=1;}

/^[t ]*name:/ {
    if (default_found) {
        gsub("[<>]", "", name);

/^[t ]*muted:/ {
    if (default_found) {
        if ($2=="yes") {
        } else {
        system("pacmd set-source-mute " name " " mute);
        system("notify-send --expire-time 1000 --icon " icon " Microphone: " status);

/^[t ]*index:/{if (default_found) exit;}'
Answered By: Aleksey Alekseev

Complementing the response ofLucian Adrian Grijincu and vladimirich

Add the display of a message by enabling/disabling the microphone.

Run multiple commands on the shortcut command:

$ sh -c "amixer set Capture toggle ; amixer get Capture | 
     grep '[off]' && notify-send 'MIC switched OFF' || notify-send 'MIC switched ON'"
Answered By: Roberto Nascimento

Based on answer above

I like to create my own terminal stupid shortcuts. So to configrure m = mute; mm = unmute

I added this to ./.bashrc

# ~/.bashrc
alias m="amixer set Capture nocap"
alias mm="amixer set Capture cap"


interesting enough, yesterday I’ve re-enable autostart of “Screen Locker (Launch screen locker program) in the menu> sessions and startup > Application Autostart and now my hardware mute button start working (after restart) I have no idea why (XFCE Xubuntu 18.08)

I’m still keeping those terminal shortcuts but just wanted to point out

Answered By: equivalent8

I switch between a USB webcam/mic and my internal mic and the other solutions typically work on the "default" device which is often not the device I’m actively using so I wrote this to mute all microphones

pacmd list-sources | 
        grep -oP 'index: d+' | 
        awk '{ print $2 }' | 
        xargs -I{} pactl set-source-mute {} toggle 
        && pacmd list-sources | 
        grep -oP 'muted: (?:yes|no)'
Answered By: blockloop

Using answer of vladimirich I created a script, because we can’t execute multiple commands in a hotkey entry.

  • so I made a script with the line:

    amixer set Capture toggle && amixer get Capture | grep '[off]' && notify-send "MIC switched OFF" || notify-send "MIC switched ON"
  • put it in a .sh file

  • and call it in the hotkey command with sh <path to>.

Works like a charm.

Answered By: WegPast

Here’s an example for toggling a selected audio source only using CLI (command line interface) only:

  1. Get list of possible sound cards in the system:

    pacmd list-sources | grep card:


    card: 0 <alsa_card.usb-Microsoft_Microsoft___LifeCam_HD-5000-02>

    card: 1 <alsa_card.pci-0000_00_1b.0>

  2. Select some way to identify the correct card. If you trust that your configuration does not change, you can use card number and simply run (e.g. if you want to control the card 1):

    pactl set-source-mute 1 toggle

    However, if you instead want to prepare for a case where e.g. your USB connected source is not always connected and you only want to mute that, you can use some way to detect it from the above output. Let’s say you want to control the LifeCam HD-5000 only. Then you could do it like this:

    pacmd list-sources | grep -P "card: d+ <[^>]*LifeCam_HD-5000[^>]*>" | awk '{print $2}' | xargs -rn1 -I_ pactl set-source-mute _ toggle

    This queries all audio sources from PulseAudio, extracts card rows that have LifeCam_HD-5000 as part of their name, uses awk to extract the second part of the row to get the card number and passes it to pactl to toggle correct source muting using xargs to put the number in correct position in the command. The -rn1 flag tells xargs to do nothing if the card number couldn’t be found.

    If you need to know the mute status for some scripting, you can do

    pacmd dump | grep -P 'set-source-mute [^ ]*LifeCam_HD-5000' | awk '{print $3}'

    which will emit yes (muted) or no (not muted).

Answered By: Mikko Rantalainen

On 20.04, I see option to set a shortcut for the same under Settings -> Keyboard Shortcuts -> Sound and Media.

enter image description here

There is no default key assigned though.

Answered By: Urmil Parikh