How do I log into my Linux laptop if I have forgotten both the username and password?
You can drop into single mode from Grub. During boot press Esc on the Grub boot screen when it prompts you to. It may just show you Grub with listings of each kernel - if that's the case don't press Esc.
From here select the first entry and press e to edit that entry. Page down to the line that starts with
This will allow you to edit the entire line. Scroll to the right until you reach the end and remove
From here you can add users to the system, change user passwords, etc.
You might do as Marco suggested, but his will not work on all distros. More precisely, it will not work without the need of giving the root password on systems using openrc.
The more generic way, without using any other bootable media, is to append
Another option, maybe a last resort, is to boot from a removable media (like livecd), mount the root partition of your system and either chroot to it or do a dirty job on