23 February 2010

Reset root password - Linux

[*] Linux method 1

At the boot loader (lilo or grub), enter the following boot option:

init=/bin/sh

The kernel will mount the root partition and init will start the bourne shell instead of rc and then a runlevel. Use the command passwd at the prompt to change the password and then reboot.

Forget the single user mode as you need the password for that.

If, after booting, the root partition is mounted read only, remount it rw:

# mount -o remount,rw /
# passwd     # or delete the root password (/etc/shadow)
# sync; mount -o remount,ro /    # sync before to remount read only
# reboot


[*] Linux method 2

*  Boot a live CD or installation CD into a rescue mode which will give you a shell.
*  Find the root partition with fdisk e.g. fdisk /dev/sda
*  Mount it and use chroot:

# mount -o rw /dev/sda? /mnt
# chroot /mnt     # chroot into /mnt
# passwd
# reboot

biOos

No comments: