Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Remove Root Password from Shadow file

2,750 views
Skip to first unread message

Klist Smith

unread,
Mar 3, 2005, 10:33:35 PM3/3/05
to
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

unread,
Mar 3, 2005, 10:36:22 PM3/3/05
to
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

unread,
Mar 3, 2005, 11:38:12 PM3/3/05
to

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) fl...@barrow.com

Jake Nelson

unread,
Mar 3, 2005, 11:45:21 PM3/3/05
to
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

unread,
Mar 4, 2005, 3:11:21 AM3/4/05
to
Klist Smith <klist...@hotmail.com> writes:

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

unread,
Mar 4, 2005, 12:53:00 PM3/4/05
to

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

unread,
Mar 5, 2005, 12:01:56 AM3/5/05
to

"Mike Mol" <mik...@gmail.com> wrote in message
news:1109958780....@g14g2000cwa.googlegroups.com...

>
> Klist Smith wrote:
>> 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.

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

unread,
Mar 7, 2005, 10:50:39 PM3/7/05
to

Nico Kadel-Garcia wrote:
> "Mike Mol" <mik...@gmail.com> wrote in message

> > 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.

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.

Bill Davidsen

unread,
Mar 22, 2005, 4:36:06 PM3/22/05
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 (davi...@tmr.com)
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me

0 new messages