Click to See Complete Forum and Search --> : Lost root password in Linux?
chrs0302
01-12-2006, 03:42 PM
I have lost the root password on a Linux server. I remember one good document on the net explaining the procedure. I am not able to recollect the search phrase. Pl try to send me some useful links to reset root password.
Thanks in advance
JamminJoeyB
01-12-2006, 03:52 PM
Did you try searching the forums? I seem to recall a pretty legnthy thread on here about recovering passwords. I think you might need one of the bootable cd linux distros to do it.
ph34r
01-12-2006, 03:55 PM
Boot with livecd or install cd, mount your filesystem, edit what would be /etc/shadow- and remove the password. Reboot as normal, login as root with no password, set a new password using passwd
deathadder
01-12-2006, 06:19 PM
Instead of editing /etc/shadow mount the root filesystem from a livecd and then chroot, and run passwd.
saikee
01-12-2006, 06:23 PM
deathadder suggestion is the ticket!
voidinit
01-13-2006, 01:34 AM
If you are using a bootloader that allows you to edit kernel options (LILO and GRUB both do), you may not even need the live cd. It depends on your distro's security config. Usually, with a 2.4 series kernel you can pass -s or -single to the end of the kernel options string. Under 2.6.something this does not work. I don't know exactly when it was changed, but if -s or -single doesn't work, then try just adding a 1 (just the numeral one) before the kernel options. If all that fails, try passing init=/bin/bash to the kernel, though that usually only works on very primitive BSD style init systems.
Here are some examples if you are using grub and your root filesystem is on /dev/sda1:
2.4 series example:
grub>kernel /boot/vmlinuz -s ro root=/dev/sda1
grub>initrd /boot/initrd.img
2.6 series example:
grub>kernel /boot/vmlinuz 1 ro root=/dev/sda1
grub>initrd /boot/initrd.img
The longshot example:
grub>kernel /boot/vmlinuz ro root=/dev/sda1 init=/bin/bash
grub>initrd /boot/initrd.img
There are some distributions that will prompt for a password even when booting to the single user runlevel. If you have one of these distributions then you will need a live CD or a boot floppy. I usually use slackware's boot floppy images.
chrs0302
01-13-2006, 02:09 PM
Thaks for all your time and valuable suggestions. Here is one more interesting link. I will try to check all these on our trial server and let you know the o/p.
Have a nice weekend.
http://www.linuxforum.com/forums/index.php...howtopic=163520
saikee
01-13-2006, 06:26 PM
voidinit's suggestion of passing the parameter "1" at kernel boot time worked OK for me in Ubuntu.
justlinux.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.