The systemctl command is a utility which is responsible for examining and controlling the systemd system and service manager. It is a collection of system management libraries, utilities and daemons which function as a successor to the System V init daemon.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to solve Ubuntu related errors.
In this context, we shall look into starting, stopping, and restarting services in Ubuntu 20.04.
Services are background processes that run when the OS boots and end when it shuts down.
Systemd is System Management Daemon and it refers to all the libraries, packages, and utilities around daemon.
Before you get started on staring, stopping, or restarting your services, you need to know the ones that are available on your system.
You can see a list of all the services available on your system by using:
systemctl list-unit-files --type service –all
This will enable you to view the services.
The state of your services can be enabled, disabled, static, masked, or generated.
To view running services, use:
sudo systemctl | grep running
The result of this command is a list of running services.
To do this, Use the command below to start a service:
systemctl start {service-name}
To do this, Use the command below to stop a service:
systemctl stop {service-name}
To do this, Use the command below to restart a service:
systemctl restart {service-name}
To do this, Use the command below to view the status of a service:
systemctl status {service-name}
Service is a high-level command that redirects on different binaries. It is less advanced compared to systemd and is a part of init.
Compared to system, the service commands are a lot simpler. To view all services use:
service --status-all
You will be able to view the services.
The way they are displayed is different. [ + ] means the services is enabled and [ – ] means disabled.
Use the command below to start a service:
service {service-name} start
Use the command below to stop a service:
service {service-name} stop
Use the command below to restart a service:
service {service-name} restart
Use the command below to view the status of a service:
service {service-name} status
The init scripts for services are loaded in the directory /etc/init.d/. Init stands for initialization, it is a daemon process that starts when the computer starts and ends when it shuts down. If init does not start, no process starts and the system reaches the Kernel Panic stage. It has been replaced by systemd which reduces computational overhead.
Use the command below to start a service:
/etc/init.d/{service name} stop
Use the command below to stop a service:
/etc/init.d/{service name} stop
Use the command below to restart a service:
/etc/init.d/{service name} restart
Use this command to view the status of a service:
/etc/init.d/{service name} status