How to Boot or Change System Mode in Linux?

Linux is an open-source operating system that’s highly versatile and customizable. It is often used in server environments due to its reliability and security features. It is particularly popular among developers and IT professionals, who appreciate its flexibility, stability, and versatility.

In this blog, we will see how to boot or change the system into different operating modes in Linux.

Linux Boot Process

A Linux boot process is initiated when the computer is turned on, and it goes through several stages before the user can interact with the system's interface. The process typically starts with the BIOS (Basic Input/Output System) performing a Power-On Self-Test (POST) to check for hardware errors. After that, the boot loader is loaded into memory, which is responsible for loading the operating system kernel.

Once the kernel is loaded, it initializes the system and loads the necessary drivers and modules. The kernel then starts the system's init process, which is responsible for starting the system's services and processes based on the target system configuration. The target system defines the desired behavior of the system during the boot process, and it can be customized as per the user's requirement.

Watch this video to understand Linux's main concepts.

What is System Target?

System target in Linux refers to the specific state or mode in which the operating system is configured. It is responsible for managing various services, processes, and applications that are required for a particular purpose or task.

The target system helps the user define the desired behavior during the boot process and provides a convenient way to manage the system's functionality. It can be changed or modified per the user's requirement and accessed through various tools and commands provided by the Linux operating system.

List of the Commonly Used System Targets

Below are some of the most common system targets:

Linux system target modes

It’s important to note that you must have a password set for the root user to use these targets. If the root user has no password, you cannot use these targets as you cannot log in as root.

We can check the default target by running the following command:

systemctl get-default

Changing the Default Boot Target

To change the default boot target in Linux, you will need to open the grub configuration file. First, open the terminal by pressing Ctrl + Alt + T. Next, type in sudo nano /etc/default/grub and press enter. This will open the grub configuration file in the nano text editor.

Once the file is open, locate the line that reads GRUB_DEFAULT=0. This line specifies the default boot target. Change the number to match the target you want to set as the default. For example, if you want to set the fourth target as the default, change the line to read GRUB_DEFAULT=3.

After making the change, save the file by pressing Ctrl + X, then Y, then Enter. Finally, update the grub configuration by running the command sudo update-grub. Now, the next time you boot your Linux system, it will automatically boot into your desired target.


Let's see another way of changing the boot target.

Assume the system has a default boot system set as graphical.target. Booting into this target is pretty demanding. We can change the default boot target if we don’t need our operating system to load up a graphical user interface. We do that by running the command below:

sudo systemctl set-default multi-user.target

The multi-user.target makes 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 simultaneously. multi-user.target also turns on network services, so the machine can access the Internet and local network.

Change a System into a Different Target Without Rebooting

Now imagine we want to get back to our graphical desktop. Maybe we need to use a 3D modeling application for 1 hour. Instead of changing the default boot target, then rebooting, we can switch to a different target without rebooting. For instance, we can switch back to the graphical.target with:

sudo systemctl isolate graphical.target

This will load up all the graphical applications, and we will get access to our graphical user interface.

This does not change our default boot target. If we reboot, we will be dropped at a text-based console, our multi-user.target that we previously set as default.

Other commonly used targets are emergency.target and rescue.target.

emergency.target Loads up as few programs as possible. This can be useful for debugging in situations where 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.

rescue.target In this mode, a few essential services are loaded, and you are dropped to 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, etc.

Why our Linux Basics course stands out!

Each lecture in our Linux course is followed by hands-on labs, where you will be given challenges to solve. The labs open up right in your browser, so there is no hassle of setting up environments to practice. You start practicing seconds after the lecture is complete.

The most important thing while learning Linux, especially the Linux command line, is practice. The hundreds of questions in our labs throughout this course will give you enough hands-on practice to be confident in Linux.

ENROLL NOW

Learning Linux Basics Course & Labs | KodeKloud

Conclusion

In this article, you've learned how Linux systems boot up and the different target modes. This is important if you plan to work with Linux to build or test systems.


More on Linux: