sudo killall -HUP WindowServer
Warning: All your opened programs will quit immediately! This is like a restart, but of only the graphical part of the system. Quit your open programs first! You have been warned. Here's what happens:
- kill is a program to send signals (terminate or just "signals") to Unix programs -- and in OS X, all programs are Unix programs. killall is the same, but you can use the name of the program instead of its process ID (pid). The dark side is that if you have more than one program with the same name, all programs will receive the kill signal.
- -HUP is a signal that usually says to the process that configuration files are changed and the process must be restarted.
- WindowServer is the program that manages the graphical side of OS X.
[robg adds: A comment on the queue site notes that this may be useful for those times when the GUI locks up, if you're still able to connect via ssh -- try a restart of the window server before forcing a full reboot.]

