6

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.

1
  • 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. Jul 3, 2012 at 14:12

4 Answers 4

6

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.

4
  • 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, 2012 at 14:41
  • @Izzy Argh, I feel old now :< Jul 2, 2012 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, 2012 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, 2012 at 16:43
7

I've tried other options with newer version of Ubuntu (Ubuntu 18.04.1 LTS) and they didn't work. What did the trick for me was the following command:

systemctl set-default multi-user.target

Reboot and it will show only the console.

You can revert it running:

systemctl set-default graphical.target

And reboot again.

3
  • A piece of explanation would make the answer better. What does the command really do? Why did it help? Are there side effects? Sep 12, 2018 at 8:18
  • 1
    This command modifies systemd configuration. systemd is the program that controls the startup process of newer versions of Ubuntu. Setting the multi-user target rather than the graphical one prevents a graphical boot. This is a good clean way to achieve the result desired by the questioner. Jan 22, 2019 at 8:40
  • How do you undo this command once you run it? Mar 19, 2020 at 20:06
2

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.

0
  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.

You must log in to answer this question.

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