Linux - Boot or Change System into Different Operating Modes

In this blog, we will see how to boot or change system into different operating modes in Linux.
Watch this video to gain a deeper understanding of Linux's main concepts.
Changing the Default Boot Target
When the operating system boots up, it takes a look at what the default system target is. We can check for ourselves what target is currently set as default with:
systemctl get-default
The name graphical.target suggests that the operating system is configured to boot into a graphical environment. The file graphical.target contains instructions about what needs to happen to arrive at this target. By reading this, the operating system knows what programs it needs to launch, and in what order, to boot into this target.
Booting into a graphical target is pretty demanding. If we don’t need our operating system to load up a graphical user interface, we can change the default boot target.
sudo systemctl set-default multi-user.target
The multi-user.target is something that will make Linux boot normally, with all of its daemons, database server utilities, and whatever we might have configured. But the graphical interface will be skipped. Everything will be text-based. It’s called multi-user because while Linux is booted in this mode multiple users can log in and use the system at the same time. multi-user.target also turns on network services, so the machine will have access to the Internet and local network.
Let’s see what happens now that we’ve changed the default boot target.
We get the text-based login console instead of the previous graphical login screen.
Let’s log in.
Change System into Different Target
Now imagine we want to get back to our graphical desktop. Maybe we need to use a 3D modelling application for 1 hour. Instead of changing the default boot target, then rebooting, we can immediately switch to a different target without rebooting. We can switch back to the graphical.target with:
sudo systemctl isolate graphical.target
This will load up all the graphical applications and we get access to our graphical user interface.
It’s important to note, this does not change our default boot target. If we reboot, we will be dropped at a text-based console, once again, our multi-user.target that we previously set as default.
Other targets that might be useful are emergency.target
and rescue.target
.
emergency.target
will load up as few programs as possible. This can be useful for debugging, in case the programs loaded by the other targets are making your system unstable. If you boot into this target, the root filesystem will be mounted as read-only.
In rescue.target
a few essential services are loaded, and you are dropped to what is called a root shell. Simply put, a few more programs are loaded than in emergency.target, but fewer than are loaded in multi-user.target. In this root shell, you can type commands as the system administrator, create database backups while the database is not online, fix system settings, and so on.
It’s important to note that to be able to use these targets, you must have a password set for the root user. If the root user has no password, you cannot use these targets as you cannot log in as root.
To learn more about Linux checkout our hands-on Linux course here
To get free hands-on experience on System Administration and DevOps tasks please check out our KodeKloud Engineer program here