Lost sudo

From FreekiWiki
Revision as of 15:06, 20 February 2014 by Psullivan (talk | contribs) (Created page with "In Xubuntu (and other Ubuntu-derived operating systems) there isn't a true root user account, so in the majority of cases system administration will be performed by a user cap...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In Xubuntu (and other Ubuntu-derived operating systems) there isn't a true root user account, so in the majority of cases system administration will be performed by a user capable of using the sudo function to gain superuser privileges.

If you are ever prompted for the root password and do not have the option to provide the password for any of the user accounts on your system the problem is likely that none of your user accounts have authority to use sudo.

Booting into Recovery Mode with GRUB

Ubuntu 10.04

Note that after performing step 1 you have a limited time to perform step 2, so please read the instructions fully before beginning the process.

  1. Power on the computer (shut it down first or simply reboot if it is already running).
  2. When the BIOS information or manufacturer's logo "splash" screen appears start holding down the right shift key. If your computer does not usually display BIOS information or a manufacturer's logo you may need to start holding down the shift key immediately after pressing the power button.
  3. After a few seconds you will see the GRUB menu, which is characterized by a lines that will say ...kernel 3.2.... If the system continues to boot normally and arrives at the regular login screen or desktop you will need to restart and try again. If you are repeatedly failing to reach the GRUB menu try quickly and repeatedly tapping the shift key until the menu appears instead of just holding it down.
  4. Hit the down arrow key (usually only once) until it arrives on the first line that ends with recovery mode and press enter.
  5. Select "Root" from the recovery mode menu that appears to enter a shell environment with root privileges.
  6. You should now see a prompt at the bottom of the screen that reads
  root@freekbox:~#

Proceed to the "Restoring sudo" section of this page.

Xubuntu 12.04

Note that after performing step 1 you have a limited time to perform step 2, so please read the instructions fully before beginning the process.

  1. Power on the computer (shut it down first or simply reboot if it is already running).
  2. When the BIOS information or manufacturer's logo "splash" screen appears start holding down the right shift key. If your computer does not usually display BIOS information or a manufacturer's logo you may need to start holding down the shift key immediately after pressing the power button.
  3. After a few seconds you will see the GRUB menu, which is characterized by a lines that will say ...kernel 3.2.... If the system continues to boot normally and arrives at the regular login screen or desktop you will need to restart and try again. If you are repeatedly failing to reach the GRUB menu try quickly and repeatedly tapping the shift key until the menu appears instead of just holding it down.
  4. Hit the down arrow key (usually only once) until it arrives on the first line that ends with recovery mode and press enter.
  5. Select "Root" from the recovery mode menu that appears to enter a shell environment with root privileges. Note that until further steps are completed your file system will be in "read only" mode and you will not be able to make any persistent changes to the system.
  6. You should now see a prompt at the bottom of the screen that reads
  root@freekbox:~#

Mount the file system in read/write mode by entering the following command at the prompt:

  mount -o remount,rw /

Restoring sudo

Once at the recovery mode root shell prompt, follow these steps:

  • Type the following command and press Enter to create a back up of your group settings:
  cp /etc/group /etc/group.bak
  • Edit your group settings file by entering the command
  nano /etc/group
  • You will be presented with a very basic text editor. Use the arrow keys to move the cursor. There may be more lines in the file than fit on the screen, so use the Page Up and Page Down keys to navigate through the entire file. Each line in this file represents one of the groups on your system and various attributes of that group separated by : symbols. Be very careful not to accidentally modify any lines you are not instructed to. If you suspect you may have changed something accidentally then press Ctrl-X followed by the N key to cancel any changes and try again. If you have already saved the changes when you realize you made a mistake then revert to your backed-up group file with the command
  cp /etc/group.bak /etc/group
  • Find the line for the sudo group, which should look something like this:
  sudo:x:27:

If there are any usernames listed after the third : in that line then those users should have the ability to make administrative changes and you may want to cancel this process, restart your computer, and log in as that user to perform administrative tasks instead.

  • Add the username that should be able to administer the computer to the end of the sudo group line. If there will be multiple users in the group then separate their names with a comma:
  sudo:x:27:username1,username2
  • Press Ctrl+O to save the file, then Ctrl+X to close the text editor.
  • Enter the command
  reboot
  • Your system will restart and your new account should now be able to use administrative features. If you are returned to the GRUB menu after restarting just press the Enter key to select the default option and boot normally.