A Practical Guide to Managing systemd Services on Linux

Mastering systemctl : A Practical Guide to Managing systemd Services on Linux

If you’ve spent any time working with modern Linux systems, you’ve likely come across the systemctl command. It’s a powerful tool that’s part of systemd, the system and service manager used by most major Linux distributions today—including Ubuntu, CentOS, Debian, Fedora, and more.

In this post, we’ll break down what systemctl does, how it’s used to manage system services and states, and why it’s a command every Linux user—beginner or advanced—should get comfortable with. Plus, we’ll explore plenty of practical examples to help you hit the ground running.

What is systemctl?

systemctl is the command-line interface used to interact with systemd. Think of systemd as the central nervous system of your Linux OS. It handles system startup, manages services, keeps track of system states, and more.

The systemctl command allows you to start, stop, enable, disable, restart, and check the status of services (also called “units”) on your system.

What Are Unit Files?

Before diving into the commands, it’s helpful to understand the idea of a “unit.” In systemd, everything it manages is represented as a unit. These unit files define how systemd should manage a service, device, mount point, socket, timer, etc.

The most common unit type you’ll deal with is the service unit, which ends in .service.

Example:

  • nginx.service
  • ssh.service
  • cron.service

These unit files are usually located in directories like /etc/systemd/system/ or /lib/systemd/system/.

Basic systemctl Commands (With Examples)

1. Starting a Service

To start a service manually (without rebooting):

sudo systemctl start nginx.service

Check it worked:

sudo systemctl status nginx.service

Sample output:

● nginx.service - A high performance web server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: active (running) since Sat 2025-05-10 09:00:00 UTC; 5s ago

2. Stopping a Service

sudo systemctl stop nginx.service

Check the status again:

sudo systemctl status nginx.service

● nginx.service - A high performance web server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: inactive (dead) since Sat 2025-05-10 09:05:00 UTC; 2s ago

3. Restarting a Service

Use this when you want to apply changes (like updated configs):

sudo systemctl restart nginx.service

4. Reloading a Service

Some services support reloading configuration without a full restart:

sudo systemctl reload nginx.service

5. Enabling a Service

To automatically start a service at boot time:

sudo systemctl enable nginx.service

Verify:

systemctl is-enabled nginx.service

Expected output:

enabled

6. Disabling a Service

sudo systemctl disable nginx.service

Verify:

systemctl is-enabled nginx.service

disabled

7. Checking Service Status

sudo systemctl status ssh.service

You’ll see details like whether the service is running, its PID, recent log messages, and its startup behavior.

8. Listing All Services

systemctl list-units --type=service

To filter running services:

systemctl list-units --type=service --state=running

Other Useful Tricks

View Failed Services

systemctl --failed

Daemon Reload

If you create or modify a unit file, reload systemd‘s configuration with:

sudo systemctl daemon-reexec
or more commonly:
sudo systemctl daemon-reload

Quick Reference Summary

Task Command
Start a service sudo systemctl start <name>.service
Stop a service sudo systemctl stop <name>.service
Restart a service sudo systemctl restart <name>.service
Reload config sudo systemctl reload <name>.service
Enable service on boot sudo systemctl enable <name>.service
Disable service on boot sudo systemctl disable <name>.service
Check status sudo systemctl status <name>.service
List running services systemctl list-units --type=service --state=running
View failed services systemctl --failed

Final Thoughts

The systemctl command is an essential part of modern Linux administration. Whether you’re troubleshooting, deploying web applications, or just managing your personal server, mastering systemctl will make your life easier and your systems more predictable.

The best way to get comfortable with it? Practice! Try starting and stopping test services, enabling them on boot, and watching their behavior. Before long, managing services on your Linux machine will feel second nature.

Share your thoughts