By setting init=/bin/sh in the editable grub command line. You can google how to get there exactly. This directly starts a root shell instead of the normal init process. (it is also in the raspberrytips link that were already linked in another comment).
This also means that anybody who has physical access to your console during bootup can root the system. If you do not want that, you need to set a harddisk encryption password (and optionally also a BIOS password, but the latter won´t protect e.g. against disassembling the computer and putting the HDD into another Linux box).
By setting
init=/bin/shin the editable grub command line. You can google how to get there exactly. This directly starts a root shell instead of the normal init process. (it is also in the raspberrytips link that were already linked in another comment).This also means that anybody who has physical access to your console during bootup can root the system. If you do not want that, you need to set a harddisk encryption password (and optionally also a BIOS password, but the latter won´t protect e.g. against disassembling the computer and putting the HDD into another Linux box).