Set audio volume from terminal

Is it possible to set the audio volume using the terminal instead of clicking the speaker icon in the top bar?

I want to do this because my keyboard does not have volume increase/decrease buttons, and I find it annoying to reach for the mouse.

Asked By: Tristian


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%
Answered By: Renan

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.

Answered By: enzotib

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.

Answered By: fradeve

In OS X use the following:

# highest
osascript -e "set Volume 7"
# lowest
osascript -e "set Volume 1"
# middle
osascript -e "set Volume 3.5"  

You can even set the volume to other fractional levels:

# 25%
osascript -e "set Volume 1.75"
Answered By: 1''

If your system is using pulseaudio you could use pactl:

pactl set-sink-volume 0 +15%


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.
Answered By: don_crissti

I know this is an old one. Since Alsa and pulseaudio are so connected, this answer from askubuntu helped me manage the volume from both my main sound and the HDMI:

increase volume

amixer -q -D pulse sset Master 10%+

decrease volume

amixer -q -D pulse sset Master 10%-

toggle mute

amixer -q -D pulse sset Master toggle

Other amixer sset commands work too.

Answered By: Mathter

These are “more natural for human ear”.

To get the master in the alsamixer units, use:

amixer -M get Master

To raise the volume by 5% in the alsamixer units, for example:

amixer -M set Master 5%+

Answered By: Robson

So, answer the question first: To increase the Master volume level by 10%, consider this snippet:

amixer -q sset Master 10%+

You can also set it to a specific value:

amixer -q sset Master 78%

This can also be found in other answers, but I try to extend to the comment by Eric Leschinski, which basically is a TL:DR;-ish answer.

To read the Master Volume level (human readable), you can use:

amixer sget Master  

To get the number in percent (from 0% to 100%), you can pipe it into grep and awk:

amixer sget Master | grep 'Right:' | awk -F'[][]' '{ print $2 }'

On my notebook, I only have a mono-speaker, so the right code for me was:

amixer sget Master | grep 'Mono:' | awk -F'[][]' '{ print $2 }'
Answered By: i_want_more_edits

I use pipewire. There are a couple of "native tools" for volume adjustment in pipewire:

  1. pw-cli (pipewire client) meets my definition of very difficult to use, but it does do volume control (among other things) if you care to decipher it.

  2. wpctl (wireplumber control) is much more user-friendly IMHO. It’s actually part of wireplumber – a separate, but related app that typically gets installed with apt install pipewire.

A couple of typical commands to check/control volume in wpctl are:

$ wpctl get-volume @DEFAULT_AUDIO_SINK@
$ wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ 
# volume increases :)

… which could be simplified with some aliases &/or kbd shortcuts.

There is no manual, but Arch has a good reference with links to the official docs.

Answered By: Seamus
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.