Re: Lose Linux root password
- From: Lew Pitcher <lpitcher@xxxxxxxxxxxx>
- Date: Tue, 09 Jun 2009 13:27:52 -0400
On June 9, 2009 13:00, in alt.os.linux, Ivan Marsh (ivanmarsh@xxxxxxxxx)
wrote:
Johnson wrote:
I lose my root password, and couldn't get into the Linux. I have some
data stored in the hard drive, and I don't want to lose them. What is
the easiest way to recover the system?
Thanks.
Assuming you're using grub as the boot loader, edit the kernel parameters
at boot and add "single" to the end of the line that loads the kernel.
Then run passwd from the maintenance prompt and change the password.
"Single user" mode, initiated from grub or from lilo kernel parameter list,
will not guarantee unfettered root access to a standard Linux-based system.
Most distributions protect even the single-user mode with a password-based
login prompt. Thus, despite the Linux Gazette advice (as pointed out by
another poster) and the advice of Mr. Marsh, above, "single" won't
necessarily permit the OP to fix his problem.
If it works, then it works. But, if it doesn't, then the OP can use a "live
distro" to recover his files.
To the OP: If "single user" mode doesn't let you in, then
- boot a "live distro" CD, like Ubuntu
- obtain a commandline (run xterm or terminal or something)
- get root; with "live boot" distros, this is usually dead simple, as the
root password is usually provided as part of the documentation
- mount your real root directory onto an unused directory of the live boot
environment (i.e. onto /mnt). Make certain you mount it rw
- cd to your newly-mounted root directory
- enter the following command: "chroot . /bin/bash" to obtain a command
prompt that uses your newly-mounted root directory and /it's/ files
(including it's etc/passwd and etc/shadow)
- enter the passwd command to change roots password
When you are done
- enter "exit" to quit the chroot shell
- cd to the real /
- umount your installation's root directory
- shutdown and reboot
What this does is permit the password program from /your/ installation to
work on the password files from /your/ installation, by running everything
in an environment that starts with your installation as the root
filesystem. Up to the point where you chroot, you are just establishing a
running environment, but when you chroot, you have effectively
re-established /your/ installation, with access as root.
Hope this helps
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------
.
- Follow-Ups:
- Re: Lose Linux root password
- From: Ivan Marsh
- Re: Lose Linux root password
- References:
- Lose Linux root password
- From: Johnson
- Re: Lose Linux root password
- From: Ivan Marsh
- Lose Linux root password
- Prev by Date: Re: Lose Linux root password
- Next by Date: Re: Lose Linux root password
- Previous by thread: Re: Lose Linux root password
- Next by thread: Re: Lose Linux root password
- Index(es):
Relevant Pages
|