how to change root password in debian

This is one of the problem faced by many person’s“what if i lost the root password”First thing that comes in mind is “use single user mode” but the answer is NO.
coz debian takes the system security to one more level up and by default ask’s for the root password.

so the BIG QUESTION IS HOW TO proceed further

follow these steps

1) on grub-boot prompt.
press “e” to enter edit mode

2) then press downarrow to reach the line that starts with “kernel “
press “e” again

3) at the end of this line type in “init=/bin/sh” or “/bin/bash”

4) then press enter to make that change and press “b” to boot

in a few seconds you will be on your “#” prompt

5) only one step left
“mount -o remount rw /”

this step is necessary coz in this case root file system is mounted as read only.

6) finally type “passwd” and you get the screen to change the password

and then type in “init 6? or “reboot”

those who are looking for the technical details, the main work is the init command that we passed as an argument to kernel, it told kernel to specifically run the command specified in parameter instead of working on normal routine.

TRICK = if you have any program you wish to run instead of this then you can do that too using init command only.


Sponsored Link

10 thoughts on “how to change root password in debian

  1. As long as you ‘ve physical access to the Linux box, you can crack in to any Linux box irrespective of which flavor of Linux use. So i don’t really believe with you – Debian is special and you can’t easily crack in to it.

  2. I have found that the best way to change a root password on a NIX box is to:

    – boot up with a “Live CD” such as KNOPPIX
    – mount (rw) the partition that contains the /etc folder
    – open the passwd file in a text editor of your choice
    – find the line for the root user
    – backspace over the field containing the encrypted password
    – save the file
    – remove the CD and reboot

    Now you can login as root without a password ans run passwd to reset it.
    KNOPPIX has many valuable uses. Get yours today at

  3. – backspace over the field containing the encrypted password

    I do not see a password. I see
    and see no user names at all.

    How can I change?

    Installed Debian and con not log in as user or root, so do not no how to use passwd command, as I can not get to root terminal.


  4. The file in question is “/etc/shadow” unless you explicitly disabled shadow passwords during installation.

  5. if u have ur user with sudo rights u can do a simple
    sudo passwd root
    im saying this cause whenever i install a system the first thing i do is give sudo permission

  6. Hello I am running Deb 504 as a nx cherry and recently after running a bunch of package installation in synaptic and security updates in a gnome desktop I found my user password changed and so I used rescue disk and changed it back. Next time I ran deb full I found my root changed as well (!?) So I tried editing shadow with vi using rescue cd , bash on assumed root and saved and no joy… whats left? Should I use a liveCD other than the debian?
    Any idea is appreciated as I’d have to go to square 1 for the 4th time.

  7. in grub its eaiser to just add the whole line drectly rw init=/bin/bash
    so u dont need to remount in rw from ro 🙂

    // A

Leave a comment

Your email address will not be published. Required fields are marked *