Say if I wanted to replicate Ubuntu Server and have no GUI running what would I do to make this happen? Upon running htop/top from tty session I see both gnome and xorg are still running and sucking up quite a substantial amount of memory (I'm using VirtualBox and have 1024MB allocated to Ubuntu). I would preferably want the ability to disable/stop gnome and Xorg whenever I wish in order to free resources. I don't see any point in switching to tty from Xorg and keeping the processes running. I would however like to have the ability to re-enable/start the necessary files upon leaving tty. I do not want things to be permanently disabled although having this option would be useful/

Any help? Thanks


You can use systemctl to "isolate" targets, which is to some extend similar to switching runlevels. The targets of interest here are

  • graphical.target

  • multi-user.target

Confusingly, graphical.target is the default target in both Ubuntu desktop and server, but since there is no display manager installed in server it's essentially the same as multi-user.target.

Switch while Ubuntu is running

Switch to "text mode" (you can simply run this in e.g. gnome-terminal):

sudo systemctl isolate multi-user.target

Switch to "graphical mode":

sudo systemctl isolate graphical.target

Set boot target

You can set the default target that is reached after boot (persists across reboot), e.g.:

sudo systemctl set-default multi-user.target

You can also set a target with the kernel parameter systemd.unit, e.g.


The kernel parameter has precedence over the default target.

This can be used to boot to a specific target once by editing the grub boot entry before boot. Or you could add multiple boot entries for different targets.

| improve this answer | |
  • Could you add the information whether this change persists across reboots? – Carsten S May 24 at 9:57
  • 2
    @CarstenS isolate is ephemeral; to make it persistent use set-default – steeldriver May 24 at 13:04
  • This answer seems to work. However when I type in the command for switching to text mode I have to manually switch to a tty session using CTRL+ALT+F*. If I don't I'm just left with a blinking cursor and no text. Is there a way to do this while referring to exactly what session I want? – customcup May 24 at 19:29
  • @customcup which Ubuntu version do you use? In my 18.04 virtualbox VM, I get a login screen on tty1 after isolating multi-user.target. Did you run it in a tty or in a terminal emulator inside gnome? – danzel May 24 at 20:16
  • @danzel 20.04 and I'm doing it through terminal emulator – customcup May 24 at 22:19

You can use systemctl(the systemd system and service manager) to control your display manager. In the case of Ubuntu, this is GDM - Gnome Display Manager, SDDM and LightDM are other common display managers.

To check the status from the command line:

sudo systemctl status gdm

To stop:

sudo systemctl stop gdm

To start:

sudo systemctl start gdm

To disable (prevent loading at system startup):

sudo systemctl disable gdm

To enable (loading at system startup):

sudo systemctl enable gdm
| improve this answer | |

Another way of achieving this is to edit the line beginning with the linux command on your grub entry and add the number 3 at the end to boot in runlevel 3 which won't start x-server at all by default.

It should look something like this :

 linux  /boot/vmlinuz-5.3.0-46-generic root=UUID=SOME_UUID ro quiet splash 3

This has the same result as others have pointed out , but you can change it even before the system boots up.

In the grub menu press the e button on the ubuntu menu entry and after putting 3 at the end of the line , just press Ctrl+x to boot. Note that this won't save this config for you. If you want to save it , you must edit the file /boot/grub/grub.cfg. (And this is the scenario if you cannot get the grub menu at boot screen , because for example grub's timeout was set to zero. )

And another option for you is to install Ubuntu server which doesn't have GUI at all. unless you have a reason to stick with the desktop version. (e.g desktop version has more tools installed by default , like g++ ).

| improve this answer | |
  • One probably should add, that this is about the same as running init 3... while init 5 would still bring up the GUI, because it never had been disabled, as it had been requested. – Martin Zeitler May 24 at 18:01
  • @MartinZeitler Yes you're right. Each of the answers here are just one of the possible solutions.Sometimes there are lots of different ways to do the same task. – Parsa Mousavi May 24 at 20:47
  • It does not disable the GUI, therefore it does not answer the question. – Martin Zeitler May 24 at 20:51
  • 1
    typo: quite should be quiet. – Peter Cordes May 24 at 22:07
  • @PeterCordes Edited.Thanks. – Parsa Mousavi May 25 at 8:11

First of all, you can press Ctrl + Alt + F2, to switch to tty, and login under CUI. After that, you can remove XServer by apt.

| improve this answer | |
  • The question asks about shutting down X temporarily (and re-enabling later), so that doesn't really help. – Norrius May 24 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.