Skip to main content

Resetting the root password on RHEL 7 Systems

How to Reset Root Passwords on RHEL 7 and CentOS 7 Linux Systems

If you have forgotten your root password on a RHEL 7 server or a CentOS 7 server, you can reset your root password as long as you have access to the GRUB 2 bootloader. (The following example was performed on a RHEL 7.5 server)
To access the GRUB 2 bootloader, boot your system and wait for the GRUB 2 menu to appear:

Boot System and wait for GRUB 2 menu

Boot your system and wait until the GRUB2 menu appears. On some systems you may need to press the "Escape" key to access the GRUB 2 menu.



Highlight OS Entry

Highlight your Operating System and then press "e" to edit.


Find line beginning linux


Find the line beginning with linux. In this example the line begins linux16.


Manually Edit Line


Using the arrow keys and the delete key, manually delete the following entries rhgb and quiet from the line.

Next, append the following statement to the end of the line init=/bin/sh

Don't worry if your command is spread across more than one line. A continuation character "\ will be inserted automatically.


Ctrl +X to reboot using the specified options


To reboot your system now using the options specified, press the keys Ctrl +X

Once the system has re-booted, you will be presented with a shell prompt without having to enter any user name or password information

At this command prompt you will need to enter the following commands below:

Load Local SELinux Policy


Load the installed SELinux policy: /usr/sbin/load_policy -i

Remount "/" Filesystem in Read/Write mode


Remount the "/" root filesystem in Read/Write mode: mount -o remount,rw /

Issue passwd Command


Issue the passwd command to reset the root account password: passwd

Remount "/" Filesystem as Read Only


Remount the "/" root filesystem in Read Only mode: mount -o remount,ro /


Now reboot the system


You can now reboot the system. You can issue the command "exec /sbin/init 6" to reboot.

Once your system is backup, you should be able to login with the new "root" password.

Login with New Password


You should now have arrived at the login screen. Here you will be able to login with your root account using your new password. (You may need to login as a normal user then "su" to root depending on your system set-up)

Comments

Popular posts from this blog

Reset root pass in ESXi 5.5

    In this post i will show how to reset root password in ESXi 5.5. For this first we need any bootable linux distributor. In my example i used Ubuntu 16.04.     Boot from Ubuntu disk. Select try Ubuntu, wait for loading. After full loading open Terminal. Type fdisk -l for list all partitions hypervisor/system image is located on the first 250 MB partition (/dev/sda5) which contains the state.tgz file. Mount /dev/sda5 to /mnt sudo -s mount /dev/sda5 /mnt. Go to the /mnt cd /mnt . Copy state.tgz to /tmp folder cp state.tgz /tmp , cd /tmp. Unarchive state.tgz tar xzf state.tgz then   tar xzf local.tgz Go to the /etc directory in /tmp folder  cd etc/ . For deleting resetting password open shadow file with nano shadow  delete the password hash of ESXi root account. Close nano editor. Re add etc/ folder to local.tgz : tar czf local.tgz etc after it readd local.tgz to state.tgz: tar czf state.tgz local.tgz . Copy state.tgz mnt/ folder: cp state.tgz /mnt/ . umount /mnt 

Service Hosting - KVM documentation

Host System Requirements: Minimum host system requirements 6 GB free disk space. 2 GB RAM. Recommended system requirements One core or thread for each virtualized CPU and one for the host. 2 GB of RAM, plus additional RAM for virtual machines. 6 GB disk space for the host, plus the required disk space for the virtual machine(s). KVM Hypervisor Requirements: an Intel processor with the Intel VT-x and Intel 64 virtualization extensions for x86-based systems; or an AMD processor with the AMD-V and the AMD64 virtualization extensions. Installing the Virtualization Packages: To use virtualization on OL7, at minimum, you need to install the following packages: # yum install qemu-kvm libvirt qemu-kvm: This package provides the user-level KVM emulator and facilitates communication between hosts and guest virtual machines. qemu-img: This package provides disk management for guest virtual machines. The qemu-img package is installed as a dependency of the qemu-kvm package. libvirt: