Permissions and ownership is a perpetual learning process for beginner Linux administrators. There are quite a few things you need to use superuser privileges for in your everyday administration. But let’s say, for instance, you broke your
/etc/sudoers file (like I did) and now sudo is broken. What do you do then?
Error When Sudo is Broken
If you try to use
sudo when the
/etc/sudoers file is broken, you’ll get an error like this:
sudo: >>> /etc/sudoers: syntax error near line 30 <<< sudo: parse error in /etc/sudoers near line 30 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin
This is not a pretty sight.
And because you can’t use
sudo when the
/etc/sudoers file is broken, that also means that you can’t fix the file with the normal command:
sudo nano /etc/sudoers.
But thankfully, all hope is not lost. There is a relatively easy way to fix this.
What to Do When Sudo is Broken
Since you can’t use
sudo nano, you’ll need to use a different command.
You’ll get a response like this:
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/sbin/visudo' as the super user
Authenticating as: Username,,, (username)
Enter your password there, and you’ll get this:
==== AUTHENTICATION COMPLETE ===
And then the
/etc/sudoers/ file will open for you to edit.
Fix what ever problem you have, save the file, and you’re back in business.
Welcome back to the realm of administrator privileges.
Image credit Nadya Peek.