Skip to content

Lesson 08 — Linux Services & Systemd

Imagine you’ve deployed an Ubuntu server in AWS to host a company website.

The web server must:

  • Start automatically after every reboot.
  • Continue running even if no user is logged in.
  • Restart if it crashes.
  • Be monitored by the operating system.

Linux accomplishes this using Services managed by systemd.

Services run quietly in the background and power almost every part of a Linux system—from networking and SSH to databases, web servers, Docker, and Kubernetes.

Whether you’re a Linux Administrator, Cloud Engineer, DevOps Engineer, or Cybersecurity Professional, understanding Linux services is essential because nearly every enterprise application depends on them.


After completing this lesson, you will be able to:

  • Explain what Linux services are.
  • Understand systemd and systemctl.
  • Manage services.
  • Configure services to start automatically.
  • Understand service units and targets.
  • Troubleshoot failed services.
  • Apply enterprise service management best practices.

A Linux Service is a background process that performs a specific function without requiring user interaction.

Examples include:

  • SSH Server
  • NGINX
  • Apache
  • Docker
  • MySQL
  • PostgreSQL
  • Cron
  • Network Manager

Services continue running even after users log out.


Without services:

  • Websites would stop.
  • Databases would become unavailable.
  • SSH access would fail.
  • Containers would stop.
  • Enterprise applications would become inaccessible.

Services keep Linux systems available and reliable.


systemd is the default service manager used by most modern Linux distributions.

It is responsible for:

  • Starting the operating system.
  • Managing services.
  • Tracking running processes.
  • Handling system startup.
  • Managing dependencies.
  • Recording service logs.

The first process started during boot is:

systemd
PID 1

systemctl is the command-line tool used to manage services controlled by systemd.

Using systemctl, administrators can:

  • Start services
  • Stop services
  • Restart services
  • Enable services
  • Disable services
  • Check service status

Check whether a service is running.

Terminal window
systemctl status ssh

Example output:

Active: active (running)

This command displays:

  • Service state
  • Process ID
  • Startup time
  • Recent log entries

Start a stopped service.

Terminal window
sudo systemctl start nginx

The service begins running immediately.


Stop a running service.

Terminal window
sudo systemctl stop nginx

This gracefully shuts down the service.


Restart a service after configuration changes.

Terminal window
sudo systemctl restart nginx

Restarting applies new settings without rebooting the server.


Some services can reload configuration without restarting.

Terminal window
sudo systemctl reload nginx

This minimizes downtime.


Enable automatic startup during boot.

Terminal window
sudo systemctl enable nginx

Now the service starts every time Linux boots.


Prevent automatic startup.

Terminal window
sudo systemctl disable nginx

The service remains installed but no longer starts automatically.


Verify startup configuration.

Terminal window
systemctl is-enabled nginx

Example:

enabled

or

disabled

Display active services.

Terminal window
systemctl list-units --type=service

This shows all running services managed by systemd.


Identify services that failed to start.

Terminal window
systemctl --failed

This is useful during troubleshooting.


Every service has a unit file.

Typical location:

/etc/systemd/system/
/usr/lib/systemd/system/

Example:

nginx.service

A unit file defines:

  • Service name
  • Startup command
  • Dependencies
  • Restart behavior

systemd manages different unit types.

Unit Purpose
.service Background services
.target Boot targets
.socket Socket activation
.mount Mounted file systems
.timer Scheduled tasks
.device Hardware devices

The most common unit is the .service file.


Targets define system startup states.

Examples:

Target Purpose
multi-user.target Multi-user server mode
graphical.target Desktop environment
rescue.target Recovery mode
emergency.target Emergency maintenance

Targets replace the older Linux runlevel system.


Display system startup performance.

Terminal window
systemd-analyze

Example:

Startup finished in
4.5 seconds

This helps administrators identify slow boot processes.


systemd integrates with journalctl.

View logs for a service.

Terminal window
journalctl -u nginx

View recent logs.

Terminal window
journalctl -xe

Logs are essential for troubleshooting production systems.


Many services depend on other services.

Example:

Application
Database
Network
Storage

systemd automatically starts services in the correct order.


Cloud Engineers commonly manage services such as:

  • SSH
  • Docker
  • Kubernetes Kubelet
  • NGINX
  • Apache
  • MySQL
  • PostgreSQL
  • Cloud Monitoring Agents

Managing services is a daily task in cloud environments.


DevOps Engineers frequently:

  • Deploy services
  • Restart applications
  • Monitor services
  • Configure automatic startup
  • Troubleshoot failed deployments

Automation tools like Ansible often use systemd to manage services.


Security teams investigate:

  • Unexpected services
  • Disabled security services
  • Malware running as services
  • Unauthorized startup services
  • Failed authentication services

Monitoring services helps detect security incidents.


Check service status:

Terminal window
systemctl status service-name

Start service:

Terminal window
systemctl start service-name

Stop service:

Terminal window
systemctl stop service-name

Restart service:

Terminal window
systemctl restart service-name

Reload configuration:

Terminal window
systemctl reload service-name

Enable at boot:

Terminal window
systemctl enable service-name

Disable at boot:

Terminal window
systemctl disable service-name

View logs:

Terminal window
journalctl -u service-name

A company deploys an internal web application.

Ubuntu Server
systemd
NGINX Service
Application Service
MySQL Service
Users Access Website

If the server reboots, systemd automatically starts all required services in the correct sequence, ensuring the application becomes available without manual intervention.


As a Linux administrator:

  • Enable only required services.
  • Disable unused services.
  • Monitor service health regularly.
  • Restart services after configuration changes.
  • Review logs before troubleshooting.
  • Keep service configurations documented.
  • Use descriptive custom service names.
  • Test startup behavior after system updates.

Proper service management improves system reliability, security, and availability.


After completing this lesson, you should understand:

  • What Linux services are.
  • The role of systemd.
  • How to use systemctl.
  • Service unit files.
  • Startup targets.
  • Viewing service logs.
  • Enterprise service management best practices.

Linux services are the foundation of every modern Linux server.

From SSH and web servers to databases, containers, and monitoring agents, nearly every enterprise application runs as a managed service.

By mastering systemd and systemctl, you’ll be able to deploy, manage, monitor, and troubleshoot Linux servers confidently in cloud, DevOps, and enterprise environments.

These skills are used daily by Linux Administrators, Cloud Engineers, DevOps Engineers, Site Reliability Engineers (SREs), and Cybersecurity Professionals.


➡️ Lesson 09 — Linux Networking

In the next lesson, you’ll learn how Linux communicates over networks, configure IP addresses, troubleshoot connectivity, understand network interfaces, DNS configuration, routing, and use essential networking commands like ip, ping, ss, netstat, traceroute, and curl.