In this article, you will learn, How to reset your root user password in Linux in 3 minutes
There are many passwords to store and remember. Sometimes system admins forgot their system root user password. And this creates a lot of trouble. In this tutorial, I will guide you, how to reset the forgotten root user password in just three minutes. This tutorial is valid for Red Hat Enterprise Linux, Fedora, and CentOS Enterprise Linux, or CentOS for short.
If your system hard disk is encrypted with LUKS, you would have to provide the LUKS password key when you got a prompt, but if you don’t have set this LUKS, then there is no problem. I have tested this process in CenOS 6.5/7/8 and RHEL 7/8 and Fedora 15 and later versions. You may also like to read how to boot into an emergency mode?.
Resetting your forgotten root user password in Linux
If your system is running (on) then, first you have to turn it off. And after turning it off, you can follow the below steps.
Turn on your computer
When you see the
GRUB2 boot menu, it means boot option, something like the below picture, press letter
e to edit the boot menu.
Step 3: You will see the screen like the below picture, you have to look for the line which is starting with
Step 4: At the end of this line, you have to type
rd.break and then press
Ctrl + x
Also, you can look at the below picture for getting help.
Step 5: If you have followed all the steps correctly, then you will see the screen which will start
When you see the above lines, you can start typing the below commands in series
mount -o remount,rw /sysroot
Also, now to reset the password use the below command.
Now you can type a new password for the root user.
retype the password
Using the below command, you will relabel the files which you have modified during the password change.
and now you can wait, it will take sometime and then, it will automatically reboot the machine. that’s all.
In this tutorial, you learned, How to reset your root user password in Linux in 3 minutes. This process is very easy as you saw. But, sometimes it’s harder when you are working in a production environment because you have to shut down the system, and then you can reset the password. So, I always recommend that you create a sudo user with at least password reset capability. I hope you understand but, if you have any questions, you can ask in the comment section.
Also, you may like to read further,