How can I deactivate the gnome desktop of my ubuntu server?

3

3

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.

19 Lee

Posted 2012-07-02T13:47:42.440

Reputation: 95

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 – 2012-07-03T14:12:15.867

Answers

3

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.

Darth Android

Posted 2012-07-02T13:47:42.440

Reputation: 35 133

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 – 2012-07-02T14:41:52.333

@Izzy Argh, I feel old now :< – Darth Android – 2012-07-02T15:31:09.970

@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 – 2012-07-02T15:37:55.877

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 – 2012-07-02T16:43:52.227

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.

Izzy

Posted 2012-07-02T13:47:42.440

Reputation: 3 187

1

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.

Alexandre Andrade

Posted 2012-07-02T13:47:42.440

Reputation: 11

A piece of explanation would make the answer better. What does the command really do? Why did it help? Are there side effects? – Kamil Maciorowski – 2018-09-12T08:18:39.287

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. – Brice M. Dempsey – 2019-01-22T08:40:15.343

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.

mrucci

Posted 2012-07-02T13:47:42.440

Reputation: 8 398