Learn how to boot into Single-User Mode (in that mode just type the word reboot to boot back into OS X). Then learn the command for vi commands or nano commands.
Warning: Don't do command line commands unless you absolutely know what you are doing.
And triple-check the syntax before you hit enter in single user mode. You are in root mode, and a single space in a wrong place can delete everything in the worst case scenario.