How to Reset Root Password in Linux for Beginners

Reset root password in Linux means changing the main administrator password. To reset it, access recovery mode or use a bootable Linux media. Follow prompts to set a new root password. This process helps regain admin access.

🤖AI Overview:

Reset root Password in Linux refers to the process of creating a new password for the root user when the current password is unknown or forgotten. This action is typically completed using recovery mode or a live system to gain access and securely update the password. Resetting the root password restores administrative control of the Linux system and is essential for maintaining system security and accessibility.

Note: Before starting, consider that you should have Console Access or VNC access to the server to log in to the single-user mode. This interface enables you to access the server console even if you don’t have access to it over the network connection.

Quick Steps to Reset root Password in Linux

  1. Reboot your system and access the boot menu.
  2. Highlight your Linux entry and press “e” to edit.
  3. Find the line starting with linux and add “init=/bin/bash” at the end.
  4. Press Ctrl plus X to boot into single-user mode.
  5. Type passwd root and press Enter to set a new password.
  6. Enter your new root password when prompted.
  7. Type exec /sbin/init and press Enter to restart.
  8. Log in using your new root password.

Reset password in CentOS 6

To login into a single-user mode in CentOS 6, you have to stop the bootloader process. Open the console, reboot the machine and stop the booting process by pressing the Space key. Now press the A to be able to modify the setting.

 

Login to single user mode to reset password in centos 6

 

On the new page, add a space and type 1, and press enter. Now the system will automatically reboot and login to the single-user mode.

 

login to single user mode

 

On the new page, we will use the passwd command to change the password. Consider that you cannot see the password text when changing the password because of the security measures.

 

reset the password in centos 6

 

Now, reboot the operating system using the reboot command or the reboot button on top of your console, and you will be able to log in using the new password that you set.

Reset password in CentOS 7 and CentOS 8

To login into the emergency mode in CentOS 7 and reset the password, you have to stop the bootloader process. Open the console, reboot the machine and stop the booting process by pressing the Space key. Now press the E to be able to modify the setting.

 

Stop boot loader process in centos 7

 

Use the up and down arrows to scroll and find the ro word.

 

change arguments to reset pass in centos 7

 

Please change it to rw init=/sysroot/bin/sh and press ctrl + x simultaneously to go to the emergency mode automatically.

 

Change read and write permissions and add init process to the sysroot

 

On the new page, change the directory to sysroot using the following command.

chroot /sysroot

And use the passwd root command to change the root password. Reboot the machine, and you will log in using the new password you’ve set.

 

reset CentOS 7 server password in emergency mode

 

Reset password in Debian 9 and Debian 10

After you buy Linux VPS, such as Debian, you may forget the server’s password for any reason. To reset the password in Debian, reboot the server and stop the automatic boot by pressing the Space key. Once you did it, you should see the Grub section in the following picture.

 

grub in debian 9

 

Now, press e to be able to edit the grub file. Find the line finishing with ro quiet and add init=/bin/bash to the end of it.

 

edit grub menu in Debian

 

Finally, press the control + x buttons simultaneously to log in to the single-user mode.

Enter the following command to adjust the permissions.

mount -n -o remount,rw /

And use passwd command to change the password.

 

change permissions and change password in debian 9 and debian 10

 

Reset Password in Ubuntu 18 and Ubuntu 20

To change the password of ubuntu 18 or ubuntu 20, like the other operating systems, we need to log in to single-user mode. To do this, reboot or start the server and stop the booting process by pressing the Space key.

 

Grub menu in ubuntu

 

Once it was stopped, press the e button to be able to edit the Grub Menu.

 

edit ubuntu grub Menu

 

Find the ro and change it with the rw init=/bin/bash and consider that the line should be finished with the mentioned parameters so change the ro and any other sentences after the ro with rw init=/bin/bash

 

change ro to rw in Ubuntu to reset password

 

Type the following command to modify the permissions.

mount | grep -w /

Once you did it, you should see the message (rw, realtime).

Change the password using passwd command and reboot the server.

 

change password in ubuntu18 and ubuntu 20

 

Concludion

Resetting the root password in Linux is a vital process you can follow step by step. Each stage ensures your access is restored in a secure way.

Remember to keep your new root password in a safe location and only share it with trusted users.

If you have any questions, OperaVPS is here to support you. Thank you for trusting me to guide you through how to reset root password in Linux.

FAQ

You should reset the root password in Linux if you cannot remember your current password or if you suspect that your account has been compromised. It is also necessary when you are handed over a server and do not have the previous root credentials.

No, you do not need advanced knowledge, but it is helpful to understand basic Linux commands. Most beginners can reset the root password by following clear, step-by-step instructions.

Resetting the root password is safe if you follow the correct steps. However, unauthorized access to the root account can cause security risks. Always ensure you have permission to perform this action.

In most cases, you need to restart the system into recovery mode or single-user mode to reset the root password. Some specific situations may allow you to reset it while the system is running, but this is not recommended for beginners.

Most Linux distributions such as Ubuntu, CentOS, Debian, and Fedora support similar methods for resetting the root password. There may be slight differences in the procedure, so always check the steps for your specific distribution.

After resetting the root password, update your password to something strong and unique. Also, review your server’s security settings and limit root access where possible to keep your system secure.

If you are unable to reset the root password, check your boot mode and ensure you have the correct permissions. If you are using a virtual private server, your hosting provider may offer a recovery console or support team to help.

No, you cannot reset the root password through SSH if you have lost the current password. You will need physical or console access to your server to perform the password reset.

Resetting the root password does not delete or modify your files or data. The process only changes the password for the root user and does not impact your data storage.

Leave a Reply

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