I have installed Ubuntu Server 11.10 on my machine. Next I used
sudo apt-get install ubuntu-desktop to install GUI.
Is it possible to disable it and re-enable it anytime I want?
If yes, what commands do I use?
running the following command:
will give you a list of all your upstart jobs, if it's not gdm it will be something similar.
Assuming it is in fact gdm the following will show you under what conditions the gnome display manager will automatically start:
At this point you can do one of two things by editing the gdm config file using:
on a line by itself somewhere near the top of the file BEFORE the line that begins with:
This will essentially prevent gdm from ever running by itself, however you can still start XWindows manually by logging in and running: startx
Your other option would be to comment out (add a # before any text on the line :) the line beginning with:
and every subsequent line until (but not including) the line that begins with:
This will prevent gdm from running at startup but will still allow you to start it as a service if for instance you wanted to leave a graphical login screen up instead of a black console. You can check to make sure your changes were correct by running:
once more to make sure all of the start ons are gone. Hopefully this helps, I find half the joy of using Linux to be unraveling it's inner workings till I understand them so I tried to give you as much info as you will need but still leave a few things for you to discover on your own ( man initctl )...
The fastest method would be to log in to 1 of the 6 TTY's using CTRL+ALT+F1 through CTRL+ALT+F6.
To get back to the desktop/GUI, simply press CTRL+ALT+F7.
Should stop the gui... though it might be a different service name these days...
The benefit of this over iglvzx's answer is that the gui stops running, freeing resources, rather than simply hiding it.