Boot Ubuntu 16.04 into command line / do not start GUI

You could disable the display manager service with systemctl. For example if your display manager is lightdm then run:

sudo systemctl disable lightdm.service

This will prevent the service from starting at boot.

Edit:

I forgot to mention how to start the GUI. It is as simple as starting the systemd service:

sudo systemctl start lightdm.service

Instead of text use runlevel 3:

GRUB_CMDLINE_LINUX="3"

# To remove all the fancy graphics you need to get rid of `splash`.
GRUB_CMDLINE_LINUX_DEFAULT=”quiet”

# Uncomment to disable graphical terminal (grub-pc only) 
GRUB_TERMINAL=console

Then update-grub and reboot.


But you really only need GRUB_CMDLINE_LINUX="3". For quick test hit ESC during booting to get into the grub boot menu. Then press e and find the line which specifies kernel and add 3 at the end:

 linux /vmlinuz root=/dev/mapper/ubuntu ro 3

Boot it with CTRL+x


Ideally I also want to be able to start GUI by typig a command.

One of these:

$ sudo telinit 5
$ sudo service lightdm restart
$ sudo systemctl start lightdm

Tested on Ubuntu 16.04.1 LTS.


  • When in GUI-mode, this will take you to text-mode (runlevel 2,3,4) on reboot. You may get a blank screen (no-gui) which is a reminder that there's no GUI :-), enter ctrlalt(F1,F2,...) to use the runlevels.

systemctl set-default multi-user.target

  • This will take you back to GUI boot when you are in text-mode.

systemctl set-default graphical.target