Between stimulus and response, there is a space. In that space lies our freedom and power to choose our response. In our response lies our growth and our happiness.

Friday, February 19, 2010

Recovering root password in Linux

You cannot recover the old password but you can reset it. The easiest way to do this is by rebooting into single user mode, making the file system writable and then change the password. In my case, I am using Oracle's Unbreakable Linux which is basically Red Hat

STEP 1: Boot into single user mode from GRUB

Reboot the system, and when you are at the selection prompt (GRUB), hit F2. This will keep you in GRUB screen. It will show you the version of Linux you are using. Press 'e'.

This will refresh the screen where you should select the entry that begins with 'kernel' and press 'e' again.

Append ' single' to the end of that line (without the quotes). Make sure that there is a space between what's there and 'single'. If your system requires you to enter your root password to log into single-user mode, then append init=/bin/bash after 'single'. Hit 'Enter' to save the changes. In my case I have to type the whole thing
' single init=/bin/bash' without the quotes.

Press 'b' to boot into Single User Mode.

Once the system finishes booting, you will be logged in as root. Your file system is in read-only mode at this point

STEP 2: Change your file system so it is in read-write mode

Type in 'mount -o remount,rw /' (without the quotes) at the # prompt and hit enter

STEP 3: Change the root password

Type in 'passwd root' (without the quotes) at the # prompt and hit enter. Give your new password and reconfirm.

STEP 4: Reboot the system

Type in 'reboot' (without the quotes) at the # prompt and you are done.


Post a Comment