Services are all over the Linux world. Enterprise Linux world turn over services. There are different tools to manage Linux services like Sys-V, upstart, systemd etc. Systemd is gaining popularity in recent times. Fedora, CentOs, RedHat uses systemd for a long time. Ubuntu started to use systemd too. Here we will look into basics of the service management with systemd.
List Installed Services
Linux operating systems like Ubuntu, CentOS, Debian etc. cames with a lot of default services. Also we can install them later with package managers. We can list currently existing services with the systemctl
command by providing list-units
option.
$ systemctl list-units

- In systemd services are named unit so we use systemctl list-units command.
- As we see there information about service status like active
Get Status of a Service
Now we can know exact names of the services. We will use status
option with the service name in order to get detailed information about the given service. In this example we will list apache2
service.
$ systemctl status apache2

- systemctl status is the command to get status information
- httpd is the service we want to see status information.
- Active:active means it is running currently
- At the bottom we can see latest logs generated by httpd service
Start Service
If the service is in a stoppped state we need to start this service to use properly. We will use start
option by providing the service name. In this example we will start the service apache2
$ systemctl start apache2
Stop Service
The easiest part of managing services is stopping them. We can stop them like start
$ systemctl stop httpd
Restart Service
After making configuration changes about services we need to stop and start service. The practical way is just restarting service like below.
$ systemctl restart httpd
How To Start, Stop and Get Status of Linux Service With Systemd? Infografic
