Set volume from terminal

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%

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.


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.