Basically inside a sudo session, even one emulating another none root user (sudo -u username command) there is no sound available.
Inside a sudo session sound appears disabled.
I need sound, how do I fix it?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
I've solved this before by running pulseaudio in "system mode" where it is available to all users instead of just the user running the desktop. You can read more about it here:
Note that there's some good reasons not to do this:
Unfortunately I don't know of any other way to solve the problem on a system running pulseaudio.
I got around this problem by enabling 'network server' in pulseaudio preferences.
To get the pulseaudio preferences manager, open up a terminal and type
sudo apt-get install paprefs
Then run it as your usual login (i.e. DON'T run it using
sudo -u) by typing
On the Network Server tab, click "Enable network access to local sound devices", leaving all other settings as they are.
Close the PulseAudio Preferences window and you're done. You should only need to do this once.
As I understand it, this method avoids some of the security issues of running pulseaudio in 'system mode' but, for example, the programs you run using
sudo -u will still share your volume level.
Because we have not ticked 'Allow other machines on the LAN to discover local sound devices' or 'Don't require authentication' your sound device is not actually available to other computers on the network. This setting just allows your computer to connect to itself, you don't need to be connected to a network at all.
NOTE: If you are running a transparent proxy (if you don't know, you're probably not), you have to ensure loopback TCP connections are not being redirected at the NAT level. To add an exception directly to iptables type
sudo iptables -t nat -I OUTPUT -p tcp -o lo -j RETURN
PREROUTING if your proxy is redirecting in the prerouting chain.
If you use 'sux' instead of 'sudo' everything should work.