Category Archives: CentOS 7

How To Reset Root Password In CentOS 7 – grub 2

The first step to reset the root password is boot the CentOS machine in emergency mode, and for this process, we’ll use rd.break.

Start the system and, on the GRUB 2 boot screen, press the ‘e’ key for edit:


Remove the rhgb and quiet parameters from the end, or near the end, of the linux16 line, or linuxefi on UEFI systems.


Add the following parameters at the end of the linux16 line on x86-64 BIOS-based systems, or the linuxefi line on UEFI systems: rd.break enforcing=0


When you finish, press ctrl + x to load the system. Finally you’ll boot in emergency mode.


After emergency mode booting, you must remount the filesystem as writable because it’s mounted read-only, so you just have to type the following command:

mount -o remount,rw /sysroot

Now change the file system’s root as follows: chroot /sysroot

Finally, you’ll get a chroot environment ready to reset the password. Probably you know the command to set a user password, but if don’t, let me explain it.

The way to set a password is easy just type passwd user_name

user_name isn’t necessary if you’re logged in the session, so for this tutorial, you must type only “passwd


If the system is not writable, the passwd tool fails with the following error:

Authentication token manipulation error

Updating the password file results in a file with the incorrect SELinux security context, because SELinux is a Linux kernel security module that provides a mechanism for supporting access control security policies, to relabel all files on next system boot, enter the following command:

touch /.autorelabel

But I have to tell you something, relabel a large disk takes a long time, so you can omit this step provided you included the enforcing=0 option.

Now you must remount the filesystem as read only using the following command:

mount -o remount,ro /

Now exit from chroot environment and exit to finish the system boot (just type exit two times).


If you omitted to relabel files enter the following command to restore the /etc/shadow file’s SELinux security context:

restorecon /etc/shadow

Enter the following commands to turn SELinux policy enforcement back on and verify that it is on:

setenforce 1


That’s all friends. The process to reset the root password isn’t hard and this isn’t the only way to do it. Also, you can use an installation disk or maybe a live Linux cd of another distro.


How to Reset Forgotten Root Password in RHEL/CentOS and Fedora

In this post will guide you simple steps to reset forgotten root password in RHEL, CentOS and Fedora Linux with example. There are various ways to reset root password which are.

  1. Booting into single user mode.
  2. Using boot disk and edit passwd file.
  3. Mount drive to another system and change passwd file.


Here, in this article we are going to review “Booting into single user mode” option to reset forgotten root password.

Cautious: We urge to take backup of your data and try it out at your own risk.

STEP 1. Boot Computer and Interrupt while booting at GRUB stage hitting ‘arrow‘ keys or “space bar“.


booting at GRUB

STEP 2. Type ‘a‘ to modify kernel argument. Anytime you can cancel typing ‘ESC‘ key.

modify kernel argument

STEP 3. Append 1 at the end of “rhgb quiet” and press “Enter” key to boot into single user mode.

rhgb quiet

STEP 4. Type command “runlevel” to know the the runlevel where you are standing. Here “1 S” state that your are in a single user mode.


STEP 5. Type ‘passwd‘ command without username and press ‘Enter‘ key in command prompt. It’ll ask to supply new root password and re-type the same password for confirmation. “Your are Done” Congratulation!!!

supply new root password