15%

Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code:

Skills
Get Started
31.10.2024

Systemctl Commands: How to Restart, Reload, and Stop Services in Linux

Managing services efficiently is one of the most critical skills for any Linux system administrator. Whether you're running a high-traffic web server on a VPS Hosting plan or maintaining a Dedicated Server environment, understanding how to control system services using systemctl is absolutely essential. This comprehensive guide covers everything you need to know about restarting, reloading, and stopping services in Linux using systemd and systemctl.

What Is systemd and Why Does It Matter?

systemd is the default init system and service manager used in virtually all modern Linux distributions, including Ubuntu, Debian, CentOS, Rocky Linux, AlmaLinux, and Fedora. It replaced older init systems like SysVinit and Upstart, bringing significant improvements to how Linux boots and manages processes.

Key Features of systemd

  • Parallel service startup — Dramatically reduces boot times by starting services concurrently
  • On-demand service activation — Services can be launched only when needed, conserving system resources
  • Dependency management — Automatically handles service dependencies and ordering
  • Centralized logging — Integrates with journald for unified, structured log management
  • Cgroup-based resource control — Tracks and limits CPU, memory, and I/O usage per service
  • Socket and D-Bus activation — Enables advanced inter-process communication patterns

Understanding systemd is not just academic — it directly impacts the stability, performance, and security of your Linux environment.

What Is systemctl?

systemctl is the primary command-line interface for interacting with systemd. It allows administrators to:

  • Start, stop, restart, and reload services
  • Enable or disable services at boot
  • Check service status and view logs
  • Manage system targets (runlevels)
  • Reload the systemd daemon configuration

All systemctl commands that modify system state require root privileges or sudo access.

Core systemctl Commands for Service Management

1. Restarting a Service

Restarting a service stops it completely and then starts it fresh. This is the go-to operation when:

  • You've made configuration changes that require a full process restart
  • A service has crashed or become unresponsive
  • You need to apply updated binary files after a package upgrade

Syntax:

sudo systemctl restart <service_name>

Example — Restart the Nginx web server:

sudo systemctl restart nginx

Example — Restart the Apache web server:

sudo systemctl restart apache2

Example — Restart the MySQL/MariaDB database:

sudo systemctl restart mysql

> Important: Restarting a service causes a brief interruption. For production environments, consider using reload when supported to avoid downtime.

2. Reloading a Service

Reloading instructs a running service to re-read its configuration files without stopping the process. This is ideal for applying configuration changes with zero downtime.

Syntax:

sudo systemctl reload <service_name>

Example — Reload Nginx after editing its configuration:

sudo systemctl reload nginx

Example — Reload SSH daemon after modifying sshd_config:

sudo systemctl reload sshd

> Note: Not all services support the reload operation. If a service does not implement it, systemctl will return an error. In those cases, use restart instead.

Pro Tip — Use reload-or-restart for maximum compatibility:

sudo systemctl reload-or-restart <service_name>

This command attempts a reload first. If the service doesn't support reload, it falls back to a full restart automatically — making it the safest option for scripted deployments and automation.

3. Stopping a Service

Stopping a service terminates it immediately. Use this when you need to take a service offline for maintenance, troubleshooting, or reconfiguration.

Syntax:

sudo systemctl stop <service_name>

Example — Stop the Nginx web server:

sudo systemctl stop nginx

Example — Stop the firewall service:

sudo systemctl stop ufw

> Warning: Stopping a critical service (such as sshd on a remote server) can lock you out of your system. Always ensure you have an alternative access method, such as a console or out-of-band management, before stopping essential services.

4. Starting a Service

If a service is not currently running, use the start command to launch it.

Syntax:

sudo systemctl start <service_name>

Example:

sudo systemctl start nginx

5. Enabling a Service at Boot

Enabling a service creates the necessary symlinks so that systemd automatically starts it during system boot.

Syntax:

sudo systemctl enable <service_name>

Example:

sudo systemctl enable nginx

Enable and start simultaneously (recommended):

sudo systemctl enable --now nginx

6. Disabling a Service at Boot

Disabling a service prevents it from starting automatically, but does not stop it if it's currently running.

Syntax:

sudo systemctl disable <service_name>

Example:

sudo systemctl disable bluetooth

Disable and stop simultaneously:

sudo systemctl disable --now bluetooth

7. Checking Service Status

The status command is one of the most frequently used systemctl commands. It provides a real-time snapshot of a service's state, including recent log entries.

Syntax:

sudo systemctl status <service_name>

Example — Check the status of Nginx:

sudo systemctl status nginx

Sample output:

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-01-15 10:23:45 UTC; 2h 34min ago
       Docs: man:nginx(8)
    Process: 1234 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 1235 (nginx)
      Tasks: 3 (limit: 4915)
     Memory: 6.2M
        CPU: 45ms
     CGroup: /system.slice/nginx.service
             ├─1235 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─1236 "nginx: worker process"

The output includes:

  • Loaded — Whether the unit file is loaded and if it's enabled at boot
  • Active — Current running state (active (running), inactive (dead), failed, etc.)
  • Main PID — The primary process ID of the service
  • Memory/CPU — Resource consumption metrics
  • CGroup — The control group hierarchy
  • Recent logs — Last few journal entries for quick diagnostics

Advanced systemctl Commands

Checking if a Service Is Active or Enabled

For use in scripts and automation, these commands return simple boolean-style exit codes:

# Check if a service is currently running
systemctl is-active nginx

# Check if a service is enabled at boot
systemctl is-enabled nginx

# Check if a service has failed
systemctl is-failed nginx

Listing All Services

# List all loaded and active units
systemctl list-units --type=service

# List all installed unit files and their states
systemctl list-unit-files --type=service

# List only failed services
systemctl --failed

Reloading the systemd Daemon

After creating or modifying unit files, you must reload the systemd daemon to recognize the changes:

sudo systemctl daemon-reload

Masking and Unmasking a Service

Masking a service prevents it from being started manually or automatically — even by other services:

# Prevent a service from ever starting
sudo systemctl mask <service_name>

# Re-enable a masked service
sudo systemctl unmask <service_name>

Quick Reference: systemctl Command Cheat Sheet

CommandDescription
systemctl start <service>Start a stopped service
systemctl stop <service>Stop a running service
systemctl restart <service>Stop and restart a service
systemctl reload <service>Reload config without stopping
systemctl reload-or-restart <service>Reload if supported, else restart
systemctl enable <service>Enable service at boot
systemctl disable <service>Disable service at boot
systemctl enable --now <service>Enable and start immediately
systemctl disable --now <service>Disable and stop immediately
systemctl status <service>Show service status and logs
systemctl is-active <service>Check if service is running
systemctl is-enabled <service>Check if service starts at boot
systemctl is-failed <service>Check if service has failed
systemctl list-units --type=serviceList all active services
systemctl --failedList all failed services
systemctl daemon-reloadReload systemd unit files
systemctl mask <service>Completely prevent service from starting
systemctl unmask <service>Remove mask from service

Practical Use Cases for Server Administrators

Scenario 1: Applying Nginx Configuration Changes

You've edited /etc/nginx/nginx.conf on your web server. To apply changes without dropping active connections:

# First, test the configuration syntax
sudo nginx -t

# If the test passes, reload gracefully
sudo systemctl reload nginx

Scenario 2: Recovering a Failed Service

A service has crashed and shows a failed state:

# Check what went wrong
sudo systemctl status myapp.service

# View full logs for the service
sudo journalctl -u myapp.service -n 50 --no-pager

# Restart the service
sudo systemctl restart myapp.service

Scenario 3: Setting Up a New Service After Deployment

After deploying a new application with a custom unit file:

# Reload systemd to recognize the new unit file
sudo systemctl daemon-reload

# Enable and start the service in one command
sudo systemctl enable --now myapp.service

# Verify it's running correctly
sudo systemctl status myapp.service

Difference Between restart, reload, and stop — At a Glance

ActionProcess Stopped?Downtime?Use Case
stopYesYesMaintenance, troubleshooting
restartYes, then restartedBriefConfig changes requiring full restart
reloadNoNoneConfig changes with zero downtime
reload-or-restartOnly if neededMinimalSafe automation and scripting

Managing Services Across Different Hosting Environments

The systemctl commands covered in this guide apply universally across Linux-based hosting environments. Whether you're managing services on a VPS with cPanel or a bare-metal Dedicated Server, systemd provides a consistent, reliable interface for service management.

For teams running web applications, it's equally important to secure your services with proper SSL/TLS encryption. AlexHost offers SSL Certificates to help you protect your web services and build user trust — and once your certificate is installed, a simple sudo systemctl reload nginx or sudo systemctl reload apache2 is all it takes to apply the new configuration without downtime.

If you're building a new project and need a reliable foundation, consider starting with Shared Web Hosting for smaller workloads, then scaling up to a full VPS or dedicated server as your needs grow.

Conclusion

Mastering systemctl commands is a fundamental requirement for anyone managing Linux servers in production. The ability to restart, reload, and stop services efficiently — and to understand the difference between these operations — directly impacts your system's availability, performance, and maintainability.

Here's a quick summary of the key takeaways:

  • Use restart when you need a full service cycle — stops and starts the process fresh
  • Use reload for zero-downtime configuration updates when the service supports it
  • Use reload-or-restart in scripts for maximum compatibility and safety
  • Use stop for planned maintenance or when a service needs to be taken offline
  • Always use systemctl status and journalctl to diagnose issues before and after changes

With these commands in your toolkit, you'll be well-equipped to maintain stable, high-performance Linux environments — whether you're managing a single VPS or an entire fleet of dedicated servers.

15%

Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code:

Skills
Get Started