service Command Cheat Sheet
service runs a System V init script. It is the traditional command to start, stop, and restart services (daemons).
Modern Linux: On most modern distributions (Ubuntu, Fedora, Debian, CentOS 7+), service is a wrapper that redirects to systemctl.
Synopsis
service SCRIPT COMMAND [OPTIONS]
Basic Usage
Start a Service
sudo service nginx start
Stop a Service
sudo service nginx stop
Restart a Service
Stops and starts it.
sudo service nginx restart
Reload Configuration (No Downtime)
If the service supports it, reloads config files without killing connections.
sudo service nginx reload
Monitoring
Check Status
Detailed output about process ID, uptime, and logs.
sudo service ssh status
List All Services
See the status of all services.
service --status-all
[ + ]: Running
- [ - ]: Stopped
- [ ? ]: Status unknown
service vs systemctl
| Action | service (Legacy/Wrapper) |
systemctl (Modern) |
|---|---|---|
| Start | service apache2 start |
systemctl start apache2 |
| Stop | service apache2 stop |
systemctl stop apache2 |
| Enable on Boot | chkconfig apache2 on |
systemctl enable apache2 |
| List Logs | service apache2 status |
journalctl -u apache2 |
Notes
- Compatibility: Even on Systemd machines,
serviceusually still works for backward compatibility. - Boot Persistence:
servicedoes not generally manage enabling/disabling services on boot. Usechkconfig(Old RHEL) orupdate-rc.d(Old Debian), or just usesystemctl enable(Modern).