What is Systemd in Linux?

  • Post last modified:April 27, 2021
  • Reading time:3 mins read

Systemd is a manager that manages starts, stops, restart services in Linux, and handles how service will start when the system power-up.

Init.d is used before systemd is not in the market. But in recent systemd gain huge popularity and love from the Linux community. Today almost all major Linux distributions ship systemd as the default system component for Linux system.

Features

List of features comes with systemd.

  • Journalctl
  • Logind
  • Systemctl
  • Systemd-resolved

Journatlctl:

It is very popular, and my personal favorite journaling utility comes with systemd. It helps the system admin to track what went wrong while starting services.

$ journalctl -xe

Logind

Logind or Login Daemon is a systemd service that manages user login. It is responsible for tracking the user’s login and sessions if you use systemctl, which is the command utility of logind, which helps to operate logind from the command line.

$ loginctl
SESSION  UID USER    SEAT  TTY   
      2 1000 trendoceans seat0       

Systemctl

Systemctl is one of the most important and powerful utilities of systemd. It helps to control and manage your system services and perform tasks such as start, stop, and restart.

List down all services:

$ systemctl list-unit-files

Above command list down status of all service in your system shown like below.

systemctl list-unit-files
systemctl list-unit-files

Services status:

Get an overview of the specific service status in your system with a simple single line of command.

$ systemctl status sshd

sshd: is a daemon used to control and manage ssh service in your Linux system.

systemctl status sshd
systemctl status sshd

In my case, sshd is currently inactive, so I unable to ssh to my system. We have to start first our sshd service to get into our computer over other networks. So let’s start it.

Start service

To start any service using systemctl, find that service name. I wish to stop the sshd service, and then I use the below command to stop.

Syntax

$ systemctl start [servicename]

Example:

$ systemctl start sshd
systemctl start sshd
systemctl start sshd

If you wish to stop running sshd service, then use the below command to stop.

$ systemctl stop sshd

Autostart service

It often happens when you wish to start service at system bootup, like if you are operating your system using ssh in a different location and you need to reboot your system.

In such a situation, it can be a serious problem, like you have to guide someone on how to start the ssh service so you can able to connect to your system.

The first check is sshd start at system bootup to know that check the status of sshd service and check the below-highlighted area in a red circle.

check service status
check service status

As you have seen above, highlight the red circle. It is disabled, so when the system boot, it cannot autostart sshd service. We need to pass the below command.

$ systemctl enable sshd
$ systemctl status sshd
Enable sshd service
Enable sshd service

As you have seen in a red circle, it is now enabled, which means it will autostart when the system turn on next time.

If it’s already enabled and you need to disable it, then use the below command.

$ sudo systemctl disable sshd

If you have any query then feel to ask in comment section.

Like what you read? Please share it with others.
  • 1
    Share
guest
0 Comments
Inline Feedbacks
View all comments