Page 1 of 1

Linux: Reset root password

Posted: Thu Oct 09, 2008 10:00 pm
by ^rooker
Sometimes you receive a computer from someone else, but they forgot to tell you login credentials.
Here's a short HowTo for resetting the root password to an empty string:

1) boot the computer - until GRUB comes up

2) In GRUB, press 'e' and add the following text to the boot parameters:

Code: Select all

single init=/bin/bash
3) You should now boot into single-user runlevel, ending at a bash prompt as root.

4) Remount the harddisk read-write:

Code: Select all

mount -o remount,rw /dev/hda1
(For further details, look at [DETAILS] section below)

5) Edit /etc/shadow and the password hash for root with nothing. You will find something like this:
root:$1$verylonghashwithlettersandnumbers:10000:0:99999:7:::
make it look like this:
root::10000:0:99999:7:::
6) Save the file and reboot. Now you should be able to login as root with no password.


[DETAILS]
1) In case your system disk ain't /dev/hda1, type:

Code: Select all

mount | grep "on / type"
The beginning of the output shows you your device. it might look like this:
/dev/sda1 on / type ext3 (rw,noatime,errors=remount-ro,data=writeback)