Try amixer
:
amixer sset 'Capture' cap
amixer sset 'Capture' nocap
You may have to find out the control name for the microphone in your setup if you use additional hardware. amixer scontrols
will list the controls you have.
There's also pactl
command which should work on PulseAudio level. Identify the mic in the output of pactl list sources
and then mute / unmute the source by number
pactl set-source-mute 0 1 # mute source 0
pactl set-source-mute 0 0 # unmute source 0