Change and reset root password in Centos 7

  • Home
  • blog
  • Change and reset root password in Centos 7
centOS

Change and reset root password in Centos 7

Many times the root server or VPS password has been lost or forgotten, and the only way to restore it is to reinstall the OS, which will delete all the server information.

But with only small changes, the password can be changed without entering the root.

Changing and resetting the root password in Centos 7:

first restart the server or VPS, then:

1. On the GRUB bootloader page on your operating system, click e to edit the file:

2. In the opened page, find the line where linux 16 is written and delete the word ro and place rw init=/sysroot/bin/sh:

3. Press Control+x to enter single user mode:

5. Then enter the following commands in order:

chroot /sysroot passwd root

Enter the desired password twice.

6. Update selinux with the following command:

touch /.autorelabel

7. Exit Chroot with the following command, then reboot the system:

Exit

Reboot

After the OS is loaded, we log in with the new password.

Check out our blog for more tutorials & articles.

Leave a Reply