Operating System - Linux
1834483 Members
3229 Online
110067 Solutions
New Discussion

Re: Root Passwd For LInux

 
donne007
Regular Advisor

Root Passwd For LInux

I Have Forgotten My Linux Root Passwd , How do i recover the Passwd , One was is to INterupt the Boot in Single user mode and change the Passwd , Also I dont have the Boot Floppy,
Any One Please Help On this..
Thanks IN ADvance
Asif
2 REPLIES 2
Kodjo Agbenu
Honored Contributor

Re: Root Passwd For LInux

Hello Asif,

I can suggest an ultimate method that needs the installation bootable cd-rom.

=> Boot on the CD-Rom as if you wanted to re-install your Linux box.

=> Go through the steps until partitioning (BE CAREFUL AND DO NOT CHOOSE AUTOMATIC PARTITIONING)

=> When you reach the partitioning step, just type CTRL-ALT-F2 to open a console shell.

=> Try to find the device file that matches your Linux root partition. If it does not exist (either in /tmp or /dev), just create it manually :

mknod b

where :

For IDE :
device=/dev/hd[abcd] (n=partition number)
major=3
minor=0,64 for /dev/hda,hdb

For SCSI :
device=/dev/sd[abcd] (n=partition number)
major=8
minor=0,16,32,... for /dev/sda,sdb,sdc,...


For example : if you have only one IDE disk with root partition being the 2nd one :

mknod /dev/hda2 b 3 2

=> Create a mount point and mount your root filesystem like this :

mkdir /my_root
mount /dev/hda2 /my_root


=> Use chroot to change your current root directory :

/my_root/sbin/chroot /my_root

=> Mount /proc and /usr like this :

mount /proc
mount /usr

=> Change your root password :

passwd
...
...

=> Unmount all filesystems and exit from the "chrooted" environment :

umount /usr
umount /proc
exit

=> Unmount your root filesystem and reboot

umount /my_root



Good luck !

Kodjo
Learn and explain...
Mark Fenton
Esteemed Contributor

Re: Root Passwd For LInux

Asif,

The idea of interrupting bootup and booting to single user mode is the simplest, and should not require a Boot floppy.

The exact procedure depends on whether you use LILO or GRUB as your boot loader. For both there is typically a 10 second window where you can enter options to the boot loader, select from bootable kernel versions, etc.

For LILO, enter
linux single
when the system gets to this pause

For GRUB, it's a little trickier, as often there's a password set for bootup (security measure to prevent what you're trying to accomplish) Assuming that there is no boot password, hit whichever function key the prompt says to enter to get the grub> prompt, then
grub> kernel /vmlinuz root=/dev/hda1
grup> boot single

This should do the trick

hth
Mark