Understanding Linux service managers

Systemd has largely become the de facto standard for service management.

by Pete
Published: Updated: 12 minutes read

For Linux administrators, the pivotal task of service management is paramount. Services, those background processes offering diverse functionalities like web servers and database servers, necessitate adept handling. To accomplish this, a proficient service manager is your go-to ally.

Linux boasts several service managers, each presenting unique attributes and capabilities. This post is an introductory tour of some prominent service managers, their associated files and directories, and fundamental commands to kickstart your journey.

Let’s begin!

This isn’t an exhaustive how-to guide but rather a primer for each service manager to get you started. No particular order :)

1
Upstart

Upstart, originating from Ubuntu but also adopted by other Linux distributions like Red Hat, is designed as an alternative to the traditional SysVinit service manager. It offers support for parallel service startup, enhancing boot times and system responsiveness.

Upstart is celebrated for its simplicity. Its configuration files are straightforward, making it less intricate compared to alternatives like systemd. Additionally, it equips you with ‘initctl,’ a command-line tool for seamless service management, including status checks, service initiation, termination, and log inspection.

File and Folder Structure

Upstart’s file and folder organization may vary among Linux distributions. Nonetheless, the primary configuration files typically reside in ‘/etc/init.’ Within this directory, you’ll encounter files and directories hosting configurations for various services.

The central configuration file, ‘/etc/init/rc-sysinit.conf,’ takes charge of launching the Upstart daemon and startup scripts. You might also find subdirectories, like ‘/etc/init/httpd.conf’ for Apache web server or ‘/etc/init/mysql.conf’ for MySQL, corresponding to distinct services.

How do I know if I’m running Upstart?

There are a few ways to determine if Upstart is the service manager currently running on your Linux system:

  1. Check the ‘init’ process: Use ‘ps -p 1’ to inspect the process ID of the initial process. If it’s named ‘init,’ you’re running Upstart.
  2. Examine the ‘init’ version: ‘init –version’ displays the running init’s version; ‘upstart’ indicates Upstart.
  3. Hunt for Upstart config files: Explore the presence of Upstart configuration files in ‘/etc/init.’
  4. Check your distribution version: Ubuntu and certain others employ Upstart as the default service manager.
  5. Peek at the process list: Utilize ‘ps -e’ to list running processes; spotting an ‘init’ process indicates Upstart.

Basic Commands

This command lists all the services that are currently managed by Upstart, along with their current status (e.g. running, stopped, etc.).

initctl list

Starts the specified service. For example, to start the Apache web server, you would use the command initctl start apache2.

initctl start <service>

Stops the specified service. For example, to stop the Apache web server, you would use the command initctl stop apache2.

initctl stop <service>

Reloads the specified service’s configuration files, without interrupting its operation.

initctl reload <service>

This command shows the current status of a specific service.

initctl status <service>

2
Systemd

Red Hat’s creation, systemd, is now widely embraced by distributions like Ubuntu, Debian, and Fedora. It supersedes both SysVinit and Upstart, offering dynamic management capabilities and intricate features like service dependencies, automatic restarts, and comprehensive logging options. Systemd employs a socket-based activation model for on-demand service launches, further enhancing boot times and system agility.

Systemd also arms you with ‘systemctl,’ a command-line powerhouse for managing services efficiently, from status checks to initiation, termination, and log retrieval.

File and Folder Structure

Systemd’s file and folder arrangement diverges from other service managers. The primary configuration files dwell in ‘/etc/systemd/system.’ Each service or system component is encapsulated in a unit file (e.g., .service, .target), bearing clear, comprehensible syntax and structure.

In addition, ‘/usr/lib/systemd/system’ stocks unit files for packages installed via the distribution’s package manager, while ‘/run/systemd/system’ hosts runtime unit files

How do I know if I’m running Systemd?

There are a few ways to determine if systemd is the service manager currently running on your Linux system:

  • Inspect the primary process: ‘ps -p 1’ will reveal the init process, and if it’s labeled ‘systemd’ or ‘systemd –user,’ you’re running systemd.
  • Verify the init version: Use ‘systemctl –version’ to confirm if your system is powered by systemd.
  • Scan for systemd config files: Seek out systemd configuration files in ‘/etc/systemd/system.’
  • Check your Linux distribution version: Systemd is prevalent in distributions like Red Hat, Ubuntu, Debian, and Fedora.
  • Survey the process list: Run ‘ps -e’ to check for a ‘systemd’ process, signaling systemd operation.

Basic Commands

This command lists all the units that are currently managed by systemd, along with their current status (e.g. running, stopped, etc.).

systemctl list-units 

This command starts the specified unit. For example, to start the Apache web server, you would use the command systemctl start apache2.service.

systemctl start <unit>

This command stops the specified unit. For example, to stop the Apache web server, you would use the command systemctl stop apache2.service.

systemctl stop <unit>

Reloads the specified unit’s configuration files, without interrupting its operation.

systemctl reload <unit>

Shows the current status of a specific unit.

systemctl status <unit>

This command shows whether the unit is active or not.

systemctl is-active <unit>

Shows the dependencies of the unit.

systemctl list-dependencies <unit>

Shows the sockets that are currently available on the system.

systemctl list-sockets

3
SysVinit

SysVinit, a legacy service manager, has been a stalwart choice in the Linux world for years. It boasts a straightforward structure with configuration files residing in ‘/etc/init.d,’ taking the form of shell scripts defining service initiation, termination, and dependencies.

SysVinit stands out for its simplicity, making it a favored option for Linux newcomers. It maintains compatibility across numerous Linux distributions, ensuring reliable service management.

Folder and File Structure

SysVinit’s file and folder configuration is straightforward, with the main configuration files found in ‘/etc/init.d.’ These files, written as shell scripts, dictate how services operate and any dependencies they rely on.

How do I know if I’m running SysVinit?

Here are a few ways to check if your Linux system is running SysVinit:

  1. Check for the ‘/etc/init.d’ directory: The presence of this directory strongly suggests the use of SysVinit.
  2. Inspect the ‘init’ process: Use ‘ps -p 1’ to verify the name of the init process. If it’s labeled ‘init,’ you’re running SysVinit.
  3. Review the init version: Employ ‘init –version’ to confirm the init process version; ‘SysVinit’ indicates its use.
  4. Refer to your Linux distribution documentation: SysVinit is the default service manager for older distributions like Debian 7 and CentOS 6.

Basic Commands

Starts the specified service.

/etc/init.d/<service> start

Stops the specified service.

/etc/init.d/httpd stop

Restarts the specified service.

/etc/init.d/<service> restart

This command shows the current status of a specific service.

/etc/init.d/<service> status

Feature Comparison

FeatureUpstartSystemdSysVinit
Init processinit processsystemd processinit process
ConfigurationJob configurationUnit configurationScript configuration
File location/etc/init/etc/systemd/etc/init.d
Service statusinitctl statussystemctl status/etc/init.d/<service> status
Service controlinitctl start, initctl stop, initctl restartsystemctl start, systemctl stop, systemctl restart/etc/init.d/<service> start, /etc/init.d/<service> stop, /etc/init.d/<service> restart
Service dependenciesEvent-based activationExplicit dependencies and orderingImplicit dependencies and ordering
Service monitoringMonitored via eventsIntegrated monitoring and loggingNot included
CompatibilityUbuntu, older Linux distributionsRed Hat, newer Linux distributionsMost Linux distributions
AdvantagesSimple, reliable, easy to understandAdvanced monitoring and logging, faster boot timesSimple, reliable, highly compatible
DisadvantagesLimited service dependencies, not as advancedComplex configuration, potential compatibility issuesLimited service dependencies, no monitoring or logging

Release Dates

This table summarizes the Linux distributions where each service manager originally made its debut:

Service managerDistributionVersionRelease year
UpstartUbuntu6.102006
SystemdFedora152011
SysVinitUnix V71979

It’s essential to note that while Upstart was initially developed for and used by Ubuntu, Systemd later supplanted it as the default service manager for Ubuntu in versions 15.04 and onwards.

Furthermore, while SysVinit wasn’t specifically designed for a particular Linux distribution, it became the standard Linux service manager for many years and continued to be used across several modern distributions.

In Conclusion

As of 2021, Systemd reigns as the dominant service manager in operational Linux systems, notably in modern distributions such as Red Hat Enterprise Linux, Debian, Ubuntu, and CentOS. While SysVinit and Upstart endure in legacy systems and older distributions, Systemd has firmly established itself as the de facto standard for Linux service management.