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.
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 ↓.
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.
4. Press CTRL
1. Mount the root directory
mount -o remount, rw /
passwd root
touch /.autorelabel
exec /sbin/init 或 exec /sbin/reboot
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!