-1

I have Ubuntu 12.04 installed on my PC, recently I have edited /etc/passwd and changed

user1:x:00:00:user1,,,:/home/user1:/bin/bash

to give root permission to user1 and the system always need to login as root, for running some custom software.

Now it seems the sound is not working, the volume icon is disabled. I understand that the pulseaudio demon can't be run as root that's why the audio is not working. How can I resolve it, like set the permission of pulseaudio to run as root.

When I type the command

 /usr/bin/pulseaudio --start

Giving me the output

W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).
E: [autospawn] core-util.c: Home directory /home/user1 not ours.
W: [autospawn] lock-autospawn.c: Cannot access autospawn lock.
E: [pulseaudio] main.c: Failed to acquire autospawn lock

Edit

Solution for problem:

I have fixed the problem by disable root checking for pulseaudio equalizer

sed -i 's/exit 1/#exit1/g' /usr/bin/pulseaudio-equalizer 
Haris
  • 201
  • 1
    you don't need to edit passwd to give root access. Just run sudo useradd user1 sudo – Aniket Bhattacharyea Mar 21 '16 at 07:34
  • Does that required to enter password, for each time for some root operation?. – Haris Mar 21 '16 at 07:37
  • @MelBurslan I have run the command adduser user1 pulse-access but still the sound cannot enabled. – Haris Mar 21 '16 at 08:12
  • A couple of notes. First, put your /etc under version control if you haven't already - check out etckeeper. If you don't want to do that, at least back up system files in /etc before messing with them. I'd revert back to the original version if possible. And as people have mentioned, editing passwd files is rarely necessary anyway. Second, PA autospawns by default, so you normally should not need to run it. Third, running PA as root changes permissions and messes stuff up, which I recently found out the hard way. See https://unix.stackexchange.com/q/265043/4671. – Faheem Mitha Mar 21 '16 at 17:27
  • "set the permission of pulseaudio to run as root". Don't try to do that. PA is designed to run as user. The simplest thing to do here is try rebooting. Then see if pavucontrol will run as user. If it doesn't, paste the error message it gives, and try starting PA as user. Also paste the output of groups for your user, please. – Faheem Mitha Mar 21 '16 at 17:29
  • Actually the software I have developed need to be run as root also need to write some file on root fs, that's why I changed passwd file. And right now the sound setting is disabled I thought it's due to pulse audio demon problem which is not able to run as root. – Haris Mar 21 '16 at 17:49
  • This is the output I got when run groups root adm cdrom sudo audio dip plugdev lpadmin sambashare – Haris Mar 21 '16 at 17:51
  • 1
    @Haris Note that if you want to notify someone of a message, you need to put an @ followed by their username. And put information in the question, not comments. – Faheem Mitha Mar 22 '16 at 05:07
  • Sorry, I thought you will automatically get notification while I am putting comment. – Haris Mar 22 '16 at 05:45
  • No, I wasn't notified of your most recent comment, either. If you want to have a conversation, it helps if the other party is getting your messages. – Faheem Mitha Mar 22 '16 at 06:12
  • This question can help you is a very similar problem.
    https://unix.stackexchange.com/questions/473769/sound-doesnt-work-properly-in-root-but-does-in-normal-user
    – Scorpion Oct 07 '18 at 17:05

1 Answers1

5

“Give root permission to user1” is imprecise. What you actually did was to make user1 an alias for the root user. What determines the identity of a user is the user ID, not the name. The name is just what you type when you log in (that also determines what shell you get and what group you're in, but that's about it). Now “the system always login as root for some reason” — well, yes, the reason is that you are logging in as root.

Some programs don't expect to run as root and won't work properly.

You need to repair the entry in /etc/passwd to give user1 their user ID back. Then change the ownership of all files in user1's home directory back:

find /home/user1 ! -type l -uid 0 -exec chown user1 {} +

Then log out and back in, and your system should work again. Some bad side effects of the current problem may remain; be careful about changing files' permissions and ownership if you don't know exactly what you're doing. If in doubt, ask here.

  • I think you are misunderstand the line the system always login as root for some reason, I have edited the question. Actually this was my requirement to login to the system as root, and I cannot changed that back. Actually I have customized Ubuntu and created a liveISO with a custom app running on it. And the system is working fine for last 8-10 month without any major problem, except the issue like audio. So is there any way to get audio work with root user. – Haris Mar 22 '16 at 04:15
  • @Haris Don't run pulseaudio as root. Don't add an entry to /etc/passwd with a UID of 0. If you have some software that must run as root, run that software as root, and only that software. – Gilles 'SO- stop being evil' Mar 22 '16 at 11:50