0

I have used sudo chown -R yourusername:yourusername /etc to get access to that folder to remove some files, but now I get errors when I try to install stuff, as seen below, and can't seem to change things back to normal.

vk137@alternate:~$ sudo apt-get install pulseaudio
sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

To a similar question was advised to remount the filesystem, but I can't seem to do that either:

vk137@alternate:~$ mount -o remount,rw /
mount: only root can use "--options" option

How can I put the access to /etc back in the right hands?

1
  • While most configuration files are owned by / (root), you may have files owned by many system users. You never should change ownership or permissions of system files. Reinstall as linked above is about the only full solution. You could change everything to root, but if you run the terminal command id you will see many users all that may own some system files.
    – oldfred
    Feb 4, 2016 at 16:07

2 Answers 2

1

Not all will be solved by chowning it to root:root, try installing same Ubuntu version on another PC or VM, install all the packages you currently have installed and run this command:

sudo find /etc -exec stat --format 'chown %U:%G %n' {} \; >> restore.sh

It will write a script that contains permissions from healthy /etc with content like this:

...
chown root:dip /etc/ppp/peers/provider
chown root:lp /etc/cups/subscriptions.conf 
chown root:lp /etc/cups/printers.conf 
chown root:root /etc/cups/raw.types 
chown root:root /etc/cups/smfp.types 
chown root:lp /etc/cups/printers.conf.O 
...

Copy restore.sh to your current troubled Ubuntu and run it with sudo to restore your permissions.

0

The question is similar, but not equal to some others around here. I managed to fix this problem by rebooting into recovery mode, then using the following commands:

mount -o rw,remount /

This remounted the entire drive as read-write

chown -hR root:root /etc

This set the permissions to /etc back to user root and usergroup root.

1
  • You should follow the advice of Mike, because some services or commands won't work if these cannot access their configuration files beneath /etc. Just give root:root permissions on all files will not solve all your problems...
    – Thomas
    Feb 4, 2016 at 17:34

Not the answer you're looking for? Browse other questions tagged .