Control the systemd system and service manager in Linux.
# To show all running services:
systemctl status
# To list failed units:
systemctl --failed
# To start/Stop/Restart/Reload a service:
systemctl <start|stop|restart|reload> <unit>
# To show the status of a unit:
systemctl status <unit>
# To enable/Disable a unit to be started on bootup:
systemctl <enable|disable> <unit>
# To mask/Unmask a unit to prevent enablement and manual activation:
systemctl <mask|unmask> <unit>
# To reload systemd, scanning for new or changed units:
systemctl daemon-reload
# To check if a unit is enabled:
systemctl is-enabled <unit>
# ---
# To start service
systemctl start <service_inactive>
# To stop service
systemctl stop <service_active>
# To enable service
systemctl enable <service_disabled>
# To disable service
systemctl disable <service_enabled>
# To restart service
systemctl restart <service>
# To reload service
systemctl reload <service_active>
# To service status
systemctl status <service>
# To list running services
systemctl list-units --type=service --state=running
# To list enabled services
systemctl list-unit-files --type=service --state=enabled
# To list disabled services
systemctl list-unit-files --type=service --state=disabled
$ service_inactive: systemctl list-units --type=service --state=inactive | awk '{print $1}' | grep .service | sed 's/.service$//'
$ service_active: systemctl list-units --type=service --state=active | awk '{print $1}' | grep .service | sed 's/.service$//'
$ service_enabled: systemctl list-unit-files --type=service --state=enabled | awk '{print $1}' | grep .service | sed 's/.service$//'
$ service_disabled: systemctl list-unit-files --type=service --state=disabled | awk '{print $1}' | grep .service | sed 's/.service$//'
$ service: systemctl list-units --type=service --all | awk '{print $1}' | grep .service | sed 's/.service$//'