Linux single-user mode

First, the single-user mode Introduction

Forget the root password chances of this problem is very high, however, to solve this problem in linux is very simple, just reboot the linux system, then boot into linux in single-user mode (init1), due to the single-user mode is not required enter the login password, so you can log into the system directly, modify the root password to solve the problem.

Second, the single-user mode to change the password

File is read when Centos6 start: /etc/grub.cfg;

Centos7 start reading when the file is: /etc/grub2.cfg

1, Centos6 into single user to change the password

1, restart the system, enter the system welcome screen, press the arrow keys to enter the GRUB interface;

In this interface, press the arrow keys to enter GRUB interface;

2, select the kernel version GRUB screen, press the 'e' key;

Select line kernel kernel press 'e' key to enter the

3, this interface can be edited in the last input 'single' and press Enter to return

Selected kernel line, and press the 'b' key to enter the single-user mode.

4, change passwords

Passwd root modify the root password

5, reboot the system reboot

2, Centos7 single user to change the password

1, into the GRUB page, select the appropriate kernel, press 'e' key;

Note: The first acts of kernel; the second rescue mode behavior.

2, modify the information into the kernel interface, find Linux16 this line;

At the end of this line add init = / bin / sh

Press 'Ctrl + x' single user mode

3, enter single-user, re-mount the root directory, so that it can be written;

Execute mount -o remount, rw /

4, modify the character set (optional)

Locale view the current character set

Input export LANG = en_US

The character set of the terminal to English

5, change passwords

passwd root

6, when selinux firewall start, after modifying the password file to be created

touch /.autorelable

Otherwise unable to restart the system restart

7, reboot the system

exec /sbin/init

Guess you like

Origin www.cnblogs.com/yxf-/p/11441518.html