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?

2 Answers2

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.

Mike
  • 5,931
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.