Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it possible to set the audio volume using the terminal?, instead of clicking the speaker icon in the topbar, the reason I want need to do this is because my keyboard does not have a volume increase/decrease buttons and I find it annoying to reach for the mouse.

share|improve this question

5 Answers 5

up vote 36 down vote accepted

For interactive usage you can use alsamixer. For scripting (e.g. binding to key combinations) take a look at amixer.

alsamixer is included by default in most systems.


To set the master volume use:

# Gets a list of simple mixer controls
$ amixer scontrols 

Then set it to the desired volume, as an example

$ amixer sset 'Master' 50%
share|improve this answer

Found in Openbox's configuration file rc.xml:

# increase by 3%
amixer -q sset Master 3%+

# decrease by 3%
amixer -q sset Master 3%-

# mute/unmute
amixer -q sset Master toggle

amixer manual page can give more details.

share|improve this answer

you can also try pamixer, a recent project that does exactly what you want. It is in the ArchLinux AUR repository with the same name.

share|improve this answer

If your system is using pulseaudio you could use pactl:

pactl set-sink-volume 0 +15%

or

pactl set-sink-volume 0 -5dB

though you could also specify an integer or a linear factor:

set-sink-volume SINK VOLUME [VOLUME ...]
          Set the volume of the specified sink (identified by its symbolic name or numerical index). VOLUME can be speci‐
          fied as an integer (e.g. 2000, 16384), a linear factor (e.g. 0.4, 1.100), a percentage (e.g. 10%, 100%) or a
          decibel value (e.g. 0dB, 20dB). If the volume specification start with a + or - the volume  adjustment  will  be
          relative to the current sink volume. A single volume value affects all channels; if multiple volume values are
          given their number has to match the sink's number of channels.
share|improve this answer
    
Note from arch linux wiki: pactl commands that take negative percentage arguments will fail with an 'invalid option' error. Use the standard shell -- pseudo argument to disable argument parsing before the negative argument. e.g. pactl set-sink-volume 1 -- -5% –  Jamie Cockburn Aug 25 at 8:01
    
@JamieCockburn - I'm not sure when was that written but I use archlinux and there is absolutely no need for the additional -- with negative values (percentage, db, integers... they all work fine). In fact, it's quite the opposite: if I use -- as per the wiki e.g. pactl set-sink-volume 1 -- -3% I get Invalid volume specification. –  don_crissti Aug 25 at 10:02
    
Must be dependent on shell then? I'm on ubuntu 14.04, with Xfce, and running the command from bash (4.3.11). If I omit the --, I get an invalid option. –  Jamie Cockburn Aug 25 at 10:58
    
@JamieCockburn - I don 't think the shell is relevant (for the record, it works fine for me with both bash and zsh). Probably earlier versions of pactl had this problem and upstream most likely fixed it (I'm using v. 6.0). –  don_crissti Aug 25 at 11:08
    
Right, well the standard pactl bundled with this distro seems to be 4.0. Hopefully my comment this will help others facing this issue! –  Jamie Cockburn Aug 25 at 11:44

in OS X use the following:

osascript -e "set Volume 7"    

highest

osascript -e "set Volume 1"    

lowest

osascript -e "set Volume 3.5"  

middle

You can even set the volume to other fractional levels:

osascript -e "set Volume 1.75"  

25% volume

share|improve this answer

Your Answer

 
discard

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.