Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

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:

http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide

Note that there's some good reasons not to do this:

http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide

Unfortunately I don't know of any other way to solve the problem on a system running pulseaudio.

share|improve this answer

Try:

sudo usermod -G audio -a username

Then do sudo login username and check if audio is listed when running groups. That should do the trick.

share|improve this answer

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

paprefs

On the Network Server tab, click "Enable network access to local sound devices", leaving all other settings as they are.

Image: http://i.stack.imgur.com/Ua0qg.png

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

Replace OUTPUT with PREROUTING if your proxy is redirecting in the prerouting chain.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.