The Linux Page

Boot into the command line console in Ubuntu 16.04 and newer

An Ubuntu 16.04 login prompt just after boot, ready for you to log in.

As I just upgraded my 14.04 installation to 16.04, it booted right up to lightdm.

I had it properly setup to boot in a console before, but somehow it changed the behavior on me.

This is because the computer is now using systemd to boot.

I already had the GRUB variables setup as expected:

GRUB_CMDLINE_LINUX_DEFAULT="text"
GRUB_CMDLINE_LINUX="text"
GRUB_TERMINAL=console

But this is not enough if you want to start in the console when running systemd (which is running since 15.04). See X11 Auto-starting for details about older versions.

systemd has a list of variables you can tweak using the systemctl command. To boot in the console, you have to set that as the default:

sudo systemctl set-default multi-user.target

This prevents the graphical boot and starts using the console instead.

To go back to graphical boot, use the graphical target instead:

sudo systemctl set-default graphical.target

And you will get the usual lightdm (or gmd) prompt instead of a console.

Now you may want to start X11 once in a while. I actually work in X11, but log out nightly so that way memory is not as tight and X11 is reset at least daily (which with my old setup was a good thing). As of 2016, the memory footprint may have been less of a problem, but it still cleans up all sorts of things, especially when upgrades happen. So... to start X11, I was used to run:

startx           # not working well with Ubuntu 16.04 / Unity

Instead of startx, we now want to run X11 with systemd which will make sure that all the necessary parts get loaded as expected. That is, startx will start the X11 screen but not Unity. You can do that manually (or many tweak to a personal script that gets run by startx) with:

setsid unity

However, since 15.10, or maybe even 15.04, Ubuntu uses systemd which is expected to be used to start the X11 environment. This works with the following command:

sudo systemctl start graphical.target

The command will start X11 and Unity as expected. You have to do that instead of startx. Only this won't give you the option of logging out of X11 as you could before with the log out menu. Instead, you have to switch back to multi-users with a similar command:

sudo systemctl isolate multi-user.target

The command switches you back to the standard super fast text consoles.

The switch back will generally take you to TTY 7 or 8 which is likely to be a black screen or have some boot logs, not a login prompt or the console you started from. To fix that problem, you may use the chvt command line option:

sudo chvt 1 && sudo systemctl isolate multi-user.target

Of course, you may just decide not to have to deal with that sort of things anymore and just stay in your X11 console throughout time... You can simply reboot once in a while when the environment decays too much...

Obviously, you should know what the current status is: whether you are in your graphical system or in your consoles. Yet, there is a command to check that out:

systemctl list-units --type target --all

The --all options shows you the inactive targets as well.

Note: My previous version was saying to use start to restart the multi-user.target. That ended up breaking not too long ago so now I have to use isolate, which anyway is most certainly all around better.

Re: Boot into the command line console in Ubuntu 16.04

I keep my linux desktop on another floor of my house. I rarely use it as a desktop. Most of the time, I use it as a home server. Wanted to save some memory while it runs as the server. I had to execute only one command that you mentioned (systemctl set-default multi-user.target). It worked great. My server thanked you for saving some memory!