36

I want my Ubuntu 16.04 to not start GUI on boot and show command line console only. I have tried the following recipies but none of them are for version 16.04 and so they do not seem to work — GUI starts anyway:

  1. GRUB_CMDLINE_LINUX=”text”

  2. Changing the default runlevel

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

5 Answers5

28

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
25

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.

A.D.
  • 563
12
  • 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

nyxee
  • 321
  • 3
  • 7
10

One of the following, as part of the kernel command line (editable via GRUB), should work:

  • systemd.unit=multi-user.target will override the default of "graphical.target" – this, along with systemctl set-default, is the equivalent of "default runlevel";
  • systemd.mask=lightdm.service will forbid a specific service from starting, until manually systemctl unmask'd later;
  • systemd.mask=display-manager.service – same;
  • rescue aka systemd.unit=rescue.target is the equivalent of "single-user runlevel"; not for daily use, but useful when fixing broken GUI.
grawity
  • 501,077
4

for ubuntu 18.04 enable root user

 sudo passwd

and then

systemctl set-default multi-user.target
Mohannd
  • 207
  • 1
  • 6