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

The necessary measures taken to forget the root password of Linux system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

With the increasing number of Linux systems used in enterprises, root is a super administrator in Linux systems, which is equivalent to the administrator of Windows systems. Have absolute authority. The necessary actions taken when the administrator forgets the root password (with little chance, of course):

There are three ways to change the root password:

First, the first method: step 1: press "e" on the kernel after boot.

Step 2: move the cursor to the line at the beginning of linux16, add the kernel parameter rd.break, and press Ctrl+x to start

Step 3, restart the system by executing the following command

Touch / .autorelabel # / / if your system does not have selinux enabled, you do not have to do this step

After personal testing, there is no problem!

Second, the second method: step 1: press "e" on the kernel after boot.

Step 2: move the cursor to the line at the beginning of linux16, change it to rw init=/sysroot/bin/sh, and press Ctrl+x to start

Step 3: restart the system by entering the following command

Touch / .autorelabel # / / if your system does not have selinux enabled, you do not have to do this step

After personal testing, there is no problem!

Third, the third method:

Similar to fixing the GRUB boot menu, please refer to the blog: Linux repair MBR and GRUB boot menu

Enter first aid mode and enter "passwd root"!

It is obviously not safe to change the root user password so easily. To improve security, we can set the password to enter the GRUB menu as follows:

[root@localhost ~] # grub2-mkpasswd-pbkdf2 / / enter the password when prompted: Reenter password: PBKDF2 hash of your password is / / "is" is followed by an encrypted password string (due to restrictions Cannot be released) [root@localhost ~] # cp / boot/grub2/grub.cfg / boot/grub2/grub.cfg.bak [root@localhost ~] # cp / etc/grub.d/00_header / etc/grub.d/00_header.bak// is recommended to make a backup (experimental environment It doesn't matter) [root@localhost ~] # vim / etc/grub.d/00_header / / this is the configuration file for generating passwords through the key tool. / / omit part of the content cat

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