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 reset a lost root password within 5 minutes

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

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to reset the lost root password within 5 minutes. The content of the article is of high quality, so Xiaobian shares it with you for reference. I hope you have a certain understanding of relevant knowledge after reading this article.

How to reset root password quickly and easily on Fedora, CentOS and similar Linux distributions.

System administrators can easily reset passwords for users who forget them. But what happens if the system administrator forgets the root password or leaves the company? This guide will show you how to reset a lost or forgotten root password in less than 5 minutes on Red Hat compatible systems, including Fedora and CentOS.

Note that if the entire system hard drive is encrypted with LUKS, you will need to provide the LUKS password when prompted. Additionally, this procedure applies to systems running systemd, which has been the default initial system since Fedora 15, CentOS 7.14.04, and Red Hat Enterprise Linux 7.0.

First you need to interrupt the startup process, so you need to start it or restart it if it's already started. *** This can be tricky because the GRUB menu flashes quickly across the screen. You may need to try several times until you can do it.

When you see this screen, press the e key on the keyboard:

If you do this correctly, you should see a screen similar to this:

Use the arrow keys to move to the Linux16 line:

Using your del key or your backspace key, delete rhgb quiet and replace it with the following:

rd.break enforcing=0

Setting enforcing=0 avoids performing a full system SELinux retag. Once the system restarts, you just need to restore the correct SELinux context for/etc/shadow. I'll show you how to do it.

Press Ctrl-x to start.

The system will now be in emergency mode.

Remount the hard drive with read and write permissions:

# mount –o remount,rw /sysroot

Run chroot to access the system:

# chroot /sysroot

You can now change the root password:

# passwd

When prompted, enter the new root password twice. If successful, you should see a message that says "all authentication tokens updated successfully."

Type exit twice to restart the system.

Log in as root and restore the SELinux label for/etc/shadow.

# restorecon -v /etc/shadow

Return SELinux to enforce mode:

# setenforce 1 How to reset the lost root password in 5 minutes is shared here. I hope the above content can help you and learn more. If you think the article is good, you can share it so that more people can see it.

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