Skip to main content

service command

Detailed Explanation

The service command is a utility to run a System V init script. In older Linux distributions (pre-systemd), this was the primary way to start and stop background services. On modern systemd-based systems, service is largely a wrapper that passes commands to systemctl, retaining backward compatibility for administrators used to the old syntax.

Basic Syntax

service <service_name> <command>

Commands are typically start, stop, restart, reload, or status.

Common Commands

CommandDescription
startStart the specified service.
stopStop the specified service.
restartRestart the service.
statusPrint the current status of the service.
--status-allPrint the status of all services.

Real-world Examples

Check the status of the SSH daemon:

service ssh status

(On a systemd system, this usually transparently calls systemctl status ssh.service)

Restart the Apache web server:

sudo service apache2 restart

List the status of all available services:

service --status-all