How to manage Linux services using Systemd

One of the most important skills that any new Systemd user needs to learn is how to manage computer services. This article will teach you the basics: start, stop, enable and disable services from the Linux command line.

What is Systemd?

There are a number of Linux computers running Systemd such as in the Linux, Debian, Fedora, Red Hat and Ubuntu distributions that use Systemd by default. Some distributions will be difficult or impossible to run without installing Systemd.

  1. 10 Linux distributions you may not know yet

Systemd was designed to replace SysV's old init project, which has been used in UNIX distributions since the 1980s. Lennart Poettering's main developer has also stated that Systemd can do more tasks. init and can act as a development platform and link between individual applications, the Linux kernel.

How to manage Linux services using Systemd Picture 1

How to start and stop units

Systemd starts, stops, turns on and turns off "unit". Units include services, mount points, devices and sockets on the computer. In these instructions, you will work with services (.service files), which represent programs on the computer waiting for access for a specific task.

Some Linux distributions have access to Hddtemp, a small utility that checks the temperature of the hard drive. Hddtemp has a .service file and can run as a daemon, so you can start it manually and allow it to activate at startup. This utility is small so you can download and try it with Systemd, you can delete it later if you want.

  1. Instructions for checking the temperature of CPU, VGA, hard drive of computer, laptop

Install Hddtemp on Arch with the following command:

 sudo pacman -S hddtemp 

and on Ubuntu with:

 sudo apt-get install hddtemp 

Now start the new utility with Systemd:

 sudo systemctl start hddtemp.service 

You can then restart, stop and see the status of man-db with the same type of systemctl unit. Notice that the 'unit' works like any 'unit.service' file that you will use.

How to manage Linux services using Systemd Picture 2

sudo systemctl start hddtemp commands, sudo systemctl stop hddtemp , and sudo systemctl restart hddtemp does not create output by default when it runs successfully.

You can get more service information with the following command:

 sudo systemctl status hddtemp 

In this case, this command will provide the name of the service, the status of the service (active or inactive) and start / stop made in minutes. If any of the above commands fails or causes an error, those problems will show up in the status report.

Activate and deactivate units

When starting or stopping a unit, you are completing a manual process that will likely only last for the current session. When restarting, the unit you start may not run automatically.

For units to boot, try turning them on with Hddtemp:

 sudo systemctl enable hddtemp 

The output will show that Systemd has created a symbolic link (symlink) to start Hddtemp automatically when the computer is in the boot process. The next time you can use the shortcut:

 sudo systemctl enable --now unit 

to activate and start a unit in a command.

How to manage Linux services using Systemd Picture 3

You can now disable Hddtemp easily with the following command:

 sudo systemctl disable hddtemp 

If you are unsure whether a unit is enabled, you can run the sudo systemctl is-enabled unit command.

Now you can remove Hddtemp from your computer if you want.

When using Systemd, the above commands will become useful when managing programs on the computer. Check the 'COMMANDS' section of the Systemctl man page with the command man systemctl to see the commands that start, stop, enable, disable, and other commands are more complex than the example above, but you should not worry about the commands. This command is very easy to use.

See more:

  1. How to manage Windows Vista services
  2. Disable unnecessary services in Windows 7
  3. All ways to open Windows Services on Windows 10/8/7
3.6 ★ | 7 Vote

May be interested

  • 8 commands for efficient management of Linux processes8 commands for efficient management of Linux processes
    there are three main states in the life cycle of an application process: start, run, and stop. if you want to be a competent linux administrator, you need to know how to manage each state carefully. the following 8 commands can be used to help you manage the entire process lifecycle.
  • How to manage memory to restrict Linux to use too much RAMHow to manage memory to restrict Linux to use too much RAM
    you install linux with the promise that it will consume less system resources than windows. but why then, is your system still slow?
  • Is Linux, Windows or macOS the operating system for you?Is Linux, Windows or macOS the operating system for you?
    an operating system is simply defined as software that allows you to manage your computer's hardware and resources, and provides a number of common services that allow you to run different programs.
  • How to modify and manage Hosts files on LinuxHow to modify and manage Hosts files on Linux
    if you need to block web pages or create personalized web shortcuts on linux, solve these tasks by adding or adjusting a few lines in the hosts file.
  • How to manage packages on RPM-based Linux distributions with DNFHow to manage packages on RPM-based Linux distributions with DNF
    this tutorial will show you how to install and manage software packages on rpm-based linux distributions like fedora and red hat enterprise linux (rhel) using dnf.
  • How to Install and Use Fonts in LinuxHow to Install and Use Fonts in Linux
    but while font rendering is far from perfect in linux, one thing this open source platform does well is allow users to easily manage their fonts. from selecting, adding, and adjusting, you can work with fonts quite easily in linux.
  • How to find, set and change IP addresses on LinuxHow to find, set and change IP addresses on Linux
    ip address is like a computer phone number. computers use it to communicate with other devices and vice versa. here are some simple ways to manage ip addresses on linux.
  • Linux is everywhereLinux is everywhere
    quietly, but at a very fast pace, linux is penetrating increasingly into consumer services, devices and products, from email to cars. a revolution called linux is quietly embracing consumer technology.
  • Guide to network operation for Linux users: 11 commands to knowGuide to network operation for Linux users: 11 commands to know
    linux supports commands to download files, diagnose network problems, manage network interfaces or view network statistics on the terminal. here are some common linux commands to work with, please consult.
  • How to manage user passwords from Terminal in LinuxHow to manage user passwords from Terminal in Linux
    like many things on linux, passwords are easily managed directly from the command line. the passwd utility is designed to allow you to quickly and easily access all password-related commands on the system. you can use it to change and manage your password and other user passwords on the system