Linux Services


Linux Services

The Service Command starts calling the script and stops a daemon or service. Usually, all scripts are stored in the/etc/init.d directory.

List running service on Ubuntu

service --status-all – This command is used to get the list of services in our system.

Systemd service management

Listing services

Systemctl – It is used to list running services.

systemctl -- failed To list failed services

Managing Targets (Similar to Runlevels in SysV)

systemctl get-default To find the default target for your system

systemctl set-default To set the default target for your system

Managing services at runtime

systemctl start [service-name] To start a service

systemctl stop [service-name] To stop a service

systemctl restart [service-name] To restart a service

systemctl reload [service-name] To request the service to reload its configuration

systemctl status [service-name] To show the current status of a service

Managing autostart of services

systemctl is-enabled [service-name] To show whether a service is enabled on system boot

systemctl is-active [service-name] To show whether a service is currently active(running)

systemctl enable [service-name] To enable a service on system boot

systemctl disable [service-name] To disable a service on system boot

Masking services

systemctl mask [service-name] To mask a service (Makes it hard to start a service by mistake)

systemctl unmask [service-name] To unmask a service

Restarting systemd

systemctl daemon-reload