How to Change Root Password on CentOS

how to change password on centos 8

Hackers have become advanced in recent years, forcing users to devise secure unique, complex, and unique passwords. The drawback of these passwords is that they’re difficult to remember, and one could easily forget their passwords. It is also possible to forget your password if you haven’t checked in for an extended period of time.

In this guide, we’ll discuss how to change a password in CentOS 7 and 8 as well as the CentOS 7 root password in default when you buy Linux VPS Server.

 

Change Root Password on CentOS 8

If you’ve forgotten your password, even after trying many times to recall the password you used to use, you’re still unable to remember it. Don’t panic. You can easily reset the password even if you just buy Linux VPS; you can reset your root password by using the Boot menu of GRUB. To reset or change password in CentOS 8, specifically your root use. Simply reboot the device.

After the system has restarted, click the “ESC” key immediately to end the booting process.

Choose the kernel from the GRUB/Boot menu which you want to boot using the arrow keys.

The ‘e’ button on your keyboard will pull up the editing menu.

In the editing menu, locate the “ro” kernel parameter and replace it with “rw,” and add an additional parameter “init=/sysroot/bin/sh”:

Use Ctrl + the X key to enter the single-user mode after you have finished with the previous step.

Then, run your “chroot /sysroot” command to change your root system file into both write and read mode.

Now you will be able to change the root password.

To change the password for root, type the following command:

Passwd root

Then, you will be required to enter a new password and confirm it. It is recommended to choose a unique, complex and intricate password that is simple to remember.

The next step would be to begin SELinux relabelling. To initiate the relabeling of SELinux, follow the command:

Touch /.autorelabel

After changing the label, you can use these commands to store and apply the modifications:

exit

That’s how to change root password in CentOS 8. Now all you have to do is to restart the system by typing the “reboot” command into the terminal.

It may be necessary to wait for a few minutes for the SELinux relabelling process to finish.

Once the system is up and running again, you will get a window asking for root password.

 

Change Password in CentOS 7 from Terminal

If you are looking to change your password for root or have forgotten the current password, you don’t required to perform anything complicated, like the method we mentioned above. Simply open the CentOS 8 terminal and type the following command:

Sudo passwd root

If you’re logged in with the root username, you’ll be asked to enter and confirm your new password.

If you’re logged in as a regular user with Sudo privileges, you’ll be asked to enter the password you are currently using as well as the new password.

After successfully resetting your password for root, you need to sign in using the new password set as a root user. And that is how you would change root password in CentOS 7 and 8 using the terminal, if you were contemplating whether you should buy a CentOS server or not just because it is hard to work with, don’t. Linux in general is one of the coolest OS you can find and with many guides around, you are almost guaranteed to learn a thing or two and troubleshoot yourself.

 

Conclusion

In this guide of CentOS Linux change password we discussed how you would change a password from GRUB/Boot menu as well as the terminal. After you claim your Linux VPS server, remember to change your password in order to improve your server security.

Leave a Reply

Your email address will not be published.