I have a Xonar DGX card, and I can change the audio output with alsamixer by going to the Analog Output option and switching between Stereo Headphones and Stereo Headphones FP. How can I do the same by using the command line?

I've looked up and found about sinks and how they can be switched with pacmd, but from what I understand my both outputs are within the same sink, which is my Xonar card.

  • 1
    If both outputs are within the same sink in PA, they probably will have different associated profiles.
    – muru
    Jul 30, 2018 at 0:02
  • 1
    amixer is the commandline version of alsamixer Jul 30, 2018 at 0:09
  • Possible duplicate - unix.stackexchange.com/questions/175930/….
    – slm
    Jul 30, 2018 at 1:54

4 Answers 4


I believe you can do this using a number of tools, such as amixer, or pamd, or pactl.

NOTE: Your assumption is how I understand things as well. Sinks I equate to actual soundcards (output), and the outputs on them are called ports.

The actual definition from this guide titled PulseAudio under the hood:


A sink is an output device. It is an active unit that consumes samples.

Sink usually runs a thread with its own event loop, peeks sample chunks from connected sink inputs, and mixes them. It also implements clocking and maintains latency. The rest of the world usually communicates with a sink using messages.

The typical sink represents an output sound device, e.g. headphones connected to a sound card line output or on a Bluetooth headset. PulseAudio automatically creates a sink for every detected output device.


Here's an example showing how to use pactl:

$ pactl list sinks |& grep -E "Sink|Ports|analog-ou"
Sink #0
        analog-output-lineout: Line Out (priority: 9900, not available)
        analog-output-headphones: Headphones (priority: 9000, not available)
    Active Port: analog-output-lineout

Above you can see my Active Port: is currently my soundcard's lineout. Let's change that to the headphones.

$ pactl set-sink-port 0 analog-output-headphones

And if we check again:

$ pactl list sinks |& grep -E "Sink|Ports|analog-ou"
X11 connection rejected because of wrong authentication.
Sink #0
        analog-output-lineout: Line Out (priority: 9900, not available)
        analog-output-headphones: Headphones (priority: 9000, not available)
    Active Port: analog-output-headphones

From man pactl:

   set-sink-port SINK PORT
          Set the specified sink (identified by its symbolic name or
          numerical index) to the specified port (identified by its symbolic 

What if audio device disappears?

In rare cases I've noticed that the audio output device mysteriously disappears from the list of devices. If you find this happens you can easily resolve this by telling Pulse Audio to reload its modules:

$ pactl load-module module-detect


  • Why do you use |&? And what is the reasoning behund analog-ou instead of analog-output? Not that it changes anything, but the output colors look better that way. I also included |Name: in the grep-Expression to be able to see more easily which Sink is which. You could also add iec958-stereo-output and [Out] alongside the analog one for a more complete output including HDMI and digital outputs. My full command would then be pactl list sinks |& grep -E "Sink |Ports:|Name:|\[Out\] |analog-output:|iec958-stereo-output:". Should I post a separate answer including all the details?
    – Cadoiz
    Nov 7, 2022 at 7:50
  • Is is possible that you used this answer to change ports, but no to change sinks?
    – Cadoiz
    Nov 7, 2022 at 7:57

I used pacmd to auto switch sound from pc speakers to hdmi:

if grep '^connected$' /sys/class/drm/card0/card0-HDMI*/status ;then             
  sleep 2
  pacmd set-card-profile 0 output:hdmi-stereo
  sleep 2
  pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo

To get the active sound profile:

pacmd list |grep 'active profile'
        active profile: <output:analog-stereo+input:analog-stereo>

To list all the available output sound profiles supported:

pacmd list |grep 'output:'
  • 1
    @Cadoiz pacmd was (at 2018) the name of Pulse Audio deamon. I have not checked recently if the deamon name has been changed. Search about Pulse Audio. Nov 7, 2022 at 12:23
  • Thanks for the answer. Pulse Audio can be installed with one of apt-get install pulseaudio-utils, brew install pulseaudio, brew install pulumi or nix-env -iA nixpkgs.pulseaudio among others. I tried to extend your command for listing the output profiles as follows: pacmd list |grep -E 'Default |module\(s\)|sink\(s\)|source\(s\)|client\(s\)|card\(s\)|sink input|index:|output:' | grep -B2 'output:' - that way, you will easily see the index of each profile and to what it belongs.
    – Cadoiz
    Nov 7, 2022 at 15:25
  • Unfortunately my result was the same as with other methods: The output seems to change according to console, but not according to the gui util and real sound. Note that there could be more than one active sound profile - and you can omit the second grep to also see the "dead" indices.
    – Cadoiz
    Nov 7, 2022 at 15:26
  • This askubuntu answer showed me pacmd list-sinks. Analogously, you could use an easier command: pacmd list-cards |grep -E 'index:|name:|output:'
    – Cadoiz
    Nov 7, 2022 at 15:34

All of the other answers here didn't solve my problems as they don't change necessary parts of the configuration or don't move active streams. This Q/A provides some answers which are fairly complicated. But note that today (as of Jul 15, 2022 on on Ubuntu 22.04), it is much easier than described in slm's answer or the other ones on that related askubuntu Q/A.

Especially this answer there made me consider an answer here too.

You can just use

  • pactl list short sinks and
  • pactl list short sources

to get the list of available sinks and sources

(from that answer). After that, you can switch with

pactl set-default-sink '<the name of the sink from the list>'

The mentioned answer also provides a script to switch/toggle between two different devices.

slm mentioned a "number of tools, such as amixer, or pamd, or pactl". These can be found in different answers. Here are some references using


You can do it with amixer.

amixer -c 0 cset name='Analog Output Playback Enum' 0

Where 0 in -c 0 represents the card number. The last parameter is as follows:

0 - 'Stereo Headphones'
1 - 'Stereo Headphones FP'
2 - 'Multichannel'
  • Unfortunately gives me amixer: Cannot find the given element from control sysdefault:0. I used amixer -c 0 to display all the different options.
    – Cadoiz
    Nov 7, 2022 at 8:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .