Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to control the volume using my programming script. How can I do the following in Fedora 15, Ubuntu linux?

  1. Mute/ Unmute
  2. Volume up and volume down

Note: Please note that I use a web USB microphone/speaker and also Analogue microphone/speaker. I want to apply to all to be sure.

share|improve this question
up vote 37 down vote accepted

You can use amixer. It's in the alsa-utils package on ubuntu/debian.

Run it without parameters to get an overview about your devices.


Then use the set command to set the volumn. For example to set the master channel to 50%:

amixer set Master 50%

Note the "%" sign, without it it will treat the value as 0 - 65536 level.

share|improve this answer
Thanks! there are two ways to do this 1. As your excellent example: amixer set Master mute; amixer set Master unmute; 2. yum -y install xdotool; xdotool key XF86AudioRaiseVolume; xdotool key XF86AudioLowerVolume; – YumYumYum Sep 20 '11 at 11:05
And as an addition, you can increase or decrease the volume by amixer set Master 10%+ and amixer set Master 10%- – user Apr 7 '12 at 21:25
This does not work in Ubuntu. – Cerin May 24 '12 at 14:37
I disagree @Cerin. This works on Ubuntu LTS 12 right now. Note that the M in master is case sensitive (must be uppercase). – ashes999 Apr 9 '14 at 16:35
Cerin is right. This does not work. What works is : amixer -D pulse sset Master 50% – shivams May 7 '15 at 11:22

To Mute:

amixer -D pulse sset Master mute

To Unmute:

amixer -D pulse sset Master unmute

To turn volume up 5%:

amixer -D pulse sset Master 5%+

To turn volume down 5%:

amixer -D pulse sset Master 5%-

share|improve this answer

Your Answer


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

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