Sunday, August 9, 2009

Exploring Ubuntu Recovery Mode

Today, I did a fresh installation of Ubuntu 9.04 inside virtual box. My original idea was to play with sudoers and sudo command. I edited /etc/sudoers and logged out. Next time I tried to sudo , I go some parse error in /etc/sudoers. I was stuck . I needed sudo for modifying the file. But sudo was preventing me because of the error.

Then, I remembered about the recovery mode. Rebooted the machine and I pressed escape to get the standard grub screen as shown below.


Selecting recovery mode showed the following screens. ( The second figure below shows the remaining part of the recovery screen which is hidden from the first screen.)




I selected drop to a root shell. It allowed me to enter root account with out a password. I fixed my /etc/sudoers and my problem was gone.

Later I rebooted again and re-entered the recovery mode again to find out what capabilities it offers.

The recovery screen offers you the following menu entries on ubuntu 9.04 .

a) Try to make free space - this is useful if your machine is stuck for the want of free disk space.
b) Dpkg - If you select this option you can repair broken packages. Very useful ,if the system is stuck after a package installation.
c) fsck - if the system is stuck with file system error you can try this option.
d) grub - You can update the grub boot loader from this option.
e) netroot - Your TCP/IP network settings will be enabled and system will drop to a root shell.
This option is useful if you are trouble shooting network related issues.
f) root- Plain old root shell . Suitable for editing config files.
g) xfix - This option will try to reconfigure your X window system

10 comments:

Wild River Guitar said...

I often had to Do this because of bad updates but a word of advice to all ubuntu users get a copy of the Xubuntu live Cd because sometimes Ubuntu fails and Xubuntu can Pick up the pieces.It seems to Boot where Ubuntu won't

Anonymous said...

Just FYI for your future edits of /etc/sudoers: Don't edit /etc/sudoers directly. Edit it with visudo, which will check the syntax and help avoid this sort of problem. Of course, you'll still need sudo to run visudo.

Anonymous said...

You should always use visudo to modify
/etc/sudoers. The modified file will not be saved unless it is syntactically correct.

To use visudo, you have to (horrors of horrors) use a root terminal and the command line interface. If you do not want to do such a thing, then you should not be fiddling with /etc/sudoers! As always, make a backup of the original file before starting to edit. /etc/sudoers is readable only by root.

Open a terminal, enter 'sudo su', then 'visudo'. Visudo is a version of the vi text editor, which takes a bit of learning to use correctly. If you are not familiar, practise with its cousin vi before launching on visudo.

Yes, it is not simple and user-friendly, but sudo and sudoers are serious matters and are not playthings - as you learnt the hard way.

Also the familiar advice: print out and read the man pages for sudo and visudo before playing with fire.

And if you haven't got visudo on your machine, get it from the repository.

Tedy said...

I just curious why entering recovery mode doesn't need login password? Can we configure it so that everytime we drop to root shell it prompt us with authentication login?

Anonymous said...

@Tedy: Yes. You set your root password. I would not recommend doing this, however (1), as it may provide a false sense of security.

The root account is disabled by default, and for good reason, as it deters people from logging in as root (2); "recovery mode" is only accessible when a user has root access or when a user has physical access to the system and can choose the option via grub. Setting a root password makes it easier for an attacker who does not have physical access to gain root privileges (3) when your system is running normally (i.e. not in recovery mode).

That said, if you want another way to deter people from logging in as root from recovery mode, you can set a grub (4,5), bios, or hard drive password, which would prevent access to any boot options in the first place. You would have to type in a password every time you boot your computer, though.

1. RootSudo - Community Ubuntu Documentation - Enabling the root account
2. Ubuntu Linux Tips & Tricks: The Root Password Rumour
3. RootSudo - Community Ubuntu Documentation - Benefits of using sudo
4. Ubuntu Forums - View Single Post - [ubuntu] How do I lock down the recovery shell...
5. Idea #20047: "drop to root shell prompt not secure" - Ubuntu brainstorm

DIPANJAN said...

hi this is Dipanjan
I have a serious problem...
I changed the "Refresh Rate" in the display settings in my ubuntu 9.04

and after that my screen just went off...giving a comment of "low frequency"
I have gone to the recovery mode but cant find the solution by going to the menu of"restore Graphics"
bt of no use..
please help

Mackenzie said...

Anonymous:
No need to "sudo su ; visudo" Just "sudo visudo"

Anonymous said...

Once I have the 'recovery screen' up, how do I navigate it? How do I select an option and execute it? My screen just goes dodgy whenever I try pressing any buttons.

Anonymous said...

Thank you, it helped me. To start the virtual machine in recovery mode I had to press Shift instead of Esc, though.
Cheers
Rod

Unknown said...

From Ubunto recovery i have no words to say his awesome work.Again a usefull and reliable recovery that you've published.Thank you so much for this kind of information!
repair dbx file