You can repair most such problems on the Pi by rebooting to a root shell.
- Append
init=/bin/sh
at the end ofcmdline.txt
and reboot. (This needs to be performed by mounting the SD Card on another computer.) - After booting you will be at the prompt in a root shell.
- Your root file system is mounted as readonly now, so remount it as
read/write
mount -n -o remount,rw /
You can then edit files.
NOTE if you are running NOOBS the appropriate cmdline.txt
WILL NOT be in the first partition, but one of the other FAT partitions (depends on what you installed).