How to reset password in linux

reset password in linux
5/5 - (2 votes)

In the previous post, we covered how to change password in linux. But what do you do when you have forgotten the current root password? In this post, we will see how to reset a password in Linux.

When a regular user forgets their password, root can easily reset or change it. If you forget the root password itself, you need to know how to reset it from the boot process. The steps below are common to all types of linux users.

First, you need physical access or console access to the system. As a general rule, resetting any password requires console access. Reboot the system, and in the GRUB menu press e so you can edit the boot parameters before the kernel is loaded.

On the GRUB page you will see the conditions. After the closing fi statement, in the last line, look for rhgb quiet and replace it with rd.break. Now press Ctrl+X to boot the system.

reset password in linux

After the reboot, your root partition is read-only, so remount it with the following command:

mount -o remount,rw /sysroot
chroot /sysroot

Now enter the new password with:

passwd

You are not done yet. SELinux is enabled by default in CentOS, so you need to handle it before the next boot. Type:

touch /.autorelabel
exit
reboot

After the system restarts, log in with the new password. You have successfully reset the root password in Linux.

Related articles

nslookup practical commands

Anyone who works in IT has run into a failed DNS request at least once, and it can be frustrating. In this…