---
title: "Correct Way of Using Ubuntu systemctl to Control Systemd"
description: "Need a better way to control services in your Ubuntu machine? Learn how to effectively manage services using Ubuntu systemctl commands in this tutorial!"
canonical: "https://adamtheautomator.com/ubuntu-systemctl/"
---

# Correct Way of Using Ubuntu systemctl to Control Systemd

> Need a better way to control services in your Ubuntu machine? Learn how to effectively manage services using Ubuntu systemctl commands in this tutorial!

Source: https://adamtheautomator.com/ubuntu-systemctl/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Correct Way of Using Ubuntu systemctl to Control Systemd](https://adamtheautomator.com/wp-content/uploads/2021/11/Controlling-Systemd-services-with-Ubuntu-systemctl.jpg)

# Correct Way of Using Ubuntu systemctl to Control Systemd

[![](https://secure.gravatar.com/avatar/c14b031fe4a12b0e3f4d1e112e37261df83921ddc370cdafbad2a614e36f0cf4?s=192&d=mm&r=g)Chaitanya](https://adamtheautomator.com/author/chaitanya-g/)18 November 20215 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Command Line](/tag/command-line/)[Linux](/tag/linux/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [What is Ubuntu Systemctl?](#what-is-ubuntu-systemctl)
*   [Listing All Services](#listing-all-services)
*   [Listing Services with Specific State](#listing-services-with-specific-state)
*   [Listing Enabled Services](#listing-enabled-services)
*   [Listing Service Properties](#listing-service-properties)
*   [Managing a Specific Service](#managing-a-specific-service)
*   [Stopping a Service](#stopping-a-service)
*   [Starting a Service](#starting-a-service)
*   [Enabling or Disabling a Service](#enabling-or-disabling-a-service)
*   [Conclusion](#conclusion)

Managing a service or group of services in a modern Linux PC can be a drag, that is, if you’re not sure what you’re doing. Lucky for you, Ubuntu [Systemctl](https://tecadmin.net/tutorial/linux/linux-systemctl-command/) has you covered to manage services on a Linux PC.

In this tutorial, you will learn how to manage [Systemd](https://en.wikipedia.org/wiki/Systemd) services on Ubuntu PC by running different `systemctl` commands.

Ready? Time to dig in!

## Prerequisites

This tutorial will be a hands-on demonstration but doesn’t require special tools, so long as you’re on Ubuntu 16 or higher version, you’re good to go. This tutorial uses Ubuntu 20.04.3 LTS version for the demos.

## What is Ubuntu Systemctl?

Before running Ubuntu systemctl commands, get to know what Systemctl is first. Systemctl is a command-line utility to control and manage [systemd](https://en.wikipedia.org/wiki/Systemd) and system services.

In a nutshell, Systemctl is a control panel or service manager for the systemd [init](https://en.wikipedia.org/wiki/Init) system to initialize components after the Linux kernel is booted. Systemctl is a collection of libraries, daemons, and utilities that you can use to manage services.

To effectively manage services, know the different service states as follow:

*   **Enabled** – indicates a service is configured to start when the system boots.
*   **Disabled** – indicates a service is configured not to start when the system boots.
*   **Active** – indicates a service is currently in running state.
*   **Inactive** – indicates a service is not currently running but may start when some application tries to start that service.

## Listing All Services

Now that you know the different states of services, perhaps you want to see a list of all the services on your Ubuntu PC. Listing all services provides a handful of information that prepares you for managing services.

Open your terminal and run the below command to list all the [service units](https://manpages.ubuntu.com/manpages/focal/man5/systemd.unit.5.html) (`list-units`) (active, running, exited, or failed) with the service set as unit type (`--type=service`).

```bash
systemctl list-units --type=service
```

Pick any of the services from the list you want to manage later in this tutorial and note the **UNIT** name (e.g., **apache2**). Hit the spacebar to scroll down, or hit the “Q” key to exit the command.

By the way, here’s a good guide on [Linux Shell Scripting](https://adamtheautomator.com/linux-shell-scripting-tutorial/).

![Listing All Services (active, running, exited, or failed)](https://adamtheautomator.com/wp-content/uploads/2021/11/image-274.png)

Listing All Services (active, running, exited, or failed)

Related:[Your One and Only Linux Shell Scripting Tutorial](https://adamtheautomator.com/linux-shell-scripting-tutorial/)

## Listing Services with Specific State

Instead of listing all services, perhaps you want to narrow down the list of services. If so, adding the `--state` parameter will do the trick, as it filters out the services with the specific state you specify.

Run either of the commands below to list all active services (`--type=service --state=active`), both running and exited.

```bash
systemctl list-units --type=service --state=active
```

![Listing Services on "active" State](https://adamtheautomator.com/wp-content/uploads/2021/11/image-275.png)

Listing Services on “active” State

Similarly, to list only exited or running services, change the state value from `active` to either `running` or `exited`, as shown in the below commands:

```bash
systemctl --type=service --state=running
systemctl --type=service --state=exited
```

![Listing Services on "running" State](https://adamtheautomator.com/wp-content/uploads/2021/11/image-276.png)

Listing Services on “running” State

![Listing Services on "stopped" State](https://adamtheautomator.com/wp-content/uploads/2021/11/image-277.png)

Listing Services on “stopped” State

## Listing Enabled Services

Apart from listing active, running, and exited services, you can also list enabled and disabled services by pipelining the [`grep`](https://man7.org/linux/man-pages/man1/grep.1.html) command.

Run either of the commands below to list (`list-unit-files`) `disabled` or `enabled` services (`--type=service`).

```bash
## Lists all Enabled services
systemctl list-unit-files --type=service | grep enabled
## Lists all Disabled services
systemctl list-unit-files --type=service | grep disabled
```

Take note of an enabled service, as shown below, as you’ll need it later for disabling a service, but this tutorial uses the **[acpid.service](https://www.thegeekdiary.com/linux-os-service-acpid/)** for demo. The acpid is an extensible daemon that supports the [Advanced Configuration and Power Interface (ACPI)](https://wiki.archlinux.org/title/ACPI_modules) events.

![Listing Enabled Services](https://adamtheautomator.com/wp-content/uploads/2021/11/image-278.png)

Listing Enabled Services

## Listing Service Properties

Aside from listing services, you may want to check a service’s properties. Having insight into service properties is handy for troubleshooting, parameters for the process, or restart behavior.

Run the command below to `show` a service’s (`acpid.service`) properties in a key=value format.

```bash
systemctl show acpid.service
```

![Showing Service Properties](https://adamtheautomator.com/wp-content/uploads/2021/11/image-279.png)

Showing Service Properties

Now, if you’re only looking for a specific service property, you can pass the `-p` flag with the property name.

Run the below command to `show` a service’s (`acpid.service`) `MainPID` property.

```bash
systemctl show acpid.service -p MainPID
```

![Showing Specific Service Property](https://adamtheautomator.com/wp-content/uploads/2021/11/image-280.png)

Showing Specific Service Property

Related:[How to Kill a Process in Linux Using ps, pgrep, pkill and More](https://adamtheautomator.com/linux-kill-process/)

## Managing a Specific Service

Since the basics of listing services are out of the way, it’s time to manage a specific (single) service by running the `systemctl stop` and `start` commands.

Apache service (apache2) is used for the following demos, but you may freely manage the service you noted in the “Listing All Services” section. But before you stop or start a service, you first need to verify the service’s status.

Run the below command on a terminal to view the `apache2` service’s detailed information like its `status`.

```bash
systemctl status apache2
```

Below, you can see that the apache2 service is active and running.

![Viewing apache2 Service Status](https://adamtheautomator.com/wp-content/uploads/2021/11/image-281.png)

Viewing apache2 Service Status

> _Entering the sudo password is not needed for viewing service status as you are not changing the service state. But if you start, stop or restart a service, you have to prepend the sudo command and enter the sudo password._

### Stopping a Service

Perhaps you want to stop a service that was left hanging and still running in the background. In that case, the `systemctl stop` command is what you need. Run the `systemctl` command below to stop the `apache2` service.

```bash
sudo systemctl stop apache2
```

> _If you prefer to stop multiple services simultaneously, specify each service separated by space, like this: `sudo systemctl stop sshd apache2`. In this command, you’ll stop both sshd and apache2 services in one go._

Now run the `systemctl status` command as you did previously to verify if the apache2 service stopped.

```bash
systemctl status apache2
```

You can see below that the status of the apache2 service changed to **inactive (dead)**, which indicates the service stopped.

![Verifying if apache2 Service is Stopped](https://adamtheautomator.com/wp-content/uploads/2021/11/image-282.png)

Verifying if apache2 Service is Stopped

### Starting a Service

Now how do you start a service if you noticed it’s not running at all? You run a command similar to stopping service, which is the `systemctl start` command. Run the below command to `start` the `apache2` service.

```bash
sudo systemctl start apache2
```

> _Like stopping multiple services, you can also start multiple services in a single line of command. Replace the `stop` command with the `start` command like this: `sudo systemctl start sshd apache2`_

Now run the `systemctl status` command one more time to verify if the `apache2` service is running.

```bash
systemctl status apache2
```

If you see the **active (running)** status, as shown below, then you’re all set as the service is back in business.

![Starting apache2 service](https://adamtheautomator.com/wp-content/uploads/2021/11/image-283.png)

Starting apache2 service

> _If you prefer to restart the service right off the bat without having to stop it first. If so, go for the `systemctl restart` command instead, like this: `sudo systemctl restart apache2`_

### Enabling or Disabling a Service

Perhaps there’s a particular service you prefer to either start or prevent to start on system boot. If so, running the `systemctl` `enable` or `disable` command is the best approach.

The `enable` subcommand lets you configure the default startup settings on your system, while the `disable` subcommand prevents a service from running on system boot.

Run the `systemctl` command below to `disable` the service (`acpid.service`) you noted in the “Listing Enabled Services” section. Enter your sudo password to authorize running the command.

```bash
sudo systemctl disable acpid.service
```

![Disabling a Service](https://adamtheautomator.com/wp-content/uploads/2021/11/image-284.png)

Disabling a Service

Now since acpid.service supports [OS-directed configuration and Power Management (OSPM)](https://www.techopedia.com/definition/29207/operating-system-power-management-ospm); you need to re-enable it. The command to enable service is similar to disabling a service.

Execute the `systemctl` command below to `enable` `acpid.service`. This command registers the service back to default startup settings on your system.

```bash
sudo systemctl enable acpid.service
```

![Enabling a Service](https://adamtheautomator.com/wp-content/uploads/2021/11/image-285.png)

Enabling a Service

## Conclusion

In this tutorial, you’ve realized how quickly you can stop, start or restart services by running Ubuntu `systemctl` commands. You’ve also learned that the `systemctl` command lets you manage not just one but multiple services simultaneously.

With this newfound knowledge, why not automate controlling services in your Ubuntu system?

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fubuntu-systemctl%2F&text=Correct%20Way%20of%20Using%20Ubuntu%20systemctl%20to%20Control%20Systemd)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fubuntu-systemctl%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fubuntu-systemctl%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/09/Practical-Linux-Unix-Tee-Commands-for-the-Linux-Admin.jpg)

### [Master Unix tee Commands for Real-World Linux Admin Tasks](/unix-tee/)

Simplify Linux output management and streamline your workflow with the “Unix tee” command. This tutorial guides you through its practical applications.

![](https://adamtheautomator.com/wp-content/uploads/2022/09/Useful-Linux-Dig-Examples-for-the-Network-Admin.jpg)

### [Linux Dig for Network Admins: Practical Guide with Examples](/linux-dig/)

Become a network troubleshooting expert! This comprehensive Linux Dig guide empowers you with essential DNS query commands for immediate results.

![](https://adamtheautomator.com/wp-content/uploads/2021/12/install-phpmyadmin.jpg)

### [Step-by-Step Tutorial to Install phpMyAdmin Securely on Linux](/install-phpmyadmin/)

Discover how to securely install phpMyAdmin on Linux with our concise guide. Learn essential steps for a safe and efficient setup, tailored for Linux users.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
