How to Use ALSA Utilities to Manage Linux Audio from the Terminal

Desktop speaker close-up

The Advanced Linux Sound Architecture (ALSA) provides Linux computers with audio support. Popular distros such as Ubuntu and Arch Linux run it by default, so there’s a good chance you’re using it right now to play music through your speakers or headphones.

In this article we’ll show you two ways to adjust the volume of that playback by using the Alsamixer and Amixer utilities.

The installation for this project is minimal. Both Alsamixer and Amixer should arrive as part of the Alsa-utils package. Run these commands to install that package:

Ubuntu:

Arch Linux:

The easier of the two utilities to use is Alsamixer. It works as part of an Ncurses interface, which allows you to remain in the terminal but provides a graphical representation of your sound card and its properties.

Running that command will show you something like what is pictured in the following image.

Alsamixer default

Here you can see at the top of my screen the name of my sound card, the type of view I’m in, and the item that’s currently selected. You can change those options at your will.

Sound Card Selection

You can select a different sound card by pressing F6. It will bring up a menu that shows the known sound cards on your system. You can also enter the name of a sound card if it isn’t shown in the menu.

Alsamixer sound card selection

Views

You can change your view to see different controls for what volume options ALSA can control. The default you see above is the “Playback” view. You can choose “Capture” by pressing F4 and “All” (which includes “Playback” and “Capture”) by pressing F5. Return to “Playback” with F3.

“Capture” view

Alsamixer "capture" view

“All” view

Alsamixer "all" view

Movement and Volume Adjustment

Each type of view may have more options than you see in the screenshots here. Move right and left, respectively, through those options by pressing the Left and Right arrow keys.

Adjust each volume with Down or PgDown to reduce the volume of a channel and Up or PgUp to increase the volume.

You can mute any channel by pressing m.

Check out the full view of options by pressing F1 to get the screen pictured below.

Alsamixer help dialogue

With Amixer you don’t get a graphical environment. Instead, you use commands to set the various volumes of each channel for your sound cards.

View your available options and commands with amixer help.

Amixer help dialogue

Then look at your available controls with amixer scontrols.

Amixer scontrols command

These are the audio controls you can change. You can adjust them with various commands that follow the basic pattern of amixer -c <card-number> set <control> <value>.

  • Set the Master volume on the first sound card to 100%: amixer -c 0 set Master 100%
  • Set the Master volume on the second sound card to 50%: amixer -c 1 set Master 50%
  • Set the Mic volume on the first sound card to five decibels: amixer -c 0 set Mic 5db
  • Increase the Mic volume on the first sound card two decibels : amixer -c 0 set Mic 2db+
  • Mute the Master control on the first sound card: amixer -c 0 set Master mute
  • Unmute the Master control on the first sound card: amixer -c 0 set Master unmute

Output for these commands should produce something that looks like the following image.

Amixer set master command

There is more you can do with amixer, including setting your volumes to specific hardware value and modifying the audio channels to change, such as front, rear, center, and woofer channels. Read the manual page with man amixer to dig deeper into those advanced controls.

You should now have a basic understanding of how to use Alsamixer and Amixer to control the volume levels on your sound card.

I use Alsamixer often when I switch from desktop speakers to headphones on my laptop. It saves my ears several times a week. You may find similar uses for these tools, and hopefully you find them as intuitive and easy to use as they were meant to be.

2 comments

  1. “Popular distros such as Ubuntu and Arch Linux run it by default”

    Such popular distributions by default run Pulseaudio on top of ALSA (and even redirect ALSA default output to PulseAudio in /usr/share/alsa/pulse-alsa.conf ) so sometimes changing the ALSA audio level “underneath” (for the primary soundcard output) may be circumvented by Pulseaudio resetting the volume level from “above”.

  2. ALSA is great but the issues of modern systems with Video Cards that also support monitors with speakers via HDMI or Display Port cause a problem as well, especially if you want to use the sound card instead of the usually primary audio out of the monitor speakers. via the video card. You have to disable the video card sound with an addition as follows at least for my video card hdmi audio out, you have to find your video card’s device id via lspci with something like this:

    > lspci -vnn | grep -i nvidia
    01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK110 [GeForce GTX Titan] [10de:1005] (rev a1) (prog-if 00 [VGA controller])
    Kernel driver in use: nvidia
    01:00.1 Audio device [0403]: NVIDIA Corporation GK110 HDMI Audio [10de:0e1a] (rev a1)

    Should list out the device ID then you need to add that device to rc.local to disable it, adding the below to rc.local for that video card. You will have to do some looking around till you find the remove file under one of those directories.

    # Disable NVIDIA HDMI Sound Card
    echo 1 > /sys/devices/pci0000:00/0000:00:02.0/0000:03:00.1/remove
    # End Sound Card

    then hopefully ALSA or pulse will not default to the video audio out. Pain in the rear actually.

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.

Sponsored Stories