Tuesday, February 23, 2010

Forgot Linux root password.

1. Boot linux with rescue cd.
For that when shell comes, write
"linux rescue"
2. Mount the root using
"chroot /mnt/sysimage"
3. goto "/etc" and open "passwd"
4. search for item root passwd
5. Using your favorite text editor, edit the root entry of the
/etc/passwd file to remove the password, which is located between the first and second colons. Do this only if the password field does not contain an "x," in which case see below.

root:Yhgew13xs:0:0: ...

Change that to:

root::0:0: ...

If the password field contains an "x," then you must remove the
password from the /etc/shadow file, which is in a similar format.
Refer to the manual pages: "man passwd," and "man 5 shadow."

Note: Incorrectly editing any of the files in the /etc/ directory can severely screw up a system. Please keep a spare copy of any files in case you make a mistake.

No comments:

Post a Comment