This is article was written to make your life a bit easier now that CentOS 7.1 has changed a couple of things we were accustom to. This article assumes that you have direct access to your server either via KVM, IPMI or standing in front of your server plugged in directly. You were brought here either because you lost or forgot your root password. It could also be that your admin is on vacation and forgot to give you access to your server just in case he was unreachable.This will walk you through step by step on how to reset the password on your CentOS 7.1 server. Lets begin.
The image above probably looks familiar as you are unable to login to your server. You will have to reboot your server either by Ctrl alt del or issue a cold reboot.
Once the server has been rebooted I would suggest you spam the space key on your keyboard so that it boot stops a grub menu. You will be seeing something like this:
Once the prompt has stopped at the grub menu highlight the latest kernel version. In this case it will be “CentOS Linux 7 (core), with Linux 3.10.0-229.14.1.el7.x86_64”. Once you have highlighted or selected your latest kernel press ‘e’ from your keyboard. This will allow you to edit your Kernel and it will looks something like this:
You will have to go down to the linux16 line and replace “rhgb quiet” with “init=/bin/bash” . When adding the line please keep in mind that the text is entered without quotes. If you do not see “rhgb quiet” you can just put init=/bin/bash at the end of the kernel line. Once you have replaced “rhgb quiet” it will look like this:
Once you are done editing you may go ahead and press ctrl+x on your keyboard. This will start the boot process with the parameters we have set above. Once boot up has been completed it will drop you into the bash prompt that will look like this:
You will need to have read-write permissions in order to change the root password. This can be accomplished using the following command:
mount -o remount,rw /
Now that you have mounted root filesystem into read-write mode you can reset the root password with the following command:
Now that you have successfully reset your root password. You will have to update your SELinux parameters. You can do this using the following command:
Once you have finished updating your SELinux paramaters. You will have to reboot your server. You can do this by running the following command:
Once you are at login prompt you will be able to gain access to your server with the new login information.