When I type a sudo command into the terminal it shows the following error:
sudo: /etc/sudoers is owned by uid 1000, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin
How do I fix this?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
Another option, in the case that one doesn't have the password for
ubuntu users. I've fat-fingered ownership (more times than I want to admit) and ending up doing this:
sudo chown -R owner:group /
instead of this:
sudo chown -R owner:group .
This has almost always been in the context of a Vagrant-managed VirtualBox VM running Ubuntu headless, so YMMV. I'd never had a good fix until now, but this seems to do the trick easyishly.
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. chown -R root:root /etc/sudoers.d chown root:root /etc/sudoers chmod 440 /etc/sudoers exit 0
After the fix is in place the commands in /etc/rc.local can be removed.