Linux service managers on shell

SysVinit

All services can be found in /etc/init.d.
Enabling services on boot by symlink them in /etc/rc3.d (or /etc/rc2.d).

Some distros will have their own tool for managing these files, and that tool should be used instead.

  • Fedora/RedHat has service and chkconfig;
  • Ubuntu has update-rc.d;

List services
ls /etc/init.d/

Start service
/etc/init.d/{SERVICENAME} start

Stop service
/etc/init.d/{SERVICENAME} stop

Enable service
cd /etc/rc3.d
ln -s ../init.d/{SERVICENAME} S95{SERVICENAME}
(S95 is used to specify order. S01 will start before S02, etc)

Disable service
rm /etc/rc3.d/*{SERVICENAME}

Systemd

List services
systemctl list-unit-files

Start service
systemctl start {SERVICENAME}

Stop service
systemctl stop {SERVICENAME}

Enable service
systemctl enable {SERVICENAME}

Disable service
systemctl disable {SERVICENAME}