The Wayback Machine - https://web.archive.org/web/20241005204439/https://www.geeksforgeeks.org/boot-process-with-systemd-in-linux/
Open In App

Boot Process with Systemd in Linux

Last Updated : 13 Feb, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Systemd is a Linux system and service manager that is responsible for controlling the boot process of a Linux system. The systemd boot process consists of several stages, each of which performs a specific task that is necessary for the successful initialization of the system.

Understanding Systemd : 

One of the key features of systemd is their ability to start and stop services in parallel, rather than sequentially as with the traditional init system. This allows the system to boot up faster and be more responsive. Systemd also offers on-demand activation of daemons, so that services are only started when they are needed, which can save system resources.

Another important feature of systemd is its support for system snapshots and restores. This allows the system administrator to save the current state of the system and restore it later if necessary. This can be useful for troubleshooting or for quickly restoring the system to a known state.

In more simple language, Systemd is a system and service manager for Linux operating systems. It provides a standard way for managing and controlling system processes and is widely used as the default init system for many Linux distributions. It offers features such as parallel startup of system services, on-demand activation of daemons, and support for system state snapshots and restores. Systemd also provides a standard interface for other programs to manage system processes, making it easier to develop and maintain system services.

Boot process with Systemd : 

Background process

When a Linux system is booted, the boot process is managed by systemd. The first step in the boot process is to load the Linux kernel, which is the core of the operating system. Once the kernel is loaded, it initializes the hardware and then starts the systemd process, which is the first process that runs on the system.

From there, systemd takes over and begins starting the other system services that are needed to bring the system up and running. This includes things like the networking service, the login manager, and any other services that are required for the system to function. Systemd starts these services in parallel, rather than sequentially as with the traditional init system, which allows the system to boot up faster and be more responsive.

Once all of the necessary services have been started, the system is ready to use and the login manager is displayed, allowing the user to log in and begin using the system. Systemd continues to run in the background, managing and controlling the system services as needed. This allows the system to remain stable and responsive even when system services are being started, stopped, or modified.

Consider a scenario in Booting Linux, handling processes behind :

When a Linux system is first booted, systemd is responsible for starting the system services that are needed to bring the system up and running. This includes things like the networking service, the login manager, and any other services that are required for the system to function.

If a system service stops working, the system administrator can use systemd to restart the service or to look at the service’s logs to diagnose the problem. Systemd provides a number of tools for managing and monitoring system services, making it easy to keep the system running smoothly.

If a system administrator wants to make changes to the system, such as adding or removing services, they can use systemd to do this. For example, they can use systemd to enable or disable a service, or to change the settings for a service.

If a system administrator wants to take a snapshot of the system’s current state, they can use systemd to do this. This can be useful for creating a backup of the system, or for quickly restoring the system to a known state if something goes wrong.

Analyzing System Boot Performance : 

To analyze the performance of the system boot process using systemd, you can use the systemd-analyze command. This command provides a number of options for analyzing different aspects of the boot process, such as the time it takes for the system to boot, the services that are started during the boot process, and any performance bottlenecks that may be occurring.

Few examples are here, like how you can use the systemd-analyze command to analyze the performance of the system boot process:

  1.  To view the overall time it takes for the system to boot, you can use the systemd-analyze time command. This will print the total time taken for the system to boot, as well as the time taken by each service to start.
  2. To view a summary of the boot process, including the services that are started and the time taken for each service to start, you can use the systemd-analyze critical-chain command. This will print a tree-like structure showing the dependencies between services, and the time taken for each service to start.
  3.  To view a list of services that are started during the boot process, you can use the systemd-analyze blame command. This will print a list of services, sorted by the time taken for each service to start. This can be useful for identifying services that are taking a long time to start, which may be causing a performance bottleneck.

Here are the practical examples of how to do an analysis : 

1. To view the overall time it takes for the system to boot, you can use the following command :

systemd-analyze time

Here is the demonstration of the `time` command : 

 

2. To view a summary of the boot process, including the services that are started and the time it takes for each service to start, you can use the following command :

systemd-analyze critical-chain

Here is the demonstration of `critical-chain`command :

processes chain summary

3. To view a list of services that are started during the boot process, sorted by the time taken for each service to start, you can use the following command :

systemd-analyze blame

Here is the demonstration of `blame` command :

list of services

list of services

4. To view a graphical representation of the boot process, showing the dependencies between services and the time taken for each service to start, you can use the following command :

systemd-analyze plot > boot.svg

Here is the demonstration of `plot > boot.svg` command :

plot > boot.svg”><figcaption>plot > boot.svg</figcaption></figure>
<p>This will create a file called boot.svg containing a graphical representation of the boot process as : </p>
<div style=boot.svg image , plotted with time vs process

boot.svg image, plotted with time vs process

Controversies surrounding Systemd :

Systemd has been the subject of some controversy since it was first introduced as the default init system for many Linux distributions.

This tabular representation will describe the controversies :

                                

                               Controversy                                                                                                                                                                       

Description

Complexity and monolithicism Some critics argue that systemd is too complex and monolithic, with too many features and dependencies. This makes it difficult to understand and maintain and undermines the Unix philosophy of small, modular tools.
Tight integration with other parts of the system The tight integration between systemd and other parts of the Linux system, such as the kernel and system libraries, has led to concerns about interoperability and the ability to use alternative init systems.
Replacing traditional Unix tools  Some critics argue that systemd is unnecessarily replacing traditional Unix tools and utilities, such as init, syslog, and inetd, with its own implementations. This undermines the Unix philosophy and may lead to less tested and understood software.
Development process  There have been concerns about the development process for systemd, with some arguing that it is not sufficiently open and transparent. Decisions are made by a small group of developers without sufficient input from the wider community.


Previous Article
Next Article

Similar Reads

Finding System Boot-up Performance Statistics in Linux Using systemd-analyze Command
If your Linux system is taking so much time to boot, and you want to know which process is taking so much time to boot then you are on the right page. We are going to see how to get a complete overview of system boot-up time and which service is taking more time to initialize. We are going to use the systemd-analyze command and subcommands of syste
2 min read
Linux - Systemd and its Components
Systemd is a system that is designed specifically for the Linux kernel. It replaces the sysvinit process to become the first process with PID = 1, which gets executed in user space during the Linux start-up process. Why systemd? It is one of the first questions that came up to mind when discussing systemd. To find the answer, we have to first know
3 min read
Systemd vs Init Cheatsheet for Linux
Systemd is the new init framework, beginning with Fedora and presently embraced in numerous circulations like RedHat, Suse, and Centos. All things considered, the vast majority of us have been utilizing conventional SysV init scripts typically living in/and so on/rc.d/init.d/. These contents conjure a daemon parallel which will then, at that point,
3 min read
How to Control Systemd Services on Remote Linux Server
Linux, SysV, and LSB init scripts are compatible with Systemd, a system and service manager. Aggressive parallelization capabilities are offered by Systemd, which also offers on-demand daemon starting and uses Linux cgroups to keep track of processes. Systemd also supports system snapshotting and restore, maintains mount and automount points, and i
2 min read
How to mask a systemd unit in Linux?
Systemd is a system and service manager for Linux operating systems, providing a range of functionalities for managing system processes. In some cases, you may want to hide or disable a systemd unit to prevent it from starting automatically. This process is known as "masking" a systemd unit. In this article, we'll explore the steps to mask a system
6 min read
How to Read and Edit Systemd Logs using Journalctl in linux
In the realm of Linux system administration, managing logs is an indispensable task. System logs are crucial for understanding the health, performance, and troubleshooting of a system. Systemd, the init system widely adopted by modern Linux distributions, introduced a centralized logging system called the Journal. `journalctl` is the primary tool p
6 min read
How To Use Journalctl to View and Manipulate Systemd Logs
Journalctl is a powerful command-line utility in Linux for querying and displaying logs managed by systemd-journald. It lets users access detailed information about system events, services, and processes. With journalctl, you can filter logs based on various criteria such as time range, specific units, or log levels, enabling effective troubleshoot
4 min read
Systemd Services: Monitoring Files and Directories
It is very important to keep our services running smoothly in Linux system administration and management. Systemd is a versatile tool used in Linux that helps us manage our services and automate our tasks. It can also act as a watch guard to monitor files and directories using "path units". In this article, we will learn how to use Systemd to monit
5 min read
Service Boot Persistence in Linux
In many cases you need to work with service boot persistence in Linux, which means all those services like ssh, HTTP is started automatically when you boot the system. The best example of the need for this service is when you are installing a remote Linux server which will be accessed using ssh. When you boot the system these services are automatic
1 min read
Dual Boot Kali Linux with Windows
Sometimes we came across situations like when we want to start learning Linux and command line stuff but using Linux as a main Operating System without having a basic idea of it is not a good option. So in order to do that we may install the same alongside windows. And choose which Operating System we want to work on at which time. Before proceedin
4 min read
How to Boot Linux ISO Image Directly from Hard Drive
To Boot Linux ISO Image Directly from Hard Drive, you must have a Linux operating system installed on your hard drive and your computer must be using a GRUB2 bootloader. The GRUB2 bootloader is a standard bootloader on most Linux systems. Note: The downloaded ISO file of Linux must be a live CD release of each Linux ISO image. How to Get ISO files
4 min read
How to Dual Boot Windows 10 and Linux Mint?
Dual booting is the process of installing two operating systems on a single machine. In reality, such a system allows for the installation of various operating systems. However, how does the computer know which operating system to boot? The boot area can be occupied by a boot loader that comprehends various file systems and numerous operating syste
4 min read
How to Change Boot Options on Linux
Users are presented with boot options in the boot menu during the computer startup process. This menu displays all the available bootable partitions on the computer. Users must decide within a specified time frame which operating system (OS) they want to boot into. If no option is selected within this time, the default boot option takes precedence,
5 min read
Process Control Commands in Unix/Linux
Process control commands in Unix are: bg - put suspended process into background fg - bring process into foreground jobs - list processes bg Command : bg is a process control command that resumes suspended process while keeping them running in the background. User can run a job in the background by adding a "&" symbol at the end of the command.
3 min read
Priority of process in Linux | nice value
The running instance of program is process, and each process needs space in RAM and CPU time to be executed, each process has its priority in which it is executed. Now observe the below image and see column NI top Output: The column NI represents nice value of a process. It's value ranges from -20 to 20(on most unix like operating systems). -20 20
2 min read
Process Management in Linux
A process means program in execution. It generally takes an input, processes it and gives us the appropriate output. Check Introduction to Process Management for more details about a process. There are basically 2 types of processes. Foreground processes: Such kind of processes are also known as interactive processes. These are the processes which
3 min read
Getting System and Process Information Using C Programming and Shell in Linux
Whenever you start a new process in Linux it creates a file in /proc/ folder with the same name as that of the process id of the process. In that folder, there is a file named "status" which has all the details of the process. We can get those Process Information Through shell as follows: cat /proc/1/status As can be seen, it displays most of the i
2 min read
Installing atop Tool To Monitor the System Process in Linux
atop is an ASCII full-screen interactive performance monitor which is kind of similar to the top command to view the load over a Linux system. The job of the most critical hardware resources (from a performance point of view) at the system level, i.e. CPU, memory, disk, and network can be seen. atop enable us to identify which processes are actuall
7 min read
How to Install and Use Scout_Realtime to Monitor Server and Process Metrics in Linux?
There are numerous free tools on Linux that are used to monitor the Linux system including hardware and software. We all may have already come across some command-line Linux performance monitoring tools such as top, htop, atop, etc. Alike that we come across another tool called Scout Realtime tool which is used for server monitoring, that you can s
2 min read
limits.conf File To Limit Users, Process In Linux With Examples
Linux gives full control over the system. In this article, we are going to learn about the file limits.conf. limits.conf is a configuration that is used to limit the resources to the user, groups. Now let's understand the file structure of limits.conf and how can we use the limits.conf to limit resources to the user. Before moving further, note tha
6 min read
Easy way to kill process using Fkill in Linux
fkill-cli is a command-line-based tool to kill processes interactively. Fkill is developed using Nodejs. It can run on different operating systems like macOS, Linux, and Windows. To kill the process using fkill we just have to mention the process name or the process PID. Fkill can also be used to kill port. Installation of fkill on Different OS. No
3 min read
GRecon - Automates the process of Google Dorking on Linux
Google Dorking is the process of searching the publicly available information on the internet in a more innovative way. The advanced query is fired to get the exact results of our doubt. As Google has the collection of massive data, sometimes we didn't get the results we want, So in this case, we can use this Google Dorking process. GRecon tool is
3 min read
Get Process ID of Linux Foreground and Background Processes
The PID (process identification number) is a serial number (starting from 1) given by the operating system to uniquely identify the process. Every process started either by the operating system or by the user gets a PID in order of their invocation by the kernel. If we start the same process several times, it will be assigned different PID numbers
4 min read
How to Audit Linux Process Using ‘autrace’ on CentOS/RHEL
Autrace is a command line tool that is used for the purpose of auditing processes on Linux. The audit rules which are created by autrace are stored in the /var/www/audit/audit.log file. Before autrace can work perfectly all the previous audit logs must be deleted. The syntax of autrace is given below: Syntax: autrace -r program program-args Note: H
3 min read
Batch Script - Process in Linux
A Batch Script is basically a script having commands which execute sequentially. It helps users to perform repetitive tasks without human or user intervention or input. To automate some tasks like loading processes, and killing processes. Now in this article, we will write a batch script to view all the processes that are running, once getting all
2 min read
How to Prevent a Background Process From Being Stopped after Closing SSH client in Linux
What is Background Process? A Background Process is an ongoing process running independently, and that is not visible to the users as it runs without any user interaction after the terminal has been closed. Some of the well-known examples of Background processes are the web servers like Nginx and Apache. The Nginx discovers the file and sends it to
4 min read
How to Kill a Process in Linux | Kill Command
kill command in Linux (located in /bin/kill), is a built-in command which is used to terminate processes manually. kill command sends a signal to a process that terminates the process. If the user doesn't specify any signal that is to be sent along with the kill command, then a default TERM signal is sent that terminates the process. Basic Syntax o
6 min read
Exit status of a child process in Linux
It is known that fork() system call is used to create a new process which becomes child of the caller process. Upon exit, the child leaves an exit status that should be returned to the parent. So, when the child finishes it becomes a zombie.Whenever the child exits or stops, the parent is sent a SIGCHLD signal. The parent can use the system call wa
3 min read
Linux Process Management Command Cheat Sheet
On Linux computers there are special commands to control the programs that are running. These commands are called process management commands. With the help of process management commands you can look at the list of the programs that are currently running on your computer. You can also start new programs and run them and stop programs that are alre
6 min read
Difference Between Arch Linux and Kali Linux
Arch Linux is an open-source Linux-based Operating System that is freely available for use. It belongs to the Pacman-based Linux family. It is a light weighted OS for daily use and could even be used by professionals. It was first released in March 2002. It is a beginner-friendly Linux Operating System. Features of Arch Linux: Minimalist approach:
4 min read