Newsletter Subscribe
Enter your email address below and subscribe to our newsletter
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.
Table of Contents
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.
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.
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.
To list unit files, you can use the following command that will generate the output of each unit file:
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
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.
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
As you can see, it is not enabled and is in an inactive state.
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
To check whether the service is actively running, we are required to check its status by the following command:
sudo systemctl status ssh
As you can see it’s active and running as we intended.
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
To check whether we have stopped service successfully, we will have to check its current status by the following command:
sudo systemctl status ssh
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
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
As you can see, it is actively running.
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
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
And it will disable ssh on boot.
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
To restart your system, use the following command:
sudo systemctl reboot
Yes, from December 2019, Debian is shipping their ISO with systemd as its default init system.
Yes, Debian 11 uses systemd as its default init system.
Related Posts:
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.