How can I change the default audio device from command line?

You can control PulseAudio thoroughly through the command line using pacmd and pactl commands. For options see man pages or the wiki at PulseAudio:

pacmd list-sinks (or pactl list short sinks) for name or index number of possible sinks

pacmd set-default-sink "SINKNAME" to set the default output sink

pacmd set-default-source "SOURCENAME" to set the default input

pacmd set-sink-volume index volume

pacmd set-source-volume index volume for volume control (65536 = 100 %, 0 = mute; or a bit more intuitive 0x10000 = 100 %, 0x7500 = 75 %, 0x0 = 0 %)

and many many more CLI options.


Note: Changing the output sink through the command line interface can only take effect if stream target device reading is disabled. This can be done by editing the corresponding line in /etc/pulse/default.pa to:

load-module module-stream-restore restore_device=false

Restart PulseAudio for changes to take effect:

pulseaudio -k


For a more elaborate tutorial on how to do this, and for instructions on how to change the sink during playback see this answer.


Yes there is type alsamixer in terminal

alt text

Press ,

F1 - Help

F2 - System Information

F6 - Select Sound Card

Esc - Exit the menu


pavucontrol

Not the actual Ubuntu volume control, but better! It lets you control default devices, and even devices per application/stream.

You have to have the app actually be recording/playing for it to appear in the 'Playback' or 'Recording' tabs, but once you choose the device for that app, it seems to remember it forever.

Also, (on a side note), for old (non pulse) applications, run them after padsp, eg:

padsp some_old_app

pavucontrol