Centos 7 forgets a password, change the root password

Scenarios

linux administrator forget the root password, you need to get back operation. 
Note: This article is based on centos7.4 operating environment, due to the centos version is different, make sure that a good version before continuing

Steps

A, reboot the system, the boot process, quickly press the direction keys on the keyboard and . The purpose is to inform boot program, we need to select a different operation guide page, so that the boot program is halted. 
The following is a pause after the interface, you can see English below shows the role of the ↑ and ↓. 

 

Second, the use and selection of the first row to the row (that is, the background highlighting is selected), pressed on the keyboard eto enter editing mode

Third, the cursor will move to the rear LANG = en_US.UTF-8, a space, then an additional init = / bin / sh. Special attention here, need to write in the UTF-8, remains in the same row, and note the space. Since the screen is too small, it will automatically add \ wrap, this is normal.

 

Fourth, the press CTRL+Xbooted, after successfully entered the interface

 

Fifth, enter the following command

1, mounts the root directory 
mount -o remount, rw /

 

2, choose to modify the user name and password, where the root user to modify selected, the user can replace you want to modify

 passwd root

3, enter the same new password twice, attention will not have to enter a password on the screen when the character appears. 
If the password is too simple, you will be prompted a warning (BAD PASSWORD: The password fails the dictionary check - it is too simplistic / systematic), you can ignore it and continue to enter the password, but the proposal is still set more complex passwords for security sex

4, enter "touch /.autorelabel" Update System Information

5, enter "exec / sbin / init" normal startup system

 

At this point to change the root password to complete

Guess you like

Origin www.cnblogs.com/GoCircle/p/11662575.html