0

I had upgraded ubuntu12.04 to ubuntu14.04 and it didn't boot unless I edited this line in the grub menu

linux ${rel-dirname}/${basename} root=${lINUX_HOST_DEVICE} loop=${loop_file_relative} ro ${args} 

from ro to rw but I didn't save this change and boot by press F10. Then I update the file /etc/sudoers with wrong syntax and I can't use sudo command and I forgot the password for the root. How I can gain root privilege ??

2 Answers 2

2

Please, enter in secure mode and edit sudoers:

  1. Switch on your computer.
  2. Wait until the BIOS has finished loading, or has almost finished. (During this time you will probably see a logo of your computer manufacturer.)
  3. Quickly press and hold the Shift key, which will bring up the GNU GRUB menu. (If you see the Ubuntu logo, you've missed the point where you can enter the GRUB menu.) *
  4. Select the line which starts with "Advanced options".

  5. Select the line ending with "(recovery mode)", probably the second line, something like:

    Ubuntu GNU/Linux, with Linux 3.8.0-26-generic (recovery mode)
    
  6. Press Return and your machine will begin the boot process.

  7. After a few moments, your workstation should display a menu with a number of options. One of the options (you may need to scroll down to the bottom of the list) will be Drop to root shell prompt. Press Return with this option highlighted.

  8. The root partition is mounted read-only. To mount it read/write, enter the command

    mount -o remount,rw /
    
  9. If you have /home, /boot, /tmp, or any other mount point on a separate partition, you can mount them with the command

    mount --all
    

* If you reboot, there is no need to hold the Shift key in step 3. The GNU GRUB menu will continue to be displayed automatically on each boot until a normal startup of Ubuntu completes.

Source: https://wiki.ubuntu.com/RecoveryMode

8
  • how I can enter in secure mode? Mar 16, 2015 at 21:28
  • Do you mean recovery mode? if yes I did it but I can't modify anything because it's read only @Helio Mar 16, 2015 at 21:33
  • The root partition is mounted read-only. To mount it read/write, enter the command mount -o remount,rw /
    – 0x2b3bfa0
    Mar 16, 2015 at 21:36
  • I tried this command but it didn't work @Helio Mar 16, 2015 at 21:52
  • Had you tried this command in recovery mode and didn't work?
    – 0x2b3bfa0
    Mar 16, 2015 at 21:53
1

I solved the problem by doing these steps:

  1. I Switched on my computer.
  2. Wait until the BIOS has finished loading, or has almost finished. Quickly pressed and hold the Shift key, which will bring up the GNU GRUB menu.

  3. Select the line which starts with "Advanced options".

  4. Select the line ending with "(recovery mode)"

    Ubuntu GNU/Linux, with Linux 3.8.0-26-generic (recovery mode) but I didn't press enter, instead I pressed E to edit the line:

    linux ${rel-dirname}/${basename} root=${lINUX_HOST_DEVICE} loop=${loop_file_relative} ro recovery ${args}
    

    from ro to rw then press Ctrl+X

  5. From the menu of options, I selected the root option then typed these commands:

    $mount -o rw,remount /
    $sudo nano /etc/sudoers 
    

then update the file

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .