Home >Operation and Maintenance >CentOS >What to do if you forget your username and password in centos7

What to do if you forget your username and password in centos7

下次还敢
下次还敢Original
2024-04-07 19:54:201103browse

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 username and password in centos7

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

  1. .
  2. In the boot menu, press e to enter the GRUB editor.
  3. Use the arrow keys to find the following line:

    <code>linux16 /vmlinuz-0-rescue-0ec373f68251446a502f01c251031839b6f5f44d7d066749d0e24d0.x86_64 root=LABEL=/ rw</code>
  4. Press e to edit the line.
  5. Find root=LABEL=/ rw and replace it with the following:

    <code>init=/bin/sh</code>
  6. Press Ctrl X to boot into single-user mode .

Method 2: Using Rescue Mode

  1. In the boot menu, select "Rescue Mode".
  2. After the system starts, you will be prompted to enter the following command:

    <code>/usr/bin/switch_root /sysroot</code>
  3. After executing this command, you will enter the same environment as when you forgot your password.

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:

  1. Run passwd username, where username is the username whose password you forgot.
  2. The system will prompt you to enter a new password.
  3. Enter the new password twice.

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!

Statement:
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