Get the App
SLTechnology News&Howtos  ›  Servers  › 

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

Shulou Source: shulou.com Published: 2022-06-01 17:37:14 10月01日 Update

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.

Tags: Password input user system selection command article what to do one line screen more version interface program space keyboard different good complex practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS OPPO Reno Docker Microsoft