With Debian (LMDE 5) Bullseye, I am unable to change the audio sink using pacmd, as I was able to do with Ubuntu. However, the mate-volume-control application/gui is able to change the sinks.

It must be using a lower level or another method since pulseaudio is not running by default in Bullseye. After starting pulseaudio, the pacmd commands run without any errors, but the audio continues to play out of the sink set in the GUI.

I've edited /etc/pulse/default.pa with this line which, as I understand it, is supposed to prevent pulse from reversing the change when issued from pacmd:

load-module module-stream-restore restore_device=false

The commands that work in Ubuntu for my sound card are:

#change to analog stereo
pacmd set-card-profile alsa_card.pci-0000_00_1b.0 output:analog-stereo

#change to hdmi
pacmd set-card-profile alsa_card.pci-0000_00_1b.0 output:hdmi-stereo-extra1+input:analog-stereo

My question is similar to: Change output (sink) using the terminal, but the question has no suggestions that worked.

Has anyone had success changing the sink via script in recent Debian?

1 Answer 1


To change the sound sink (audio output device) from a script in Debian Bullseye, you can make use of the pacmd command-line tool, which is part of the PulseAudio sound server. Here's a step-by-step guide:

  1. Install the necessary packages if pacmd is not already available. You can use the following command to install it:

    sudo apt-get install pulseaudio-utils
  2. Determine the available sound sinks by running the following command:

    pacmd list-sinks | grep -e 'index:' -e 'name:'

    This command will list the available sinks along with their index numbers. Note the index number of the sound sink you want to switch to.

  3. Create a script file, for example, change_sound_sink.sh, using a text editor of your choice

    nano change_sound_sink.sh
  4. In the script file, enter the following lines:

    # Set the desired sink index
    # Change the default sink to the desired index
    pacmd set-default-sink $SINK_INDEX
    # Move existing streams to the new sink
    pacmd list-sink-inputs | awk '/index:/{print $2}' | while read -r input; do
        pacmd move-sink-input "$input" "$SINK_INDEX"

    Replace my_sink_index with the index number of the desired sound sink (e.g., 0, 1, etc.) that you obtained in Step 3.

  5. Save the script file (Ctrl+O in nano) and exit the text editor (Ctrl+X in nano).

  6. Make the script file executable by running the following command:

    chmod +x change_sound_sink.sh
  7. Run the script using the following command:


This will change the sound sink to the specified index and move any existing audio streams to the new sink.

After running the script, the sound output should be switched to the desired sink. You can incorporate this script into other automation or control systems as needed.

  • This answer fails at step 2 with "No PulseAudio daemon running, or not running as session daemon", since pulseaudio is not started in Bullseye, as explained above. If pulseaudio is started manually, then the command at step 2 only shows the running profile (analog-stereo), and not the other (hdmi) profile to select.
    – Ken H
    Jun 12, 2023 at 22:18

You must log in to answer this question.

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