How To Reset Root Password On CentOS 7

Have you ever encountered a situation when you missed your user account password on a Linux System? If you forget user password, you can easily reset it using root account.

What if you forget your root password? You cannot reset root account password using user account. Since user account is not permitted to perform such task in general.

So I planned to boot into single user mode.

  • As the system boots, press ESC to bring up the GRUB boot prompt. The prompt happens early in the boot process. If you miss the prompt, you need to restart the server from the control panel and try again.
  • At the GRUB boot prompt, press E to edit the first boot option.
  • Find the kernel line starting with linux16.
  • Change ro to rw init=/sysroot/bin/sh.
  • Press CTRL+X or F10 to boot into single user mode.
  • Access the system with the command: chroot /sysroot
  • Type passwd and follow the prompts to change the root password.
  • Run touch /.autorelabel to force file system relabeling. This is required for systems with SELinux. When you reboot the system, it will relabel the filesystem for SElinux. The reboot may take extra time during this process.
  • Run reboot -f to reboot the server.

  • That’s it. Hope this blog is helpful.

One Comment

  1. Pingback:Rsync Command in Linux with Examples easy to learn - Basic guide - WEB HOSTING PUNE

Leave a Comment

Your email address will not be published. Required fields are marked *