Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a home server on my old laptop (atom cpu).

I installed ubuntu 12.04 server edition, but I also installed ubuntu-desktop. So, when I turn it on, ubuntu desktop is shown.

I sometimes use GUI, but I want to turn the ubuntu-desktop (gnome-desktop) off when I don't use it.

I think I can save resources by turning off the GUI. It's necessary since my laptop's performance is not very good and it often becomes very hot.

I guess I can run ubuntu-desktop on my terminal with "startx" command. But, I don't know how to turn the X window off for a moment.

Anybody have an idea?

Thanks in advance.

--- Following is written after I chose the answer.

$ sudo stop lightdm 
lightdm stop/waiting

with this command, I can turn off the x window. But, I can't get tty1 on my laptop.

I put that command from outside with ssh connection.

And, I can turn the x window on outside.

X: user not authorized to run the X server, aborting.
xinit: server error

But, I can get it back with start lightdm command.

$ sudo start lightdm 
lightdm start/running, process 5673

I'm not sure this is good or not.

And I don't know I can save my resources when I stop lightdm.

share|improve this question
    
You can get back to tty1 on the console of the system with Ctrl+Alt+F1. Switch back to the tty7 (where X usually runs) with Ctrl+Alt+F7. – Darth Android Jul 3 '12 at 14:12
up vote 2 down vote accepted

To control the X environment, use sudo service gdm stop and sudo service gdm start once the system has booted up. To make permanent changes, you need to update the runlevel at which ubuntu auto-starts gdm (Gnome Desktop Manager), and set it to not start on boot up. You should be able to run these commands from an SSH shell remotely.

share|improve this answer
    
as SystemV was replaced by upstart a while ago, the concept of runlevels is no longer valid on the last few Ubuntu versions (see also this issue at AskUbuntu.com). – Izzy Jul 2 '12 at 14:41
    
@Izzy Argh, I feel old now :< – Darth Android Jul 2 '12 at 15:31
    
@Darth_Android: Don't worry. Took me a while to get used to as well. To be honest: It took until a few days ago when I was trying to deactivate some unused services myself that I found out :D – Izzy Jul 2 '12 at 15:37
    
For me, I want to do it manually. So, I chose this first answer. Thank you all for other answers, too. In fact, I should do sudo stop lightdm. I can find the way by the keywords from your answers. – 19 Lee Jul 2 '12 at 16:43

I'm currently not at my Ubuntu machine, but am writing "AFAIR":

check the /etc/init directory, where you should find a file named gdm.conf (which is used to handle the gdm service). If that's there (i.e. I remember it correctly), just type the following in a shell:

sudo echo "manual">/etc/init/gdm.override
sudo service gdm stop

Now you've stopped the gdm (Gnome Display Manager) and thus X -- after you told Upstart this service should be handled manually. So it will no longer start automatically; but if you need it, you can simply issue an sudo service gdm start to bring it up again.

share|improve this answer
  1. Disable gdm at boot:

    sudo dpkg-divert --rename --add /etc/init/gdm.conf
    
  2. Authorize users to start X:

    echo "allowed_users=console" | sudo tee -a /etc/X11/Xwrapper.config 
    
  3. Automatically start X after login on tty1:

    In your .profile or .bash_profile, add:

    if [ -z "$DISPLAY" ] && [ $(tty) = /dev/tty1 ]; then 
        startx
    fi
    

    Logging in other tty will not start gdm or X.

See also this question on serverfault.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .