Subscribe:
    Subscribe Twitter Facebook

    Thursday, October 1, 2009

    Reset forgotten root password under Linux

    Method : 1

    You can reset forgotten root password under Linux by booting system into single user mode or emergency mode (also known as rescue mode).

    My boot loader is GRUB (see LILO boot loader below)
    )Following is the procedure to reset root password if you are using GRUB as a boot loader:

    Select the kernel
    Press the e key to edit the entry
    Select second line (the line starting with the word kernel)
    Press the e key to edit kernel entry so that you can append single user mode
    Append the letter S (or word Single) to the end of the (kernel) line
    Press ENTER key
    Now press the b key to boot the Linux kernel into single user mode
    At prompt type passwd command to reset password:
    You need to mount at least / and other partitions:
    # mount -t proc proc /proc
    # mount -o remount,rw /

    Change the root password, enter:
    # passwd

    Finally reboot system:
    # sync
    # reboot


    My boot loader is LILO
    At LILO boot loader type linux single and press [ENTER] key:
    Boot: linux single

    When you get the # prompt you will need to type passwd root to reset password:
    # passwd

    Reboot system:
    # sync
    # reboot

    Method : 2


    If you don't have a LiveCD, or the system doesn't have CDROM drive, you can reboot the system into single user mode to reset the password. Simply pass the options "init=/bin/sh" to the kernel from the bootloader menu. When the system boots it will drop you into a root shell. The disk will be mounted read-only so remount it read-write with
    mount -o rw,remount /dev/ROOT
    (be sure to change ROOT to your actual root partition). Edit /etc/shadow and remove the encrypted password. Reset the root password with passwd and reboot the system.
    You should now be able to login with the new password.

    0 comments:

    Post a Comment

    Bidvertiser