Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How you can reset root password in Linux if you forgotten?

user-image
Question added by Muhammad Anzar , DevOps/DevSecOps Architect , Confidential
Date Posted: 2015/04/15
Daneesh Viswanathan
by Daneesh Viswanathan , ICT Project Engineer , Salam Technology

We can reset the root password using single user mode.

Afeef Thasleem Abdul Rahim
by Afeef Thasleem Abdul Rahim , Warehouse And Logistics Coordinator , Emerson

Hello Muhammad,

 

You can your Linux root password by booting your system in to single user mode. While booting your system keep on pressing "e" to edit the kernel. Add "1" at the end of the kernel line and boot again by pressing "b"

Deleted user
by Deleted user

another method, is if you have any GNU/linux Bootable live CD, you boot from it and mount the partition that has the linux install say for example that you have it mounted on /mnt/sda1, from the command line you type 'chroot /mnt/sda1 bash'  or 'chroot /mnt/sda1 sh', what this will do is make bash or sh run and treat the path /mnt/sda1 as the root '/' path, so now you simply type 'passwd'  and it will re-write the root password on that mounted system, after you're done just reboot and try the new password.

 

 

Abu Nur Muhammad Hasanul Karim
by Abu Nur Muhammad Hasanul Karim , Manager-System Administration , Dhaka Stock Exchange Ltd.

Reboot the system, and when you are at the selection prompt , highlight the line for Linux and press 'e'. You may only have2 seconds to do this, so be quick.

This will take you to another screen where you should select the entry that begins with 'kernel' and press 'e' again.

Append ' single' to the end of that line (without the quotes). Make sure that there is a space between what's there and 'single'. If your system requires you to enter your root password to log into single-user mode, then append init=/bin/bash after 'single'. Hit 'Enter' to save the changes.

Press 'b' to boot into Single User Mode.

Once the system finishes booting, you will be logged in as root. Use passwd and choose a new password for root.

Type reboot to reboot the system, and you can login with the new password you just selected.

Rajesh Pant
by Rajesh Pant , System Engineer , Tech Mahindra Limited

Alternative if you have configured sudo user with superuser power or any user which is in superuser group can be reset after some changes.

karthikeyan purusothaman
by karthikeyan purusothaman , System Administrator , Anjalai Ammal Mahalingam Engineering College

reboot the running system and select boot loader and edit and press1 to boot single user mode , execute passwd command to reset root password

Sarath Joseph
by Sarath Joseph , IT Administrator , Adonis Interiors LLC

Interrupt booting while system start up, then select the kernel using arrow keys and edit the kernel by pressing 'e'. Press enter after typing '1' in kernel, and after that 'b' for booting the saved settings. Now the system boots up to a single user mode. Note that if you had set a Grub password, then it is needed before editing the Grub.

While you are in single user mode type passwd root then type new password and reboot the system using shutdown -r now or reboot.

Jerry John
by Jerry John , Devops Engineer , NeST Technologies

while booting break the boot process by:-

pressing  e and using rd.break remount to /sysroot

change the password using passwd command

and if it is rhel7 dont forget to autorelabel(for selinux)

 

Mosleh Saeidi
by Mosleh Saeidi , Linux & OSS Senior Supervisor , Fanoos Telecom

1- restart the machine 

2- once the grub menu apear select the kernel that you want boot from and press "e" to edit 

3- add digit "1" right after "rhgb quiet"

4- press Enter to boot the kernel, you will be enter to runlevel 1 (single user)

5- execute "passwd" and enter the new password twice 

Amr Abdelhafez
by Amr Abdelhafez , Technical Support Engineer L3 , VMware

enter the single user mode after you reboot your machine  while booting at GRUB stage hitting ‘arrow‘ keys or “space bar“

Append 1 at the end of “rhgb quiet” and press “Enter” key to boot into single user mode

then simply write passwd command and change your root password 

 

Satyaveer Arya
by Satyaveer Arya , System Engineer , InterGlobe Technologies

1. Edit grub boot menu options.

2. Press "e" to edit the first grub menu option and navigate to kernel line.

3. Press "e" key again to edit and remove:

quiet splash 

 

and add:

init=/bin/bash

 

4. You may have some different boot options but the main part you need to change/add is init=/bin/bash.

5. Press enter.

6. Now, press "b" key to boot.

7. After successfully boot you will be presented with bash command prompt.

8. On some linux systems, you will need to completely mount / and /proc partitions. To do that, enter following commands:

mount -o remount,rw / mount -o remount,rw /proc

9. To reset a actual root password, simply type "passwd" and provide the desired password.

10. Reboot.

More Questions Like This