Remove Root Password from Shadow file - Linux

This is a discussion on Remove Root Password from Shadow file - Linux ; 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 ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: Remove Root Password from Shadow file

  1. Remove Root Password from Shadow file

    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.


  2. Re: Remove Root Password from Shadow file

    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 :-)


  3. Re: Remove Root Password from Shadow file

    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.


    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
    Ukpeagvik (Barrow, Alaska) floyd@barrow.com

  4. Re: Remove Root Password from Shadow file

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

    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.

  5. Re: Remove Root Password from Shadow file

    Klist Smith writes:

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



  6. Re: Remove Root Password from Shadow file


    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.

    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.


  7. Re: Remove Root Password from Shadow file


    "Mike Mol" wrote in message
    news:1109958780.935898.66620@g14g2000cwa.googlegro ups.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.



  8. Re: Remove Root Password from Shadow file


    Nico Kadel-Garcia wrote:
    > "Mike Mol" 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.


  9. Re: Remove Root Password from Shadow file

    Mike Mol wrote:
    > Nico Kadel-Garcia wrote:
    >
    >>"Mike Mol" 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.
    >

    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 (davidsen@tmr.com)
    "The secret to procrastination is to put things off until the
    last possible moment - but no longer" -me

+ Reply to Thread