The root user, or superuser, in Linux is a special and very careful user since he has all the privileges available in the system to perform any available task such as creating, editing or deleting accounts, deleting or adding users and many more which if run incorrectly can lead to multiple errors in system services. We must bear in mind that this user is different from all the others and that therefore we have to use it with caution since otherwise we can change irreversible damage to the equipment..
As it is a special user, it is not used frequently and instead we put “sudo†before the commands executed to grant this privilege whenever we have the administrator password, so that something normal is that we forget the root password which is set from the moment the system is installed. This is something that can happen since the number of passwords every day is very large, because many applications , emails, web pages, etc. require it. That is why those passwords that we do not use too often, such as the root user on our PC, we forget if we have not written it down anywhere to be able to remember it easily.
If this is your case (you have forgotten the password) you should not worry since in this tutorial we will explain how to reset this password in CentOS 8 step by step so that you can run this process on your PC..
To stay up to date, remember to subscribe to our YouTube channel! SUBSCRIBE
How to reset root password on CentOS 8
Step 1
To start this process, we restart the system and on the first boot we will see the following:
Step 2
There we enter the letter "e" to access the CentOS 8 editing console:
Step 2
There we place the word "ro" (read-only) which is in front of the path root = / edv / mapper / cl-root and replace "ro" with "rw" and add the following line:
init = / sysroot / bin / sh
Step 3
After this we will use the Ctrl + X keys to access the simple mode and there we will enter the following:
: / # chroot / sysroot
Step 4
This will mount the root file system in read and write mode, then we enter the following:
: / # passwd root
Step 5
Pressing Enter you must confirm the new passwords:
Step 6
We proceed to enable SELinux re-labeling with the following command:
: / # touch /.autorelabel
Step 7
We exit the editor and restart CentOS 8 with the lines:
: / # exit : / # reboot
After this it will be possible to log in to CentOS 8 as root user by entering the new password that we have defined:
With this simple procedure it will be possible to recover the root user password in CentOS 8 and in this way manage the user in the system in a much more appropriate way. You must bear in mind that this password is very important and therefore it must be strong and secure so that our team is safe.