How To Reset Any Linux Password

Varun Kashyap 10-03-2009

how to reset password in linuxA few days back we looked at how to password protect your GRUB boot entries How To Password Protect GRUB Entries (Linux) Read More so that a password is required before anyone can boot the operating system or edit the boot entry.


Let’s look at some ways you can use to reset your Linux system’s password. You might know that the root user can change the password for any other user. However what if you forget your root password? This is what we would attempt to achieve here.

So, how to reset password in Linux?

To reset your root password (or any other account’s password for that matter), there are essentially two different situations which require varying approaches.

When you can use GRUB

If you have GRUB installed and you have accesses to edit boot parameters of selected entries then the job is as easy as it can get. Follow along and you shall have root access in no time. Once you have root access you can pretty much do anything you want to do!

  • Highlight the GRUB entry for the Linux installation that you want to reset the password for.
  • Press ‘e’ to edit. Select the Kernel line. Add ‘single’ at the end of the kernel line. Press ‘b’ to boot. If your system still requires you to enter the root password, add init=/bin/bash at the end. Press ‘b’ to boot.
  • reset password linux

    how to change password linux

  • Either you would be taken to the root prompt directly or shown the recovery menu from where you can choose the root prompt. Use passwd <username> to change the password for any account.
  • How To Reset Any Linux Password rootprompt

  • Type reboot to reboot the system and then log in in with your new password.

Also, note that some distributions will create a recovery mode entry during install. If you have the recovery mode entry listed in GRUB, you need not do any of the above, just choose the recovery mode and then choose root prompt at the screen that follows.


When you can’t use GRUB

If you are unable to use GRUB for whatever reasons (like password protected entries) you can still reset the password using a Live CD (I will be using Ubuntu Live CD, you may use any other). Just follow the steps below to achieve this:

  • Boot from the Live CD
  • Choose “Try Ubuntu without any changes to your computer”
  • How To Reset Any Linux Password tryubuntu

  • When the system is ready, fire up a terminal window and get ready for some command line action
  • Type sudo fdisk -l. In the output we are concerned to know which partition Linux is installed on and what name the hard disk is using. (e.g) in this case it is /dev/sda1 is the required partition. If you are sure about the partition you can skip this step.
  • How To Reset Any Linux Password fdisk

  • Next we need to mount the Linux partition. Create a directory to act as mount point for the partition. Use ‘sudo mkdir /media/linx_part
  • How To Reset Any Linux Password mkdir

  • Mount the linux partition using the command ‘sudo mount /dev/sda1 /media/linx_part
  • How To Reset Any Linux Password mount

  • Change Root to the mount directory – ‘sudo chroot /media/sda1
  • Type passwd and then enter the new password to change the password.
  • How To Reset Any Linux Password chroot

  • Type reboot to restart the system.

Have you ever attempted such a password recovery? How did you go about it? Have some other nice tricks to show off? Let us know in the comments.

Related topics: GRUB Bootloader, Live CD, Password.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

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

  1. razorwirez
    October 10, 2019 at 9:11 pm

    The reason it' not working is because he made a mistake:

    where it says:
    " Change Root to the mount directory – ‘sudo chroot /media/sda1‘ '

    it should say:

    Change Root to the mount directory – ‘sudo chroot /media/linx_part‘

  2. alert("XSS");
    April 5, 2017 at 7:37 am


  3. Linux-Anon
    March 8, 2017 at 1:27 pm

    How does one prevent this from happening?

  4. Jim
    August 12, 2016 at 2:25 am

    The live CD solution didn't work for me. chroot got an error which I don't have exactly, but it indicated that /bin/bash wasn't found. More googling indicated that the supporting libraries for chroot have to be found in the new root directory. I ended up trashing my hard drive trying to copy them over. Bad idea, but it was one of the answers. Ended up reinstalling Windows. At least now my password problem is gone.

  5. Richard
    April 18, 2015 at 3:45 am

    Says user does not exist. Same exact user as shown on log in screen.

  6. Sreekuttan M K
    March 10, 2015 at 3:31 pm

    Thank you so much... It helped me a lot.. May God bless you. .

  7. password for linux
    January 19, 2010 at 7:48 am

    i still can't change the root or user password because i have a sidux and it doesnt't work like that ..can someone make a password recovery for linux:sidux...

  8. gaurav
    May 9, 2009 at 10:59 am

    but how to stop anybody to change root password. by your way anybody can change change the password. but i dont want anybody to change password before booting.........

    • Phil
      June 5, 2009 at 12:38 pm

      An encrypting file system will work just fine.

  9. Thomas Defranc
    March 11, 2009 at 10:07 am

    Change Root to the mount directory - ‘sudo chroot /media/sda1‘

    must be:
    Change Root to the mount directory - ‘sudo chroot /media/linux_part‘