System
service
Run legacy init service scripts.
serviceinitsystemlegacyscript
Additional Notes
service runs legacy init (SysV) service scripts. It is the traditional way to start, stop, restart, and check services on SysV-based systems, and it wraps the /etc/init.d/ scripts.
On systemd-based distributions, service usually redirects to systemctl for compatibility, so the same command works in older guides and newer systems alike.
Syntax
service [options] SERVICE ACTION
Parameters
options: Flags that change howservicebehaves.SERVICE: Name of the service script to manage.ACTION: What to do:start,stop,restart,reload,status, and so on.
Common Actions
SERVICE status: Show whether the service is running.SERVICE start: Start the service now.SERVICE stop: Stop the service now.SERVICE restart: Stop then start the service.SERVICE reload: Ask the service to reload its config without a full restart.SERVICE force-reload: Reload, falling back to restart if reload is unsupported.SERVICE condrestart: Restart only if already running.
Common Options
--status-all: Show status of every init script.--list: List installed service scripts.-h,--help: Show usage help.--version: Print the version.
Examples
sudo service ssh status
Check whether the SSH service is running.
sudo service nginx restart
Restart the nginx service.
sudo service cron stop
Stop the cron service.
sudo service apache2 reload
Reload Apache configuration without dropping connections.
sudo service --status-all
Print a running/stopped summary for all services.
service --list
List available service scripts on the system.
Practical Notes
- Most actions need
sudobecause they change system state. - On systemd systems, prefer
systemctl;servicestill works through compatibility. - Use
reload(orforce-reload) when the service supports it to avoid a full restart. statusoutput varies by script; combine withjournalctlor logs for detail on systemd hosts.service --status-allis handy for a quick overview during troubleshooting.