How do I debug when the system freezes or when it crashes back to login?

Solution 1:

Do not login using the login GUI after such a crash. Switch to a text-based login by pressing Ctrl + Alt + F1. Login with your username and password. Errors during a X session are appended to ~/.xsession-errors, but this file is overwritten every login. Make a backup of this file by executing:

mv ~/.xsession-errors{,.1}

This will rename the .xsession-errors file to .xsession_errors.1. Replace the .1 if you want a different suffix. You can now logout from this shell by executing exit.

Check the system logfiles in /var/log. The most interesting files are:

/var/log/kern.log
/var/log/Xorg.0.log (for the current session)
/var/log/Xorg.0.log.old (for previous session)
/var/log/?dm.log (gdm for gnome, kdm for KDE)

Solution 2:

All you have to do is to look at the log directory (/var/log/). You can find any crash or regular logs in there.

Some applications can create crash logs in their own directories. For example, ~/.banshee in your home directory.