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

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

October 11, 2014 by sharad chhetri 4 Comments

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.

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

Follow the given below procedure 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.

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 calledlinux16 . Now remove the parameter rhgb and quiet .

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.

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

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.

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

时间: 2024-10-20 19:26:30

CentOS 7 / RHEL 7 : Reset / Recover forgotten root password的相关文章

How To Reset Your Forgotten Root Password On CentOS 7 Servers

Sometimes you forget stuff. I do. I forget important passwords for important websites sometimes. Retrieving your forgotten passwords for most websites is easy, all one has to do remember few details that were used when signing up for the service to g

How to recover the root password in Centos 6 ?

How to recover root password in Centos 6 ? How to recover the root password ? 1) Press ' E ' when starting the server. 2) Select Kernel followed by pressing ' E ' to edit the commands. 3) Add 'single' or '1' then press enter. 4) Press " B " to b

mysql forget root password

http://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password MySQL - Resetting a lost MySQL root password The MySQL root password allows full access to the MySQL database and allows for all actions to be undertaken inc

Reset root password in CentOS 7 / RHEL 7

There may be some occasion you will end up with requirement to reset the root password, the occasion comes when you forget root password; follow this guide to reset the password of root. In CentOS, single user mode will help us to achieve our goal of

RHEL7 recover reset root password

If you have lost or forgot root password of RHEL7, you can follow this step to change to a new password, this is different with the RHEL6  single-usermode, 1, press e button in GRUB 2 boot screen. 2, at the end of Linux line add init=/bin/sh and remo

CentOS 7 / RHEL 7 上安装 LAMP + phpMyAdmin

原文 CentOS 7 / RHEL 7 上安装 LAMP + phpMyAdmin 发表于 2014-11-02 作者 Haoxian Zeng 更新于 2014-12-12 之前根据在 Linode VPS 上部署 LAMP 服务器的经验写了安装记录,得到不少网友的亲睐.随着 CentOS 7 发布,安装过程发生了不少变化.因此在虚拟机上跑了一下,根据之前的记录做了修改,以供参考.主要注意的是,现在数据库由 MySQL 改成 MariaDB 了,故而 LAMP 代表的就是 Linux + A

CentOS 7 /RHEL 7: How To Change The System Locale

The system localeare used to control the language setting of system services and the UI before the user logs in. How Do I change the default system locale in CentOS 7 linux system? How to check the current locate setting under centos 7 or RHEL 7 ? Ho

How to install redis server on CentOS 7 / RHEL 7

How to install redis server on CentOS 7 / RHEL 7 October 4, 2014 by sharad chhetri Leave a Comment In this tutorial we will learn, how to install redis server on CentOS 7 / RHEL 7 . The abbreviation of redis is REmote DIctionary Server. It is one the

在CentOS 7 / RHEL 7配置OpenLDAP服务

OpenLDAP是OpenLDAP项目开发的轻量级目录访问协议的开源实现.LDAP是一种Internet协议,电子邮件和其他程序用于从服务器查找联系人信息.它是在OpenLDAP公共许可下发布的; 它适用于所有主要的Linux发行版, AIX, Android, HP-UX, OS X, Solaris, Windows和z/OS. 它以某种方式用作关系数据库,可用于存储任何信息.LDAP不限于存储信息; 它还用作"单点登录"的后端数据库,其中用户的一个密码在许多服务之间共享. 在本教