Services running on Linux

service is an application that runs in the background to perform some tasks or waiting for requests from other applications to perform tasks.

Some services are required by the operating system, others are initiated by the user. OS specific services are networking, cron, dbus, ssh, while some of the user specific services are web servers such as Apache or Nginx, or database server such as mysql.

SysVinit vs Systemd

SysVinit is the old and test proven init system, while the Systemd is the newer init system used in many Linux distros.

Location of SysVinit scripts:

Debian: /etc/init.d

Red Hat: /etc/rc.d

Location of Systemd scripts:

{lib/etc}/systemd/

SysVinit uses:

service <service-name> command <options>

Systemd uses:

systemctl [options …] command [service-name …]

Examples:

List all services in /etc/init.d

$ ls -al /etc/init.d

List all services (SysVinit)

$ sudo service --status-all

To start a service (SysVinit)

$ sudo service networking start
$ sudo service cron --full-restart

To stop a service (SysVinit)

$ sudo service networking stop

To show the status of a service (SysVinit)

$ sudo service cron status

List all services, including inactive ones (systemd)

$ systemctl -a --type=service list-units

Start a service (systemd)

$ systemctl start httpd.service

Stop a service (systemd)

$ systemctl stop networking.service

To show the status of a service (systemd)

$ systemctl status cron.service

See also Systemd-vs-SysVinit-cheatsheet