Have you ever been encounter with broken sudo after a minor changes you've made to your users' setting? Well, there are several ways to break sudo command. From which I've personally experiences and from reading here are several things which might break sudo:
- alteration of /etc/sudoers files which taken previllages of admin to use sudo.
- permission of /etc/sudoers files being changes other than 0440
- a user which shouldn't be taken has been taken off the admin group
- Boot into Recovery Mode
- If you are using Ubuntu as your only OS, then you might need to press ESC key to bring up boot menu before you can choose Recovery Mode.
- When you chose Recovery Mode, it will bring the next boot menu which is displayed below. Choose Root - Drop to Root Shells menu.
- After that, you will need to do some command. Well basically you just need to add a new user to admin group. To do so, here is the steps:
adduser username adminCASE 2:
sudo cp /etc/sudoers /etc/sudoers.backup
sudo nano /etc/sudoers
- Edit the sudoers files to look like this:
# This file MUST be edited with the 'visudo' command as root.
# See the man page for details on how to write a sudoers file.
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
- Then Save and Exits.
- If you messing up with file permission, then all you have to do is:
chmod 0440 /etc/sudoersAfter all doing the exact command depending on how you broke the sudo, to exit Recovery System, just type 'exit' where it will bring back the Recovery Menu. All you have to do is select the First Choice to Resume Normal Boot and your sudo is back.
For more information about SUDO, please read here.