Results 1 to 10 of 12
How does one go about resetting the root password if they've lost it....
- 04-07-2005 #1Just Joined!
- Join Date
- Apr 2005
- Posts
- 7
Reset root password.
How does one go about resetting the root password if they've lost it.
- 04-07-2005 #2Just Joined!
- Join Date
- Sep 2004
- Location
- Cape Town, South Africa
- Posts
- 83
First, try single user. If you don't see either a LILO or GRUB boot screen, try hitting CTRL-X to get one. If it's LILO, just type "linux single" and that should do it (assuming that "linux" is the lilo label). If GRUB, hit 'e", then select the "kernel" line, hit "e" again, and add " single" (or just " 1") to the end of the line. Press ENTER, and then "b" to boot.
You should get a fairly normal looking boot sequence except that it terminates a little early at a bash prompt. If you get a "Give root password for system maintenance", this isn't going to work, so see the "init" version below.
If you do get the prompt, the / filesystem may not be mounted rw (although "mount" may say it is). Do
mount -o remount,rw /
If that doesn't work (it might not), just type "mount" to find out where "/" is mounted. Let's say it is on /dev/sda2. You'd then type:
mount -o remount,rw /dev/sda2
If you can do this, just type "passwd" once you are in and change it to whatever you like. Or just edit /etc/shadow to remove the password field: move to just beyond the first ":" and remove everything up to the next ":". With vi, that would be "/:" to move to the first ":", space bar once, then "d/:" and ENTER. You'll get a warning about changing a read-only file; that's normal. Before you do this, /etc/shadow might look like:
root:$1$8NFmV6tr$rT.INHxDBWn1VvU5gjGzi/:12209:0:99999:7:-1:-1:1074970543
bin:*:12187:0:99999:7:::
daemon:*:12187:0:99999:7:::
adm:*:12187:0:99999:7:::
and after, the first few lines should be:
root::12209:0:99999:7:-1:-1:1074970543
bin:*:12187:0:99999:7:::
daemon:*:12187:0:99999:7:::
adm:*:12187:0:99999:7:::
You'll need to force the write: with vi, ":wq!". (If that still doesn't work, you needed to do the -o remount,rw, see above).
Another trick is to add "init=/bin/bash" (LILO "linux init=/bin/bash" or add it to the Grub "kernel" line). This will dump you to a bash prompt much earlier than single user mode, and a lot less has been initialized, mounted, etc. You'll definitely need the "-o remount,rw" here. Also note that other filesystems aren't mounted at all, so you may need to mount them manually if you need them. Look in /etc/fstab for the device names.
Keep this in mind if you have a Linux machine in a publically accessible place : without more protection, it's not usually hard to recover a lost root password, which means it's just as easy for someone to CHANGE it, or access root without your knowlege.
Another way to do this is to remove the password from /etc/shadow. Just in case you screw up, I'd copy it somewhere safe first. You want to end up with the root line looking something like this:
# original line
root:$1$EYBTVZHP$QtjkCG768giXzPvW4HqB5/:12832:0:99999:7:::
# after editing
root::12832:0:99999:7:::
If you are having trouble with editing (you really do have to learn vi one of these days), you could just (after making a copy, of course) just
echo "root::12832:0:::::" > /mnt/etc/shadow
or, if you were in single user mode
echo "root::12832:0:::::" > /etc/shadow
and then fix things up when rebooted.
- 04-07-2005 #3Linux Enthusiast
- Join Date
- Oct 2004
- Posts
- 609
Boot the system into runlevel 1/single user/emergency.
Here, the root password isn't asked for.
When you're in, issue a "passwd" and there you enter a new root password
- 04-07-2005 #4Linux Guru
- Join Date
- May 2004
- Location
- forums.gentoo.org
- Posts
- 1,814
This is another of those occasions where it's really good to have a liveCD like Knoppix or DamnSmallLinux that you can boot to, do a quick edit and get on with it.
/IMHO
//got nothin'
///this use to look better
- 04-07-2005 #5Linux Enthusiast
- Join Date
- Oct 2004
- Posts
- 609
Knoppix... don't leave home without it
Originally Posted by drakebasher
Sure you are!
Nowadays, I always have a Knoppix cd tucked away in my briefcase, just in case!
- 04-07-2005 #6Linux Guru
- Join Date
- May 2004
- Location
- forums.gentoo.org
- Posts
- 1,814
And with DamnSmallLinux, you can leave the briefcase behind, too!
Originally Posted by boba_fett
/IMHO
//got nothin'
///this use to look better
- 04-08-2005 #7Linux Enthusiast
- Join Date
- Oct 2004
- Posts
- 609
LOL ! ! !
Originally Posted by drakebasher
- 05-11-2005 #8Just Joined!
- Join Date
- May 2005
- Location
- Texas
- Posts
- 7
Howto Knoppix
Pardon my newb-ness. I have a couple of old boxes that I'm experimenting with (FC3), and had a Knoppix CD (v3.8.1) lying around also. I tried booting the Knoppix CD on one of my FC3 boxes, and could see the boot partition with the kernel images, but not the rest of the files. Is this because I'm using volume management, or did I miss something?
Thanks in advance
Mike
- 05-11-2005 #9Just Joined!
- Join Date
- May 2005
- Location
- Texas
- Posts
- 7
Never Mind
Found my answer in another Linux Forum. Knoppix doesn't support LVM, although several posters seem to feel that it is a trivial addition. I find it strange that Fedora will use LVM as a default during install unless you build partitions manually, and then creates rescue diskettes that don't/can't mount LVM volumes.
What were they thinking?
- 05-11-2005 #10Linux Guru
- Join Date
- May 2004
- Location
- forums.gentoo.org
- Posts
- 1,814
Thanks for answering to your own post, MrMoke, I was curious to know the explanation. And yeah, that's weird about Fedora: there must be more to it....
/IMHO
//got nothin'
///this use to look better


Reply With Quote
