Also, if you have messed up so badly that regular text mode does not work, or you have forgotten your password, you can try this:
Same as above, but instead of "3", add "init=/bin/bash". You should boot automatically to root command line without password. Note that this does not run your normal init system, so almost nothing (like internet access) gets autostarted, and stuff like systemctl might not work right. This can be both useful and detrimental to fixing your problem depending on the situation.
If you are worried someone might use this to bypass your computers security, consider encrypting your installation.