• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

CentOS 7 / RHEL 7 : Reset / Recover forgotten root password

October 11, 2014 by Sharad Chhetri

In this post we will learn, how to reset / recover forgotten root password on CentOS 7 / RHEL 7 (Red Hat Enterprise Linux 7). On RHEL 5/6 or CentOS 5/6 series , the method of resetting forgotten root password was same. In latest RHEL 7 / CentOS 7 this time we have found some difference in steps to reset the forgotten root password.

Earlier, root password were used to recover from runlevel in case the boot loader password is not set.

Steps To Reset Forgotten Root Password

Follow the given below steps to reset forgotten root password.

Step 1: Reboot or start the system, edit grub2

Restart/start the system and on getting GRUB 2 boot screen, first press ESC key so that screen get stopped. Then press e key for editing.

vbox-1

Step 2: Initialize the /bin/sh

Now in next screen, scroll down with the help of arrow key and search for any of these two keyword linux16 or linuxefi on UEFI systems.In our case, we have linux16.

Disable rhgb and quiet parameters in order to enable system messages.

In first screenshot you can see, we first scrolldown to line starting with keyword called linux16 . Now remove the parameter rhgb and quiet .

root-passwd-2

In second screenshot you can see, we have removed the rhgb and quiet parameter
Add the below given parameter at the end of line, to initialize the sh shell.

init=/bin/sh

Now press CTRL with x keyword to boot the system.

root-password-3

Step 3: Remount / root partition , reset root password and autorelable

The filesystem will be in read only mode, hence run the below given command so that you can write on filesystem

mount -o remount, rw /

Now reset root password with given below command

passwd root

Reconfirm the root password.

NOTE: In case system is not writable, the passwd tool fails with the following error:
Authentication token manipulation error

Now run the below given command for relabeling the SELINUX

touch /.autorelabel

Now restart the system. You can use any one of the command.

exec /sbin/init

OR

exec /sbin/reboot

vbox-6

You will see the system is going to reboot and stuck for a short time. Just wait for a few seconds or minute. Keep pay attention that the screen is stopped when SELIUX relabeling info message appeared on screen.
After a few moment, you will see at the bottom of screen some numerical percentage is running. It states about the completion of selinux relabeling in percentage. After completing 100% , the system will be rebooted.

vbox-7

After successful booting, you can use your new root password for login into system.

vbox-8

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Recover Linux Grub Password in linux rescue mode CentOS/Red Hat
  2. How to reset forgot root password in CentOS 6.x and Redhat 6.x
  3. Forgot root password ,Reset it in Run level 1
  4. Set and reset user password by bash script
  5. ghost blog reset password and activate user from sqlite
  6. How to set root password on Ubuntu / Debian / Linux Mint
  7. How to increase Password Expire date without resetting the password
  8. Linux: Set user password by using encrypted password in command
  9. Root Is Not Able To Login In Red Hat And CentOS
  10. Password prompt in single user mode is not secure : CentOS/Red Hat

Filed Under: Linux Tagged With: forgot root password

Reader Interactions

Comments

  1. Pavlin says

    July 3, 2019 at 12:44 pm

    Thanks. It works for me uner RHEL 7.6.

  2. sebastian says

    December 28, 2016 at 10:15 pm

    hello i follow everithing step by step but still getting the same error Authentication token manipulation error using centos 7 elastix 4.0 but i dont know what happend

  3. rajendra says

    November 5, 2016 at 4:42 am

    I am getting above-mentioned error. “Authentication token manipulation error ” while resetting password.you said if system is not writable then this error will reflect. Now how to fix the issue .please help me

    • Sharad Chhetri says

      November 5, 2016 at 10:58 am

      Hi,

      mount -o remount, rw / you should run this command before executing passwd command.

      Regards
      Sharad

  4. franst says

    June 30, 2015 at 3:51 am

    my problems solved now… nice share, Thanks before!!! 🙂

    • sharad chhetri says

      June 30, 2015 at 3:07 pm

      Thanks franst,

      Feedback is important for us , keep reading our blog.

      Regards
      Sharad

  5. 影痕 says

    October 14, 2014 at 1:13 am

    thinks,谢谢!!!

    • sharadchhetri says

      October 14, 2014 at 12:06 pm

      Welcome 歡迎

      • SOMASHEKHAR B K says

        July 18, 2018 at 8:13 am

        Hello, sir good afternoon, just now I followed ur step all are good and password also updated successfully, after the reboot my Redhat showing full black screen it is not booting. please resolve this

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

Change the default port number of ssh server

set and unset line number in file with vi editor

SSH WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

error command ‘gcc’ failed with exit status 1 in Ubuntu

convert space into new line using sed command

How to forcefully send mail from mailq in sendmail MTA

How to change login banner message in GUI mode in CentOS 6 or above version.

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ·
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy