How to list, start and stop services at boot time in Linux Ubuntu/Debian

Services which are also known as daemons, are scripts and programs that run in the background. These services, which require no user input, can provide many functionalities like database services (such as MySQL), or web server services (like Tomcat) etc…

Over time however, the number of services can increase substantially and users might overlook which applications are currently running.

Knowing the services that start at boot time is therefore useful for instance if you have noticed that your system has been running slow. Some unnecessary background services might consume additional RAM and SWAP memories as well as CPU power which leaves less room for important programs. Killing these ‘junk’ services or preventing them from starting at boot might ‘relieve’ your system and improve its performance.

In this short tutorial, you will learn how to display all Ubuntu startup services at boot time in and how to start and stop them.

List startup services at boot time

There are many options that allow us to see the list of services at boot time. We will outline below the most commonly used tools .

1 – systemctl

systemctl is the central management utility that controls the systemd system, manages the services and examine the system state.
In order to list out all services along with their corresponding statuses using systemct , open up your terminal and type in the command below :

systemctl -at service

systemctl list services

Now to single out only those services that are active, go ahead and run the command below :

systemctl -t service –state=active

Linux list services

For the services that are enabled however, you would need to invoke the command below :

systemctl list-unit-files –state=enabled

As an alternative to the command above, it is also possible to use grep command as follows :

systemctl list-unit-files | grep enabled

In order to display the list of all currently loaded service units, type in the command below :

systemctl list-units –type service

This command displays, for each service unit file, its full name (UNIT) , its loaded status (LOAD), its high-level (ACTIVE) unit file activation state followed by low-level (SUB) unit file activation state and finally a short description (DESCRIPTION).

The command ‘systemctl list-units’ displays, by default, only active units. In order to display a list of all loaded units (all states), you could execute this command with the –all or -a command line switches as follows:

systemctl list-units –type service –all

Services that started before a given service

In order to find out the services which ordered to start before a specified service, type in the following command in the terminal:

systemctl list-dependencies –after ssh.service

Linux start service

Where you are able to see the services ordered to start before the service named ssh in the snapshot above.

Services that started after a given service

To determine the services which ordered to after after a specified service (ssh here), run the following command:

systemctl list-dependencies before ssh.service

2 service command

The ‘service’ command utility allows to start, restart and stop and daemons as well as other services in Linux. In order to display the list of all services , run the command below :

service –status-all

Ubuntu list services

3 – Checking a specific service enability status

In order to check whether a specific service was enabled at boot time, you could run the following syntax:

systemctl is-enabled {service_name}

systemctl is-enabled service_name.service

here the service name is ssh.

4 – Checking a specific service status

In order to see the status of a given service (enability flag is also provided as highlighted below), the following commands could be executed :

systemctl status {service_name}

systemctl status service_name.service

As an alternative to the command above, you could also use the command below :

systemctl list-unit-files –type service

The following table shows the service units information :

Courtesy: Redhat

You may be interested to read: Network configuration in Ubuntu 

Enabling a specific service at boot time

It is possible to enable a single service by using the one of the commands below :

sudo systemctl enable {service_name}

sudo systemctl enable service_name.service

Disabling a specific service at boot time

Much like enabling a service, systemctl is also able to disable a service by using one of the commands below :

sudo systemctl disable {service_name}

sudo systemctl disable service_name.service

Disabling a service prevents it (its service unit) from being automatically started at boot time.

This will read the [Install] section of the specific service unit and deletes the appropriate symbolic links to the file /usr/lib/systemd/system/name.service from the directory /etc/systemd/system/ and its subdirectories. Furthermore, you would be able to mask any service unit in order to prevent it from being started by another service or manually. To carry this out, execute the following command as root:

systemctl mask name.service

Stopping a specific service

Stopping a specific active service can be achieved via one the commands below (linux stop service) :

sudo systemctl stop {service_name}

sudo systemctl stop service_name.service

Starting and Restarting a specific service

Starting a specific inactive service can be done via one the commands below :

sudo systemctl start {service_name}

sudo systemctl start service_name.service

For the restart :

sudo systemctl restart {service_name}

sudo systemctl restart service_name.service

Displaying services error messages/logs

To check error messages or logs related to the services, execute one of the commands below :

journalctl -u {service_name}

or as an alternative :

journalctl -u service_name.service

Starting a Conflicting Service

Both negative and positive dependencies between services exist in systemd . Starting a specific service may be dependent on one or more other services (.i.e. positive dependency). Negative dependency is similar but the dependency is related to stopping one or more services.

When you try to start a new service, all dependencies are resolved automatically by systemd . The user does not get notified (explicitly) in this case . In case a service is already running, and at the same time you try to start yet another service which has a negative dependency, the first service in this case, will be automatically stopped.

For instance, if the postfix service is already running and you attempt to start the sendmail service, systemd will first automatically stop the first service, i.e. postfix, since these two services are conflicting as they cannot be executed on the same port.

Comparison of systemctl with the service tool

source : https://net2.com/how-to-list-start-and-stop-services-at-boot-time-in-linux-ubuntu-debian/

Posted on: March 8, 2022, by :  | 61 views
https://serang.ut.ac.id/css/css/slot88/ https://tinjut.bagkeu.dikdasmen.kemdikbud.go.id/slot-maxwin/ https://dpm.polinema.ac.id/slot-gacor/ https://akademik.ft.unm.ac.id/slot-dana/ https://ppdb.probolinggokab.go.id/slot-5000/ https://bkad.sulselprov.go.id/assets/ https://ojs.balidwipa.ac.id/docs/slot-gacor/ http://korpri.pekalongankab.go.id/api/slot-gacor/ https://elang.umpp.ac.id/foto/farmasi/-/asset/ http://rsud-kelet.jatengprov.go.id/wp-content/-/asset/ https://kusdhianto-fe.staff.ugm.ac.id/slot88/ http://ppdb.probolinggokab.go.id/judi-bola/ https://bapenda.labuhanbatukab.go.id/racikan-sbobet/ http://rsud-kelet.jatengprov.go.id/wp-content/-/data/ https://agenda.riau.go.id/-/judi-bola/ https://balapan.padang.go.id/sbobet88/ http://jdih.wakatobikab.go.id/sbobet88/ http://kph.menlhk.go.id/sbobet88/ https://bkad.sulselprov.go.id/data/ https://dpm.polinema.ac.id/slot-gacor/ https://dinkes.jemberkab.go.id/storage/attachments/