Post by Klist SmithI forgot my root password for my Linux. Heard that I can simply
remove the line in the "shadow" file under \etc\.
What will happen if i simply remove it and reboot? Will it ask
for a new password or what?
Pls advise. Thanks.
Don't remove the whole line, just remove the password part.
Here's an example:
root:$1$AAoxxU.8$auu1uBprTz0gCKi4QCf5b1:11636:0:::::
Change that to:
root::11636:0:::::
And you will have no password for root. You can then login as
root by just hitting the return key at the password prompt (su
won't even prompt for a password), and the next step would be to
run /passwd/ and set a new password. Use something that you
won't forget!
Some systems will let you go to single user and give you a root
shell without a password, so try that first. If that works,
just run /passwd/ to set a new password and then go back to
multiuser mode. You don't actually need to even reboot.
Otherwise, in order to remove it you'll need to boot from a
rescue disk, an intallation CD, a spare root partition, or
something else that gives you a root shell with at least a few
minimal commands available.
If you get access by booting into something other than your
normal root filesystem, you will need to mount your normal root
partition and edit the shadow file. For example, if your normal
root partition is /dev/hda1, and it has an ext2 filesystem:
mount -t ext2 /dev/hda1 /mnt
You should first save a copy the file,
cp /mnt/etc/shadow /mnt/etc/shadow.orig
and then use whatever editor is available to edit it. If you
have no editor at all, things get only slightly more
complicated. Just make a temporary /etc/shadow file that will
allow you to reboot and login as root:
echo "root::11636:0:::::" > /mnt/etc/shadow
Then reboot, login as root and copy the /etc/shadow.orig file
back to /etc/shadow before running /passwd/ to set a new
password.
--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) ***@barrow.com