Linux is well known for being a rock-stable OS. X, the client-server based frontend usually used to provide GUI functionallity, however, is known for occasionally going south. In the interest of better understanding of how to deal with this frustrating occurance, I present this brief tutorial.

Often times the unlucky X user will find himself faced with an X window that wont go away. It may refuse to refresh or even close. There are generally 2 ways of attempting to deal with this. If one is able to use a shell, one can run a command, such as:
$ps -ax | grep process name
$kill -9 offending pid

An easier way to deal with this is a very handy program called xkill. this can be run from the shell, run from a menu, or in a pinch summoned with Ctrl-Alt-Esc. Just put the pointer over the offending window and click.

Sometimes, problems with X can be much more serious. These are the times when the whole GUI locks up, or becomes so unresponsive that usual methods of logging off, or even rebooting, are unavailable. This doesn't always mean a forced unclean reboot. The protocol for dealing with this is often disabled in some linux distributions(and does require kernel support). To enable it, use your favorite editor(as root, of course) and open /etc/sysctl.conf and insert a line reading:

kernel.sysrq = 1
After doing that, you should be prepared for amost all X-based porkage
Now next time X goes to sit under a tree, try this sequence of keystrokes:

alt-sysrq-r (should unlock your keyboard. In some cases you may be able to stop here.)
at-sysrq-k (kills all current processes on your virtual terminal.)
alt-sysrq-s (syncs your hard drive.)
alt-sysrq-u (unmounts your filesystems.)
alt-sysrq-b (should give you a reboot!)

If all goes well, you should be able to reboot and recover with your filesystems clean.

None of this is new knowledge to many, but I felt it was good to put it here for all y'all linux newbies...

Cheers