How to change root password in centos

藏色散人
Release: 2020-02-07 11:12:01
Original
16747 people have browsed it

How to change root password in centos

How to change the root password in centos

If you know the root password, you need to change the password

Log in to the system as root and enter the passwd command to change the root password by default, and then enter the password twice.

How to change root password in centos

Recommended: "Linux Tutorial"

Application Scenario

The Linux administrator has forgotten the root password and needs to retrieve it.

Note: This article is based on the centos7 environment. Since the versions of centos are different, please confirm the version before continuing.

Operation steps

1. Restart the system. During the boot process, quickly press the ↑ and ↓ arrow keys on the keyboard. The purpose is to inform the bootstrap that we need to select a different action on the bootstrap page in order to cause the bootstrap to pause.

The following is the interface after pause. You can check the English below to know the functions of ↑ and ↓.

How to change root password in centos

2. Use ↑ and ↓ to set the selected line to the first line (the background is highlighted to indicate selection), press e on the keyboard to enter the editing mode

3. Move the cursor to the space after .UTF-8, and then append init=/bin/sh. Pay special attention here, you need to write it after UTF-8, keep it on the same line, and pay attention to spaces. Because the screen is too small, line breaks will be added automatically. This is normal.

How to change root password in centos

4. Press CTRL

1. Mount the root directory How to change root password in centos

mount -o remount, rw /
Copy after login

2. Select the user name whose password you want to change. Here, select the root user to modify it. You can change it to the user you want to modify

passwd root
Copy after login

3. Enter the same new password twice. Note that no characters will appear on the screen when entering the password.

If the password entered is too simple, a warning will be prompted (BAD PASSWORD: The password 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 it more complicated. Password to ensure security

4. If SElinux has been turned on, you need to enter the following command

touch /.autorelabel
Copy after login

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

exec /sbin/init
或
exec /sbin/reboot
Copy after login

The above is the detailed content of How to change root password in centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template