Categories
linux Password

How to reset your linux password

This is a generic how to, working for all Linux distributions, not only for Ubuntu or Debian or Centos etc etc.

I see a lot of howto’s what are based on the same “story”: boot in “single mode” and type passwd to change the password, but are some systems like Debian and probably others what doesn’t let you get in single mode if you don’t know the root password … so the single mode solution it will not work.

First I will describe you the single mode solution, because the start of this solution is very similar with the next solution what I will present you in the end.

    How To change the root password in single mode

  1. Restart the machine.
  2. Press any key while GRUB menu is loading.
  3. You will see the Grub Menu with you configured kernels.
  4. Choose a good kernel (or the options what is starting your linux) and press e to edit it.
  5. Now choose the line that begins with ‘kernel’. Press ‘e’ again to edit this line.
  6. Now at the end of the line just add: single
  7. Press Enter and after that press b to boot that kernel

After that the kernel will start loading and if you have lucky and your installation doesn’t have password on “single mode” you will can change the root password with passwd utility. If you have the luck to have a password on the single mode just follow the next steps:

    Other way to change the linux root password

  1. Follow the same steps as “single mode solution” but only until step 6.
  2. Replace the step 6 with: Now at the end of the line just add: init=/bin/sh
  3. Press Enter and after that press b to boot that kernel
  4. Kernel will boot and it will stop in a shell
  5. In this shell type: mount -o remount,rw /
  6. Now type: passwd and change the password
  7. Now type: sync to syncing disk (flush from memory to HDD).
  8. After that remount the disk read only: mount -o remount,ro and reboot / Or Ctrl+Alt+Printscr+S, Ctrl+Alt+Printscr+U, Ctrl+Alt+Printscr+B if you have Magic Sysrq keys enable:)

What are MagicSysRq keys ?

These are some keys combination’s what will let you to access some kernel basic commands at low level. The combination’s what I give you above are for:

Ctrl+Alt+Printscr+S – sync the disk
Ctrl+Alt+Printscr+U – unmount the disk
Ctrl+Alt+Printscr+B – reboot

'Coz sharing is caring

By Swatantra Kumar

Swatantra is an engineering leader with a successful record in building, nurturing, managing, and leading a multi-disciplinary, diverse, and distributed team of engineers and managers developing and delivering solutions. Professionally, he oversees solution design-development-delivery, cloud transition, IT strategies, technical and organizational leadership, TOM, IT governance, digital transformation, Innovation, stakeholder management, management consulting, and technology vision & strategy. When he's not working, he enjoys reading about and working with new technologies, and trying to get his friends to make the move to new web trends. He has written, co-written, and published many articles in international journals, on various domains/topics including Open Source, Networks, Low-Code, Mobile Technologies, and Business Intelligence. He made a proposal for an information management system at the University level during his graduation days.

2 replies on “How to reset your linux password”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.