Discussion:
Remove Root Password from Shadow file
(too old to reply)
Klist Smith
2005-03-04 03:33:35 UTC
Permalink
I forgot my root password for my Linux. Heard that I can simply remove
the line in the "shadow" file under \etc\.

What will happen if i simply remove it and reboot? Will it ask for a new
password or what?

Pls advise. Thanks.
hyperfusion
2005-03-04 03:36:22 UTC
Permalink
im not sure, but i think the root password will be empty.
so just login as root and hit 'enter' when your box prompts you for a
password

don't trust me though :-)
Floyd L. Davidson
2005-03-04 04:38:12 UTC
Permalink
Post by Klist Smith
I forgot my root password for my Linux. Heard that I can simply
remove the line in the "shadow" file under \etc\.
What will happen if i simply remove it and reboot? Will it ask
for a new password or what?
Pls advise. Thanks.
Don't remove the whole line, just remove the password part.
Here's an example:

root:$1$AAoxxU.8$auu1uBprTz0gCKi4QCf5b1:11636:0:::::

Change that to:

root::11636:0:::::

And you will have no password for root. You can then login as
root by just hitting the return key at the password prompt (su
won't even prompt for a password), and the next step would be to
run /passwd/ and set a new password. Use something that you
won't forget!

Some systems will let you go to single user and give you a root
shell without a password, so try that first. If that works,
just run /passwd/ to set a new password and then go back to
multiuser mode. You don't actually need to even reboot.

Otherwise, in order to remove it you'll need to boot from a
rescue disk, an intallation CD, a spare root partition, or
something else that gives you a root shell with at least a few
minimal commands available.

If you get access by booting into something other than your
normal root filesystem, you will need to mount your normal root
partition and edit the shadow file. For example, if your normal
root partition is /dev/hda1, and it has an ext2 filesystem:

mount -t ext2 /dev/hda1 /mnt

You should first save a copy the file,

cp /mnt/etc/shadow /mnt/etc/shadow.orig

and then use whatever editor is available to edit it. If you
have no editor at all, things get only slightly more
complicated. Just make a temporary /etc/shadow file that will
allow you to reboot and login as root:

echo "root::11636:0:::::" > /mnt/etc/shadow

Then reboot, login as root and copy the /etc/shadow.orig file
back to /etc/shadow before running /passwd/ to set a new
password.
--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) ***@barrow.com
Jake Nelson
2005-03-04 04:45:21 UTC
Permalink
Post by Klist Smith
I forgot my root password for my Linux. Heard that I can simply remove
the line in the "shadow" file under \etc\.
What will happen if i simply remove it and reboot? Will it ask for a new
password or what?
Pls advise. Thanks.
boot off a livecd/rescue disc (Try out the new knoppix 3.8 or something)
mount the parition, chroot /mnt/harddriveparition or whatever you
mount the disk parition as and change the root password. Reboot to the
installed system and you should have no problem logging in as root. If
you are deleting something in /etc/ I assume you are already booting off
a livecd/rescue disc.
Bill Unruh
2005-03-04 08:11:21 UTC
Permalink
Post by Klist Smith
I forgot my root password for my Linux. Heard that I can simply remove
the line in the "shadow" file under \etc\.
What will happen if i simply remove it and reboot? Will it ask for a new
password or what?
Remover the :x: in /etc/passwd for root. This will make the account
passwordless. Or log on in single user mode (linux 1 at the lilo prompt)
and then run passwd to make a new password for root.
Mike Mol
2005-03-04 17:53:00 UTC
Permalink
Post by Klist Smith
I forgot my root password for my Linux. Heard that I can simply remove
the line in the "shadow" file under \etc\.
What will happen if i simply remove it and reboot? Will it ask for a new
password or what?
Pls advise. Thanks.
Rather than remove, it, why not change it?

When you boot Linux, add "init=/bin/sh" to the command line.

When it comes up, run

mount / -o remount,rw
passwd
mount / -o remount,ro

And then power off the computer. (The shutdown command won't
necessarily work, so we use the mount command to put the root
filesystem in a safe state.)

When you power back up, your password should be whatever you set it to
when prompted by the passwd command.

DISCLAIMER: These comands worked for me yesterday on one of my Debian
boxen. I believe they'll work for other distributions, but I'm not
sure. You may be required to type the full path to the commands.
Nico Kadel-Garcia
2005-03-05 05:01:56 UTC
Permalink
Post by Klist Smith
Post by Klist Smith
I forgot my root password for my Linux. Heard that I can simply
remove
Post by Klist Smith
the line in the "shadow" file under \etc\.
What will happen if i simply remove it and reboot? Will it ask for a
new
Post by Klist Smith
password or what?
Pls advise. Thanks.
Rather than remove, it, why not change it?
When you boot Linux, add "init=/bin/sh" to the command line.
Some, but certainly not all, systems have their grub.conf or lilo.conf
password locked so you need a password to change the boot options. That's
why a rescue CD comes in handy, or if the BIOS is locked as well, pulling
out the hard drive and mounting it on another machine to make the changes.
Mike Mol
2005-03-08 03:50:39 UTC
Permalink
Post by Nico Kadel-Garcia
Post by Mike Mol
When you boot Linux, add "init=/bin/sh" to the command line.
Some, but certainly not all, systems have their grub.conf or
lilo.conf
Post by Nico Kadel-Garcia
password locked so you need a password to change the boot options. That's
why a rescue CD comes in handy, or if the BIOS is locked as well, pulling
out the hard drive and mounting it on another machine to make the changes.
I do a lot of servicing on friends' Linux laptops. Even the occasional
desktop someone brings in for me to look at. I've never been asked for
a bassword when modifying kernel parameters from the menu.

I'm not saying it's not possible; I've gone through the lilo docs
enough to know exactly how to do it. (grub's still somewhat new to me;
I'm using it on one of my machines, but it hasn't yet shown substantial
advantages for me.)

However, I've gradually come of the opinion that your average home
Linux user doesn't password-protect their boot menus, and, as long as
distros don't enable it by default, they're unlikely to.
Dave Brown
2005-03-09 01:37:09 UTC
Permalink
Post by Nico Kadel-Garcia
Post by Nico Kadel-Garcia
Post by Mike Mol
When you boot Linux, add "init=/bin/sh" to the command line.
Some, but certainly not all, systems have their grub.conf or
lilo.conf
Post by Nico Kadel-Garcia
password locked so you need a password to change the boot options.
That's
Post by Nico Kadel-Garcia
why a rescue CD comes in handy, or if the BIOS is locked as well,
pulling
Post by Nico Kadel-Garcia
out the hard drive and mounting it on another machine to make the
changes.
I do a lot of servicing on friends' Linux laptops. Even the occasional
desktop someone brings in for me to look at. I've never been asked for
a bassword when modifying kernel parameters from the menu.
I'm not saying it's not possible; I've gone through the lilo docs
enough to know exactly how to do it. (grub's still somewhat new to me;
I'm using it on one of my machines, but it hasn't yet shown substantial
advantages for me.)
However, I've gradually come of the opinion that your average home
Linux user doesn't password-protect their boot menus, and, as long as
distros don't enable it by default, they're unlikely to.
Password protecting a boot loader is a waste of time. Anyone who has
physical access to a machine can gain root access to a machine. If you're
interested in security, instead of fiddling around with password-ing the
boot loader, lock the door!
--
Dave Brown Austin, TX
Peter T. Breuer
2005-03-09 08:53:23 UTC
Permalink
Post by Dave Brown
Password protecting a boot loader is a waste of time. Anyone who has
physical access to a machine can gain root access to a machine. If you're
Can one lock the bios these days from within linux?
Post by Dave Brown
interested in security, instead of fiddling around with password-ing the
boot loader, lock the door!
Might be nice to have a deadman's switch in the bios. Must get a ping
from X every day or disk will be wiped ... dangerous, though!

Peter
Bill Davidsen
2005-03-22 21:36:06 UTC
Permalink
Post by Nico Kadel-Garcia
Post by Nico Kadel-Garcia
Post by Mike Mol
When you boot Linux, add "init=/bin/sh" to the command line.
Some, but certainly not all, systems have their grub.conf or
lilo.conf
Post by Nico Kadel-Garcia
password locked so you need a password to change the boot options.
That's
Post by Nico Kadel-Garcia
why a rescue CD comes in handy, or if the BIOS is locked as well,
pulling
Post by Nico Kadel-Garcia
out the hard drive and mounting it on another machine to make the
changes.
I do a lot of servicing on friends' Linux laptops. Even the occasional
desktop someone brings in for me to look at. I've never been asked for
a bassword when modifying kernel parameters from the menu.
I'm not saying it's not possible; I've gone through the lilo docs
enough to know exactly how to do it. (grub's still somewhat new to me;
I'm using it on one of my machines, but it hasn't yet shown substantial
advantages for me.)
However, I've gradually come of the opinion that your average home
Linux user doesn't password-protect their boot menus, and, as long as
distros don't enable it by default, they're unlikely to.
Most people don't need the protection. It's only useful when someone may
have physical access to the machine but be unwilling to break into the
case. A password on the boot, setting the BIOS to boot HD first, and
password on the BIOS are all low effort things to do. The next step up
is to use an encrypted filesystem for the really critical stuff.
--
-bill davidsen (***@tmr.com)
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me
Continue reading on narkive:
Loading...