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

What if the virtual machine Linux system forgets the password and modifies the password of root or other users

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

Share

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

This article will explain in detail about the virtual machine Linux system forget password change root or other user password how to do, editor feel very practical, so share to you as a reference, I hope you can get something after reading this article.

Working with scen

The linux administrator forgot the root password and needs to retrieve it.

Note: this article is based on the centos7 environment, because the version of centos is different, please determine the version before continuing.

Steps

First, restart the system, in the boot process, quickly press the keyboard direction keys ↑ and ↓. The goal is to tell the bootstrapper that we need to select a different action on the boot page in order for the bootstrapper to pause.

The following is the paused interface. You can check the English below to see the role of ↑ and ↓.

Use ↑ and ↓ to set the selected row to the first row (background highlight is selected), press e on the keyboard to enter edit mode

Move the cursor all the way to the back of LANG=en_US.UTF-8, a space, and then append init=/bin/sh. Note here that you need to write after UTF-8, keep it on the same line, and pay attention to the spaces. It is normal for some virtual machines to automatically add\ line breaks because the screen is too small.

4. Press CTRL+X to boot and enter the interface after success

Enter the following command

1. Mount the root directory

Mount-o remount, rw /

2. Select the user name for which you want to change the password. Here, select the root user to change it, and you can change it to the user you want to modify.

Passwd root

3. Enter the same new password twice, and note that there are no characters on the screen when entering the password.

If the password you enter is too simple, you will be prompted with a warning (BAD PASSWORD:Thepassword fails the dictionary check-it is too simplistic/systematic). You can ignore it and continue to enter the password, but it is recommended to set a more complex password to ensure security.

4. If you have enabled SElinux, you need to enter the following command

Touch /. Autorelabel

5. Finally, enter the following command to restart the system

Exec / sbin/init

About "virtual machine Linux system forgot password change root or other user password how to do" this article is shared here, I hope the above content can have some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

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