Booting to Emergency Mode

Emergency mode provides the most minimal environment possible and allows you to repair your system even in situations when the system is unable to enter rescue mode. In emergency mode, the system mounts the root file system only for reading, does not attempt to mount any other local file systems, does not activate network interfaces, and only starts few essential services. In Red Hat Enterprise Linux 7, emergency mode requires the root password.
As soon as the boot process starts, press ESC to bring up the GRUB 2 boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB 2 boot prompt. You will see GRUB 2 boot prompt – press “e” to edit the first boot option. Find the kernel line linux16 or linuxefi or linux (Each menuentry block that represents an installed Linux kernel contains linux on 64-bit IBM POWER Series, linux16 on x86_64 BIOS-based systems, and linuxefi on UEFI-based systems. Then the initrd directives followed by the path to the kernel and the initramfs image respectively) and add systemd.unit=emergency.target at the end of the line and then press CTRL-X to boot. System will boot and you will see the root prompt. Parameters, 1, s, and single, can be passed to the kernel as well.

Emergency Mode:
systemd.unit=emergency.target

It should look like this one:
–cut
1:
2: linux16 /vmlinuz-3.10.0-229.7.2.e17.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet LANG=en_IE.UTF-8 systemd.debug systemd.unit=emergency.target
3: initrd16 /initramfs-3.10-0-229.7.2.el7.x86_64.img
4:
–cut

Booting to Rescue Mode

Rescue mode provides a convenient single-user environment and allows you to repair your system in situations when it is unable to complete a normal booting process. In rescue mode, the system attempts to mount all local file systems and start some important system services, but it does not activate network interfaces or allow more users to be logged into the system at the same time. In Red Hat Enterprise Linux 7 and CentOS 7, rescue mode is equivalent to single user mode and requires the root password.
As soon as the boot process starts, press ESC to bring up the GRUB 2 boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB 2 boot prompt. You will see GRUB 2 boot prompt – press “e” to edit the first boot option. Find the kernel line linux16 or linuxefi or linux (Each menuentry block that represents an installed Linux kernel contains linux on 64-bit IBM POWER Series, linux16 on x86_64 BIOS-based systems, and linuxefi on UEFI-based systems. Then the initrd directives followed by the path to the kernel and the initramfs image respectively) and add systemd.unit=rescue.target at the end of the line and then press CTRL-X to boot. System will boot and you will see the root prompt. Parameters, 1, s, and single, can be passed to the kernel as well.

Rescue Mode:
systemd.unit=rescue.target

It should look like this one:
–cut
1:
2: linux16 /vmlinuz-3.10.0-229.7.2.e17.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet LANG=en_IE.UTF-8 systemd.debug systemd.unit=rescue.target
3: initrd16 /initramfs-3.10-0-229.7.2.el7.x86_64.img
4:
–cut

Boot Single User Mode – Resetting forgotten root user account password in RHEL/CentOS 7

As soon as the boot process starts, press ESC to bring up the GRUB boot prompt. You may need to turn the system off from the control panel and then back on to reach the GRUB boot prompt. You will see a GRUB boot prompt – press “e” to edit the first boot option. Find the kernel line linux16 or linuxefi or linux (Each menuentry block that represents an installed Linux kernel contains linux on 64-bit IBM POWER Series, linux16 on x86_64 BIOS-based systems, and linuxefi on UEFI-based systems. Then the initrd directives followed by the path to the kernel and the initramfs image respectively) and add init=/bin/sh at the end of the line and then press CTRL-X to boot.
System will boot and you will see the root prompt. Type mount -rw -o remount / and then passwd to change the root password and then touch /.autorelabel and then exec /sbin/init

In short:
init=/bin/sh – In case of VMWare like KVM or VirtualBox use rb.break instead of inti=/bin/sh
# mount -o remount,rw /
# passwd root
[Enter New Password]
[Re-enter New Password]
# touch /.autorelabel
# exec /sbin/init

It should look like this one:
–cut
1:
2: linux16 /vmlinuz-3.10.0-229.7.2.e17.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet LANG=en_IE.UTF-8 systemd.debug init=/bin/sh
3: initrd16 /initramfs-3.10-0-229.7.2.el7.x86_64.img
4:
–cut