3

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?

1

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.

0

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.

0

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.

0

Copy the file ~/.config/pulse/cookie from the user running the pulseaudio daemon to the same location for the user that you are sudo'ing to.

0

If you use 'sux' instead of 'sudo' everything should work.

https://apps.ubuntu.com/cat/applications/precise/sux/

0

Add the user to the "audio" group.

adduser username audio
  • Tested on Ubuntu 19.10. Does not work. Will not down vote though since this is an old answer. – Batcastle Jan 3 '20 at 5:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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