You can switch back and forth between KDE and GNOME by doing the following on the command line:
Will change your default window manager from KDE to Gnome.
Will change your default window manager from Gnome to KDE
The choices are 'gnome', 'kde', and 'xdm'.
Once you choose one, then you can fire up X with:
If you're already running in say, Gnome, then you can also just do the following:
You can also simply edit /etc/sysconfig/desktop directly:
# vi /etc/sysconfig/desktop
and make changes to reflect the following changes if you desire KDE, for example:
You'll need to do that as root, as indicated above, of course
For other distros, you may edit ~/.xinitrc directly.
bigrigdriver already pointed out how to change from runlevel 3 to runlevel 5 on boot by editing your inittab. In Redhat based distros like CentOS, runlevel 3 is text console based while runlevel 5 launches X and your default display manager upon system boot - this is only neccessarily so for Redhat based distros (runlevel definitions are different in various Unices).
Personally, I don't want all that extra overhead unless I specifically have a reason to be running in a GUI so I like runlevel 3 as my default on boot and then I simply manually run 'startx'. An added advantage of this approach is that when I log off, I go back to a text console based login prompt and gain back all that memory that was being used by the GUI.
Running the 'switchdesk' app allows you to choose your default, but it only works on Redhat based OSes like CentOS, Fedora, and I believe it is included in Unbreakable Linux too.
For example, if you were running in say, Slackware, the tool to use for choosing your default desktop is 'xwmconfig'
This works as root, or as a non-priviliged user. If you run it as root then all new user accounts you create will default to what you have chosen. If you run it as a non-priviliged user then it will change the default window manager for that particular user.
One final note when editing system files directly:
- Consider making a backup of your files prior to editing.
- Make one change at a time and then test, if you broke it, then you know exactly what it was and how to put it back.
- Have real beer afterward - only virtual beers should be consumed when fiddling about as the superuser!
I hope that helps