Dec 30, 2008

Fixing Broken Sudo

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
So If you've made one of this mistakes, and your sudo wont work - the best way to fix your broken sudo is by using this guide. Here is the solution:
  1. Boot into Recovery Mode
  2. 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.
  3. When you chose Recovery Mode, it will bring the next boot menu which is displayed below. Choose Root - Drop to Root Shells menu.
  4. 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 admin
sudo cp /etc/sudoers /etc/sudoers.backup
sudo nano /etc/sudoers
  • Edit the sudoers files to look like this:
# /etc/sudoers
# 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

# Defaults

Defaults !lecture,tty_tickets,!fqdn

# 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/sudoers
After 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.

Thank you for your unbelievable support on Negative Zero - Permission to read and write blog for nearly 4 years. Don't forget to like Negative Zero on Facebook. Blog Directory

Post(s) you might like to read :



Post a Comment