Operations 13 min read

Master Linux Service Management: Init Systems, runlevels, systemd & essential commands

This guide explains Linux service management fundamentals, covering traditional SysV init, Upstart and systemd, runlevel definitions, key configuration directories, and practical commands such as service, chkconfig and systemctl for enabling, disabling, inspecting, and controlling services.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Service Management: Init Systems, runlevels, systemd & essential commands

Introduction

When you install a package that provides a daemon on Linux, the system adds its initialization script to systemd, but the service is not enabled automatically. You must manually enable or disable services.

Runlevels

0 – Power off

1 – Single‑user mode

2 – Multi‑user mode without NFS

3 – Full multi‑user mode

4 – Unused

5 – Graphical interface

6 – Reboot

Common Init Systems

System V (SysV)

SysV is the original Unix init system. The first process started by the kernel is init (PID 1), which then launches all other processes. Most traditional Linux distributions still ship SysV scripts in /etc/init.d.

Upstart

Upstart is an event‑driven replacement for /sbin/init originally created for Ubuntu. It handles service start‑up, monitors services while the system runs, and stops them on shutdown. Ubuntu 9.10–14.10 and RHEL 6 used Upstart before being replaced by systemd.

systemd

systemd

is a modern init system and service manager that replaces SysV on most major Linux distributions. It is the first program started by the kernel (PID 1) and provides a unified way to manage services, sockets, devices, mounts, and more. It uses unit files with extensions such as .service, .target, .socket, etc.

service command

The service command is a wrapper for managing services on SysV‑based systems. It is available on Red Hat, Fedora, CentOS, and similar distributions, but not on all Linux flavors.

chkconfig utility

chkconfig

is a command‑line tool that lists services, shows their current run‑level settings, and enables or disables them for specific runlevels. It requires root or sudo privileges.

systemctl command

Core concepts

systemd

manages objects called *units*. Common unit types include: .service – defines a system service .target – groups units to emulate runlevels .device – represents a kernel device .mount – defines a mount point .socket – defines a listening socket (enables on‑demand activation) .snapshot – stores a system state .swap – defines a swap device .automount – automatic mount points .path – watches a file or directory for changes

Configuration file locations

/usr/lib/systemd/system/

– default unit files supplied by packages (similar to old /etc/init.d) /run/systemd/system/ – runtime units generated during boot (higher priority than /usr/lib) /etc/systemd/system/ – administrator‑created or overridden units (highest priority)

To modify a service, edit the file in /usr/lib/systemd/system/ or create a drop‑in in /etc/systemd/system/ that links to the original.

Common commands (old vs. new)

Enable service at boot: systemctl enable httpd.service (old: chkconfig --level 3 httpd on)

Disable service at boot: systemctl disable httpd.service (old: chkconfig --level 3 httpd off)

Check service status: systemctl status httpd.service (old: service httpd status)

List all services: systemctl list-units --type=service (old: chkconfig --list)

Start a service: systemctl start httpd.service (old: service httpd start)

Stop a service: systemctl stop httpd.service (old: service httpd stop)

Restart a service: systemctl restart httpd.service (old: service httpd restart)

Inspecting services

Show detailed unit properties: systemctl show httpd.service List enabled/disabled unit files: systemctl list-unit-files --type=service Show dependencies: systemctl list-dependencies httpd.service Analyze boot time per unit:

systemd-analyze blame

Socket units

List all socket units: systemctl list-unit-files --type=socket Start/stop/reload a socket:

systemctl start cups.socket
systemctl stop cups.socket
systemctl reload cups.socket

Other useful systemctl actions

Mask a service (prevent it from being started): systemctl mask httpd.service Unmask a service: systemctl unmask httpd.service Switch to text mode: systemctl isolate multi-user.target Switch to graphical mode: systemctl isolate graphical.target Power off, reboot, suspend, hibernate, rescue, emergency:

systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
systemctl rescue
systemctl emergency

Images

Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Image
Service Managementsystemdinit systemRunlevelsystemctlchkconfig
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.