петък, 21 декември 2012 г.

How to reset your root password

Couple of ways to reset your password, if you happen to mess it.
First, if you are in KDE (or whatever) and you know your sudo password, it is very easy to recover your pasword:
$sudo su -
$passwd
and type your new password.
(source)
And that's it.

If you happen to have lost your sudo password as well, you can do it the hardcore way.

First, you need to edit the kernel boot load in GRUB to reboot into single use mode by adding "init=/bin/sh". That's very useful if you screw your X and you cannot enter terminal the normal way.
Now, you have to remount the disk into read-write mode:
$mount -o rw,remount /dev/ROOT
in my case
$mount -o remount,rw /
Now do:
$nano /etc/shadow
and on the line root you need to remove everything between the first and second :
Then save and use
$password
to change your password. Then reboot. (source)
Third, there is the chroot way. I never done that, but I'll paste it here for completeness. And for desperate cases. Now, you need a LiveCD.
From it do:
$mount /dev/hda3 /mnt/gentoo
$mount /dev/hda1 /mnt/gentoo/boot
$mount -t proc none /mnt/gentoo/proc
where /dev/hda3 is your / , /dev/hda1 is your /boot, and /dev/hda2 is your swap.
Then do
$chroot /mnt/gentoo /bin/bash
which is supposed to change the environment from LiveCD to your PC. Sounds pretty creepy if you ask me.
Finally, do:
$passwd
and change your password. Then reboot and be happy.
(source)
P.S. If this way of chroot-ing doesn't help, then you can try:
# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"
#passwd
(source)

Няма коментари:

Публикуване на коментар