Well, if you're still ready to reformat and reinstall, then you've got the problem solved by being able to once again boot from the CD.
It sounds like the login screen and/or window manager is failing, and that's why you're being prompted with a UNIX-style prompt instead of the GUI of OS X.
I would venture to say that being able to restore your system to its original configuration (i.e., windows, login window, GUI, etc.) is probably gone, although some may disagree with me -- if you're not familiar with UNIX, then there's not much you can do with the UNIX prompt. I'm assuming you come from a Windows/DOS background, since you're trying to do a "dir" command at the UNIX prompt, which won't work. That's Microsoft DOS style, and the UNIX equivalent of "dir" is "ls". You can type "ls" and get a listing of files and folders there, but DOS commands aren't going to get you very far.
If you want to reformat and reinstall, boot from the OS X installer CD (by holding 'c' like before), and when the installer pops up, go up to the menubar at the top of the screen and look for "Disk Utility" in one of the menus. Select that, and you can use this utility to reformat (it's called "initialize" for Mac computers) your hard drive. After that's done, you can launch the installer again (by either booting again from the CD or, it may bring you back to the installer when you quit "Disk Utility") and you can reinstall the system from there.
If you don't wanna reformat and reinstall at this point, then perhaps someone else here can help you with the UNIX prompt you're seeing -- I know quite a few commands, but in my personal opinion, if my machine was to the point where nothing would load and I couldn't get back to the login window, I would just reformat and reinstall... I've got all my application CDs handy so reinstalling the programs and what-not wouldn't be that much of a task.
Good luck, and I hope this helps!