When your Linux doesn't give you a GUI, I know how it feels. It happened to me, and I felt like screaming my head off, which of course was of no use. Later I found that the file system had somehow got errors on it. I tried a number of things, some of which were helpful.
Listing it all down,
1. I booted into recovery mode, even when the normal mode failed, it took me to the shell prompt, where I was root by default.
2. I tried http://forums.techarena.in/operating-systems/1241547.htm. This didn't do much good.
3. I tried /etc/init.d/gdm restart and /etc/init.d/gdm start. This gave me a message box with the following error message.
Ubuntu is running in low-graphics mode.
The following error was encountered. You may need to update your configuration to solve this. (EE) Failed to load module "i810" (Module does not exist, 0)
But the screen got hanged and again made me turn off my laptop using the power button. So, it didn't help basically, the reason being there was no problem with the GDM, there were errors in the file system.
4. fsck did the magic. I tried a few times, then used Windows to post my query to different mailing lists. A. Mani and Prosun Prodhan of iitd mailing list helped me out.
5. On typing fsck, I somehow had a feeling that it was working to some extent.
mountall: fsck/  terminated with status 4
mountall: Filesystem has errors:/
init: mountall main process (852) terminated with status with status 3
Mount of filesystem failed.
This gave me the following:
/dev/sda6: ***********FILESYSTEM WAS MODIFIED****************
/dev/sda6: ***********REBOOT LINUX***********
/dev/sda6: 228389/1212416 files (0.2% non-contiguous), 110712/4849614 blocks
Then I rebooted.
I tried this a number of times, until I booted with an Ubuntu live CD and did the same, and it finally gave me the default GUI mode.
Thanks to all who helped.
I don't know why this happened, but probably because I had not shut it down properly. I had to turn off my laptop with the power button, because it got hanged on inserting a pendrive infected with virus from the lab.
Note: Repeated use of fsck must be avoided. The first thing to focus on is your filesystem. That shouldn't be harmed.