Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to enter single-user mode in centos7/rhel7 to recover root password

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to enter the single-user mode in centos7/rhel7 to recover the root password. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

To restore the root password in RHEL6 (including previous versions), simply edit the kernel startup entry at startup, add s (1 or single) to the last line of the kernel and enter single-user mode to repair the root password.

But after arriving at RHEL7, it is not allowed to do so. There are rescure,emergency and other modes for entering a single user in RHEL7, but you still have to enter a root password to log in. To fix the root password, just follow these steps:

When you boot to see the kernel entry, press e to start editing, add rw init=/bin/sh at the end of the kernel, remove the rhgb and quiet parameters (must be removed), press ctrl+x to start the system, and enter the system without a password:

1. Start OS to the following interface and press: e key to enter the editing state

2. Add: rw init=/bin/sh at the end of rhgb quiet and press: Ctrl+x to enter single-user mode, or enter root user password at the end of rhgb quiet to enter single-user operation.

3. If the file cannot be saved after editing, re-mount it in the way of rw (otherwise there is no write permission):

To ensure that some files are affected by the selinux context, you must execute the following command:

Touch /. Autorelabel

Initialize and boot the system:

Exec / sbin/init

There is an invalid device in the / etc/fstab directory, which makes OS unable to enter the system, so you need to enter the root user password for maintenance check and delete or comment out invalid or redundant boot entry settings.

Redhat 7 enters single-user mode to repair system failure

1. Start the machine, select the first one in the grub interface, and press e

2. Turn down and find the line at the beginning of Linux16

3. Change ro to "rw init=/sysroot/bin/sh" and press ctrl+x to start the system (rhgb   quiet is deleted; (no code lines in quiet mode can be deleted))

4. After entering the system, change to the root directory of the real system first. Chroot / sysroot/, can use ls / to view files. When you see the real directory of your system, the switch is successful.

Next, do what you need to do.

Finally, enter exit twice, and then type reboot to restart

The above is how to enter the single-user mode to recover the root password in centos7/rhel7 shared by Xiaobian. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report