Summarize this article:

The Grub menu appears right after you turn on the computer. In most cases, it only stays on the screen for a few moments.  If you don’t press E before the Grub menu disappears, reboot and try again. This method works for most popular Linux distributions (Ubuntu, CentOS 7, Debian). There are many distributions of Linux, some more obscure than others. If you’re not able to get to single-user mode with this method, check your distribution’s website for instructions specific to your system. Use the ↑ and ↓ keys to do so. This is the line you’ll need to modify in order to boot into single-user mode. In CentOS and some other distributions, the line may begin with linux16 rather than linux. Use the →, ←, ↑, and ↓ keys to place the cursor right after ro. The end of the line should now look like this:ro init=/bin/bash. Note the space between ro and init=/bin/bash. This tells the system to boot directly to a root-level command prompt in single-user mode. This mounts the file system in read-write mode. Since booting into single-user mode gives you root access, there’s no need to pass additional parameters to the passwd command. The characters you type won’t be displayed on the screen. This is normal. When the system confirms you’ve re-entered the same password, you’ll see a message that reads “password updated successfully.” This command reboots the system normally.

Summary:
Restart your computer. Press E at the Grub menu. Scroll to the line that begins with linux	     /boot. Move the cursor to the end of the line. Type init=/bin/bash after ro. Press Ctrl+X. Type mount –o remount,rw / at the prompt and press ↵ Enter. Type passwd at the prompt and press ↵ Enter. Type a new root password and press ↵ Enter. Retype the new password and press ↵ Enter. Type reboot –f and and press ↵ Enter.