Master Linux Service Management: Essential Skills Every Sysadmin Needs
This guide explains Linux's three main init systems, runlevels, and essential commands like service, chkconfig, and systemctl, showing how to view, enable, disable, and troubleshoot services while highlighting key configuration directories and unit types for effective system administration.
Linux Service Management Essentials
Introduction
In Linux, when you install a package that provides a daemon, the system adds a systemd script but does not enable the service automatically, so you must manually start or stop services.
Linux has three well‑known init systems that are still widely used.
Runlevels
Based on Linux/Unix, the init process (PID 1) is the first process started by the kernel. It reads /etc/inittab to determine the runlevel and then launches other processes accordingly. The traditional runlevels are:
0 – Poweroff
1 – Single‑user mode
2 – Multi‑user mode (no NFS)
3 – Full multi‑user mode
4 – Unused
5 – Graphical mode
6 – Reboot
Init Systems
The three most common init systems in Linux are:
System V (SysV) Upstart systemdSystem V (SysV)
System V is the original Unix init system. The init process is the first program started by the kernel and becomes the parent of all other processes. Most Linux distributions originally used SysV, but newer init systems like systemd have largely replaced it.
Upstart
Upstart is an event‑driven replacement for /sbin/init. It was designed for Ubuntu and can also be used on other Linux distributions to replace the older SysV init. Ubuntu 9.10 through 14.10 and RHEL 6 used Upstart before being superseded by systemd.
systemd
systemdis a modern init system and service manager used by most major Linux distributions, replacing the traditional SysV init. It is compatible with SysV and LSB scripts, runs as PID 1, and manages services, sockets, devices, mounts, and more. systemd uses .service unit files instead of traditional bash scripts. All daemon processes are placed into cgroups, which can be inspected under /cgroup/systemd.
service command
The service command manages services on many Linux distributions (e.g., Red Hat, Fedora, Mandriva, CentOS).
service --status-all
service vsftpd status
service vsftpd stop
service network restartchkconfig
chkconfigis a command‑line tool that enables or disables services for specific runlevels and lists all services with their current settings. It requires root or sudo privileges.
chkconfig --level 35 mysqld on
chkconfig mysqld on
chkconfig --listsystemctl
Concept
systemdunits represent different objects such as services, sockets, and snapshots. Unit files are stored in several directories: /usr/lib/systemd/system/ – Main service unit files (similar to old /etc/init.d) /run/systemd/system/ – Runtime‑generated units with higher priority /etc/systemd/system/ – Administrator‑created symlinks that override lower‑priority units
Unit Types
service– Files ending with .service define system services target – Files ending with .target emulate runlevels device – Represent kernel‑detected devices mount – Define filesystem mount points socket – Identify inter‑process communication sockets, enabling on‑demand service activation snapshot – Manage system snapshots swap – Identify swap devices automount – Automatic mount points path – Monitor files or directories for changes
You can list units of a specific type with systemctl -t <type>, e.g., systemctl -t service.
Common Commands
systemctl enable httpd.service
systemctl disable httpd.service
systemctl status httpd.service
systemctl start httpd.service
systemctl stop httpd.service
systemctl restart httpd.service
systemctl list-units --type=service
systemctl list-unit-files --type=service
systemctl list-dependencies httpd.service
systemctl mask httpd.service
systemctl unmask httpd.service
systemctl isolate multi-user.target
systemctl isolate graphical.target
systemctl poweroff
systemctl reboot
systemctl suspend
systemctl hibernate
systemctl rescue
systemctl emergencyService Status Codes
active (running)– Service is currently running active (exited) – Service finished its one‑time task active (waiting) – Service is waiting for an event inactive – Service is not running dead – Service process has terminated
Enablement States
enabled– Starts automatically at boot disabled – Does not start at boot static – Cannot be enabled directly but may be pulled in by other units masked – Completely blocked from starting
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
