Home >Operation and Maintenance >CentOS >What to do if you forget your username and password in centos7
If you forget your CentOS 7 login credentials, you can use the following methods to restore access: Through single-user mode: Boot to single-user mode Reset the root password Using rescue mode: Boot from rescue mode Use the switch_root command to access the system root Retrieve password : Run the passwd command and enter the new password to restart the server login
What to do if you forget your CentOS 7 login credentials
If you If you forget your CentOS 7 server username or password, don't panic, there are several ways to restore your access.
Method 1: Restart the server via single-user mode
Use the arrow keys to find the following line:
<code>linux16 /vmlinuz-0-rescue-0ec373f68251446a502f01c251031839b6f5f44d7d066749d0e24d0.x86_64 root=LABEL=/ rw</code>
Find root=LABEL=/ rw
and replace it with the following:
<code>init=/bin/sh</code>
Method 2: Using Rescue Mode
After the system starts, you will be prompted to enter the following command:
<code>/usr/bin/switch_root /sysroot</code>
Retrieve Password
No matter which method you use, once you enter single-user mode or rescue mode, you can use the following steps to recover your password:
passwd username
, where username
is the username whose password you forgot. The new password has now been set. You can restart the server to log in with the new password.
The above is the detailed content of What to do if you forget your username and password in centos7. For more information, please follow other related articles on the PHP Chinese website!