Linux: Reset root password

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

Linux: Reset root password

Post 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)
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply