What is Systemctl? An In-Depth Overview

What is Systemctl? An In-Depth Overview

The systemctl command is a utility which is responsible for examining and controlling the systemd system and service manager. It is a collection of system management libraries, utilities and daemons which function as a successor to the System V init daemon. The new systemctl commands have proven quite useful in managing a servers services. It provides detailed information about specific systemd services, and others that have server-wide utilization.

What is Systemctl? 

The systemctl command is a utility which is responsible for examining and controlling the systemd system and service manager. It is a collection of system management libraries, utilities and daemons which function as a successor to the System V init daemon. The new systemctl commands have proven quite useful in managing a servers services. It provides detailed information about specific systemd services, and others that have server-wide utilization.

Keep in mind that most of the systemctl commands will not provide any output if they have been successful. However, if the systemctl command has failed to complete the task, you will get an error message stating that it failed.

systemctl2.073020credit

Managing Services

What is a Service? 

In the systemd utility, a service is referred to as a unit. A unit is any resource that the system knows how to act on and administrate. A unit is the principal object that the systemd tools know how to address. These assets are defined in a configuration file called a unit file.

Check Service Status

Using systemctl, we can check the status of any systemd service on the managed dedicated server. The status command provides information about a service. It also lists the running state, or detail on why it is not running, or if a service has been stopped unintentionally. If we are connected to the server as a non-root user, we will have to run the systemctl commands using.

systemctl status servicename.service

This unit can be called without the .service extension. Since systemctl will look for those files with .service suffix, the command can also be used like this.

systemctl start servicename

Example of status output:

[[email protected] ~]## systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-05-08 14:15:54 EDT; 1 weeks 2 days ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 3767 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
 Main PID: 1321 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─1321 /usr/sbin/httpd -DFOREGROUND
           ├─3769 /usr/sbin/httpd -DFOREGROUND

Starting or Stopping a Service

The systemctl utility can also be used to start or stop systemd services using a service unit file, with or without that .service suffix.

systemctl start servicename.service

The same rules apply when we want to stop a specific service.

systemctl stop servicename.service

Keep in mind that the start order can only be used on systemd services that are not currently running, and the stop command used only with running services.

Restarting or Reloading a Service

A running service can be restarted using the restart command to avoid stopping and starting it manually using the following command.

systemctl restart servicename.service

Occasionally, we do not need to restart a service to apply configuration changes, if any were you made. Instead, we can use the reload command to restart the service which implements any changes to the running service.

systemctl reload servicename.serivce

If we are not sure about which of the two commands we should use, there is an additional option using the reload-or-restart command which will automatically determine it for us.

systemctl reload-or-restart servicename.service

.service cli commands systemctl

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Create a Command Line (CLI) Tool in Node.js

In this video I will show you how to turn a Node.js application into a command line tool application 🔴 Subscribe for more https://www.youtube.com/channel/UCM...

Create, Build, Deploy and Configure an Azure App Service with Azure DevOps and Azure CLI

This post shows how to create, build, deploy and configure an Azure App Service using Azure DevOps, Azure CLI and Powershell.

Outsourcing Services | IT, KPO, BPO Services | DK Business Patron

DK Business Patron offers complete end to end Outsourcing Services & Solutions which includes Outsourcing BPO Services, KPO Services, Staffing Services, Website Designing, Web Development & Digital Marketing Services across the globe.

Guide On How The Professional French Translation Services Work In India

We provide all Foreign languages like European, Spanish, French, German, Japanese, Korean, Mandarin translation and interpretation services in India.

Useful command of Angular CLI

I made a small list of commands which use a lot in Angular CLI and I want to share my list with you.