Enter your email address below and subscribe to our newsletter

How to Setup and Use Systemd in Debian 11

Share your love

Systemd is an initialization and service management system for Linux. It consists of features like starting of daemons, auto mounting maintenance, support for snapshots, and much more. It is mainly used for accomplishing common administrator tasks.

We are going to discuss what is systemd and various applications of systemd which can be accomplished by the normal user too. As the majority of Linux distribution comes pre-installed with systemd, we no longer require the installation process of systemd in Debian 11.

Before going to the operations of systemd, let’s clarify some basics related to systemd.

What is Systemd? Why it is used?

Systemd is known as one of the foundation elements for Debian Linux. Systemd is a standard tool for accomplishing tasks such as controlling which program to run while booting up Linux.

Systemd is mainly used to start, stop and restart services but it was created to do just more than activate services. It can start a journal of system activity, user logins, a cron-style job scheduler, the network stack, and more.

Various Applications of Systemd

After discussing what is systemd, let’s discuss various applications of systemd. A basic user can also perform these operations and can be helpful if you are looking for making a carrier in Linux. Let’s start with listing unit files.

Listing Unit Files

Systemd uses units to manage system services and processes. Systemd units use configuration files to control their related operations. There are three types of unit configuration files; default unit configuration files, system specific unit configuration files, and run-time unit configuration files.

  1. Default unit configuration files: These are default configuration files which are located at “/usr/lib/systemd/system”
  2. System-specific unit configuration files: These configuration files are system-specific and can be found at “/etc/systemd/system”
  3. Run time unit configuration file: These configuration files contains details about run time and can be found at “/run/systemd/system”

To list unit files, you can use the following command that will generate the output of each unit file:

 systemctl list-unit-files 

1. systemctl list-unit-files

You can manually adjust the command to get your desired output if you want to get an output of only enabled services, we can do it by including grep enabled. It would look like the following command:

 systemctl list-unit-files |grep enabled 2. systemctl list-unit-files |grep enabled

Basic Operations of Services

We can use systemd to check whether the service is active or not, disable it, and even restart the service with a single command. We are going to show you how to perform each of them. Let’s start by showing the current status of the service.

Checking Status of Service

To check the current status of any service you will have to use the following syntax:

 sudo systemctl status {Service Name} 

For demonstration, we are going to use ssh. To check the current status of ssh, use the following command:

 sudo systemctl status ssh 

3. sudo systemctl status ssh

As you can see, it is not enabled and is in an inactive state.

Enabling Service

You can enable services using systemd. To enable services, use the following command syntax:

 sudo systemctl start {Service Name} 

As we are going to enable ssh, our command will be as follows:

 sudo systemctl start ssh 

4. sudo systemctl start ssh

To check whether the service is actively running, we are required to check its status by the following command:

 sudo systemctl status ssh 

5. sudo systemctl status ssh

As you can see it’s active and running as we intended.

Disabling Service

As we have already discussed, you can use systemd for disabling any service which is actively running. To disable any running service, use the following command syntax:

 sudo systemctl stop {Service Name} 

As we want to stop ssh which is actively running, we are required to use the following command to stop it:

 sudo systemctl stop ssh 

6. sudo systemctl stop ssh

To check whether we have stopped service successfully, we will have to check its current status by the following command:

 sudo systemctl status ssh 

7. sudo systemctl status ssh

Restarting Service

Often we face an issue where service does not run as it is intended and rebooting your whole system just for a single service is not a good idea. You can easily restart any service by using the following command syntax:

 sudo systemctl restart {Service Name} 

As we want to restart ssh, we have to use the following command:

 sudo systemctl restart ssh 

8. sudo systemctl restart ssh

After restarting any service, it will be actively running. To check whether we have successfully restarted any particular service, we can check its status and if it is active, we have managed to restart the service successfully.

 sudo systemctl status ssh 

9. sudo systemctl status ssh

As you can see, it is actively running.

Enabling and Disabling Services at Boot

There are several services such as Bluetooth, docker, Wi-Fi, and others that are required to be enabled on startups. We can use systemd for enabling services at boot by using the given command syntax:

 sudo systemctl enable {Service Name} 

As we have wanted to enable ssh on boot, we will have to follow the given command:

 sudo systemctl enable ssh 

10.1 sudo systemctl enable ssh

This will enable ssh on each boot.

If you want to disable any service at boot as if it is taking more resources and making your boot time longer than usual, you can disable it by following the given command structure:

 sudo systemctl disable {Service Name} 

As we want to disable ssh on boot, we are required to follow the given command:

 sudo systemctl disable ssh 

10.2 sudo systemctl disable ssh

And it will disable ssh on boot.

Shutting Down and Restarting System

Yes, you can use systemd for powering off and restarting your device. As a system admin, you may not have Desktop Environment installed all the time and in those situations, this command will surely be helpful.

To shut down your system, use the following command:

 sudo systemctl poweroff 

10. sudo systemctl poweroff

To restart your system, use the following command:

 sudo systemctl reboot 

11. sudo systemctl reboot

Frequently asked questions related to Systemd

Does Debian use systemd?

Yes, from December 2019, Debian is shipping their ISO with systemd as its default init system.

Does Debian 11 use systemd?

Yes, Debian 11 uses systemd as its default init system.

Related Posts:

Conclusion

A system is one of the most helpful utilities and can be used without any complexity. By using this guide, you can easily use systemd on Debian 11 and other Debian-based Linux distributions such as Ubuntu, Linux Mint, Pop_OS, and many others.

Share your love
Sagar Sharma
Sagar Sharma

Sagar always uses Linux to its core and loves to write the technical side of system administration! While he's not writing for GeniusGeeks, you can find him writing for core linux blogs like IT'SFOSS.com and LinuxHandBook.com

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!