How to Use systemd on Debian 12

The systemd is the System manager in Debian and Debian-based Linux distributions. The systemd has been the default system manager in the Debian distribution since the release of Debian 8.

The startup time is reduced because of the parallel initialization introduced by it. It is used to manage the dependencies of the services as well as monitor the services. It also supports snapshotting and restoring on Debian, moreover, it runs as a daemon with the PID 1. 

This post will demonstrate the installation of the systemd on Debian 12 and also explain its basic usage. The blog will follow the outline:

  1. What are the Core Components of systemd on Debian
  2. What are the Units in systemd on Debian 12
  3. What is the Method Install systemd on Debian 12
  4. How to Set systemd as the Default init on Debian 12
  5. What is the Basic Usage of the systemd on Debian 12

Let’s start the post by understanding the core components of systemd on Debian. 

What are the Core Components of systemd on Debian?

The core components of systemd on Debian 12 are explained in the below-mentioned table.

ComponentExplanation
systemd-initThis component is used to initialize the services at the boot time from the configuration files instead of the shell scripts
systemd-networkdThis component is responsible for managing the network management
systemd-udevdThis component manages the events of the devices connected to the computer
systemd-resolvedIt is linked with the DNS and provides the naming of the network resolutions to the local networks
systemd-journaldIt stores the activity history of the system in the form of the log sheet

After going through the basic components of the systemd on Debian 12, let’s understand the units in Debian 12.

What are the Units in systemd on Debian 12?

The tasks are organized by the systemd known as the units. Four major units of systemd are defined in the table below. 

UnitsExplanation
Service UnitsThis manages the services on Debian for example to start the Apache web server
Socket UnitsIt also manages the sockets which are used for the communication between different system components of Debian
Target UnitsThe group of services is known as the target units for example, graphical.target is used to manage the graphical user interface for starting the workstation
Device UnitsIt is responsible for the management of the device settings and configurations

After understanding the basics of the systemd, proceed towards the installation of the systemd on Debian 12.

What is the Method Install systemd on Debian 12?

The systemd comes pre-installed on Debian 12 and its installation can be verified by running the command:

$ systemd --version

If the version is not displayed on the screen, then install the systemd with the “install” option of the apt command:

$ sudo apt install systemd -y

The systemd has been successfully installed on Debian 12. 

How to Set systemd as the Default init on Debian 12?

To set the systemd as the default init on Debian 12, use the mentioned below command:

$ sudo systemctl set-default multi-user.target

Now reboot the Debian 12 to apply the new changes:

$ sudo reboot

What is the Basic Usage of the systemd on Debian 12?

The systemd is used to manage the services on Debian 12. For better understanding, the Apache web server will be managed by different commands of systemd in the next examples.

Example 1: Start a Service Using the systemd

To start the service using the systemd, use the “start” option with the systemctl command:

$ sudo systemctl start apache2

Apache2 has been started on Debian 12.

Example 2: Stop a Service Using the systemd

Similarly, a running service can be stopped by using the “stop” option:

$ sudo systemctl stop apache2

Apache2 has been stopped on Debian 12. 

Example 3: Restart a Service Using the systemd

If after some changes in the configuration of the service, it can be restarted with the command:

$ sudo systemctl restart apache2

Apache2 has been restarted on Debian 12.

Example 4: Check the Status of a Service Using the systemd

To display the status of the service, run the systemd command with its “status” option:

$ sudo systemctl status apache2

The “running” output shows that the service is active and running on Debian 12.

Example 5: Enable a Service Using the systemd

To enable the service so that it can be started automatically at the time of boot, use the “enable” option:

$ sudo systemctl enable apache2

Apache2 will be started at the time of the boot of Debian 12.

Example 6: Disable a Service Using the systemd

To disable the service from starting at the boot time, run the command:

$ sudo systemctl disable apache2

The service has successfully disabled Debian 12. 

Example 7: List all Services Using the systemd

To list down all the running services using the systemd, run the command:

$ sudo systemctl

All the running services are displayed on the screen. 

Example 8: Show System Status Using the systemd

To display the status of the status using the systemd, execute the below-mentioned command:

$ sudo systemctl status

Example 9: List Down Failed Units Using the systemd

Now to display the failed units with the systemd by running the command:

$ sudo systemctl --failed

Example 10: List Installed Unit Files Using the systemd

To list down the installed unit files with the systemd, run the command:

$ sudo systemctl list-unit-files

This is all about the usage of the systemd on Debian 12.

Conclusion

The systemd is the service manager on Linux distributions and is used to manage the services on Debian 12. Different examples of usage of systemd have been explained in this blog. Users can also set the systemd to start at the bootup of Debian 12. 

This blog explained the systemd on Debian 12 with its core components and units. Also, the usage of systemd has been explained with different commands on Debian 12.