×

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.

Managing services in Ubuntu using systemd ?

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.

How to view all services running in Linux?

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.

How to view running services ?

To view running services, use:

sudo systemctl | grep running

The result of this command is a list of running services.

How to Start a Service in Linux ?

To do this, Use the command below to start a service:

systemctl start {service-name}

How to Stop a service ?

To do this, Use the command below to stop a service:

systemctl stop {service-name}

How to restart a Service ?

To do this, Use the command below to restart a service:

systemctl restart {service-name}


How to know the Status of a service?

To do this, Use the command below to view the status of a service:

systemctl status {service-name}


How to manage services in Ubuntu using service ?

Service is a high-level command that redirects on different binaries. It is less advanced compared to systemd and is a part of init.

Viewing all services

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.

Start a service

Use the command below to start a service:

service {service-name} start

Stop a service

Use the command below to stop a service:

service {service-name} stop


Restart a service

Use the command below to restart a service:

service {service-name} restart


Status of a service

Use the command below to view the status of a service:

service {service-name} status


Managing services in Ubuntu using init

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.

Start a service

Use the command below to start a service:

/etc/init.d/{service name} stop


Stop a service

Use the command below to stop a service:

/etc/init.d/{service name} stop


Restart a service

Use the command below to restart a service:

/etc/init.d/{service name} restart


Status of a service

Use this command to view the status of a service:

/etc/init.d/{service name} status


[Need urgent assistance to fix Linux related issues? We are available to help you today.  ]


Conclusion