Home  >  Article  >  Operation and Maintenance  >  What to do if you forget your password to log in to centos

What to do if you forget your password to log in to centos

下次还敢
下次还敢Original
2024-04-07 19:33:25653browse

Solutions for forgotten CentOS passwords include: Single-user mode: Enter single-user mode and use passwd root to reset the password. Rescue Mode: Boot from CentOS Live CD/USB, mount root partition and reset password. Remote access: Use SSH to connect remotely and reset the password with sudo passwd root.

What to do if you forget your password to log in to centos

How to log into CentOS if you forgot your password

Forgetting your CentOS password can be frustrating, but There are several ways to reset your password and regain access to your system.

Method 1: Single User Mode

  • Restart the server and hold down the Shift key to enter the GRUB menu.
  • Select "Advanced Options" and then select the entry labeled "Single User Mode".
  • You will be prompted to enter the root password. Since you forgot your password, press Enter to skip this step.
  • The system will boot into single user mode.
  • Reset the root password using the following command:
passwd root
  • Enter and confirm your new password.
  • Type the reboot command to restart the server.

Method 2: Rescue Mode

  • Boot the server using CentOS Live CD/USB.
  • When prompted to select a language, select "Rescue Mode".
  • The system will load the rescue system.
  • Mount the root partition:
mount /dev/sdaX /mnt
  • Reset the password in the mounted root partition:
chroot /mnt
passwd root
  • Exit chroot And remount the root partition:
exit
umount /mnt
  • Type the reboot command to restart the server.

Method 3: Remote Access

If your server is accessible via SSH, you can reset the forgotten password using a remote account:

  • Connect to the server using SSH:
ssh username@server_ip
  • At the remote prompt, use the following command to reset the root password:
sudo passwd root

Tip:

  • Choose a strong password and change it regularly.
  • Consider using a password manager to store your passwords securely.
  • If you forget another user's password, you can use the same process to reset them.

The above is the detailed content of What to do if you forget your password to log in to centos. 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