amixer Command in Linux

Introduction

This lab provides a practical guide on leveraging the amixer command, a powerful command-line utility for managing sound card mixer settings within a Linux environment. You'll master adjusting the system's master volume, gain control over individual sound channels, and explore real-world examples of amixer in action. Learn to inspect current mixer configurations, fine-tune master volume levels, and manage specific sound channels, developing a solid understanding of this essential Linux audio tool for system administration tasks.

Introduction to amixer Command

This section introduces you to the amixer command, a fundamental tool in Linux for systemadmin tasks related to audio. amixer is a command-line interface designed for direct control over your sound card's mixer settings. With it, you can manipulate volume, balance, and other audio-related properties.

Let's begin by examining the existing sound card mixer settings using the amixer command:

amixer

Example output:

Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 65536 [100%] [0.00dB] [on]
  Front Right: Playback 65536 [100%] [0.00dB] [on]

This output reveals the current configuration for the 'Master' mixer control, encompassing the volume level and mute status of both the front left and right audio channels.

You can modify the 'Master' control's volume using the amixer command:

amixer set Master 50%

Example output:

Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 32768 [50%] [-6.00dB] [on]
  Front Right: Playback 32768 [50%] [-6.00dB] [on]

This command effectively adjusts the 'Master' volume to 50% of its maximum.

Next, we will delve into controlling individual sound channels with amixer.

Adjusting Master Volume with amixer

Here, you will discover how to modify the master volume of your sound card using the amixer command within your Linux environment. This is a common systemadmin task.

First, retrieve the current master volume level using the following command:

amixer get Master

Example output:

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 65536
  Mono: Playback 65536 [100%] [0.00dB] [on]

This output indicates that the master volume is currently set to its maximum level, 100%.

To change the master volume, utilize the amixer set command. For example, to reduce the master volume to 50%, execute:

amixer set Master 50%

Example output:

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 65536
  Mono: Playback 32768 [50%] [-6.00dB] [on]

Alternatively, you can use absolute values rather than percentages. To set the master volume to its highest possible value, use:

amixer set Master 65536

Example output:

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 65536
  Mono: Playback 65536 [100%] [0.00dB] [on]

To mute the master volume entirely:

amixer set Master mute

Example output:

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 65536
  Mono: Playback 65536 [100%] [0.00dB] [off]

And to restore the master volume to an audible state:

amixer set Master unmute

Example output:

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 65536
  Mono: Playback 65536 [100%] [0.00dB] [on]

You are now equipped to control the master volume using the amixer command in your Linux systemadmin tasks.

Controlling Specific Sound Channels with amixer

This section demonstrates how to manage the volume of particular sound channels using the amixer command. This is useful for Linux systemadmin tasks requiring fine-grained audio control.

First, identify the available sound channels on your Linux system using the command:

amixer scontrols

Example output:

Simple mixer control 'Master',0
Simple mixer control 'Headphone',0
Simple mixer control 'Speaker',0
Simple mixer control 'PCM',0
Simple mixer control 'Capture',0

The output reveals a list of accessible sound channels, which may include 'Master', 'Headphone', 'Speaker', 'PCM', and 'Capture'. The availability of these channels depends on your sound card and system configuration.

To adjust the volume of a specific channel, employ the amixer sset command. For instance, to set the 'Headphone' channel's volume to 50%, run:

amixer sset Headphone 50%

Example output:

Simple mixer control 'Headphone',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 32768 [50%] [-6.00dB] [on]
  Front Right: Playback 32768 [50%] [-6.00dB] [on]

You can also mute or unmute a specific channel as needed:

amixer sset Headphone mute
amixer sset Headphone unmute

Example output:

Simple mixer control 'Headphone',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 65536 [100%] [0.00dB] [off]
  Front Right: Playback 65536 [100%] [0.00dB] [off]

Simple mixer control 'Headphone',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 65536 [100%] [0.00dB] [on]
  Front Right: Playback 65536 [100%] [0.00dB] [on]

You now have the knowledge to manipulate the volume of individual sound channels using the amixer command, expanding your capabilities as a Linux systemadmin.

Summary

In this lab, you gained practical experience with the amixer command, a crucial command-line tool for managing sound card mixer settings within the Linux operating system. You began by learning how to inspect the current sound card mixer configuration using amixer and then progressed to adjusting the volume of the 'Master' control. Furthermore, you explored the methods for controlling specific sound channels utilizing amixer.

You discovered that the versatile amixer command empowers you to modify the volume, balance, and various other settings of your sound card. You learned to precisely set the master volume to a desired level, such as 50%, by employing the amixer set command. This newfound knowledge provides you with the ability to fine-tune the audio output on your Linux system, proving invaluable for various systemadmin tasks and troubleshooting scenarios.

400+ Linux Commands