Services, also known as daemons, are background programs and scripts that provide essential functionalities, such as database services like MySQL, or web server capabilities (e.g., Tomcat).
As the number of services installed and running increases overtime, it can become challenging to keep track of all active applications. Understanding which services are configured to start automatically when your system boots can be invaluable, especially if you’ve experienced a slowdown in system performance. Unnecessary services running in the background can consume valuable system resources like RAM, swap space, and CPU cycles, reducing the resources available for essential applications. Disabling or preventing these non-essential services from launching at startup can significantly enhance system responsiveness by freeing up these resources.
This concise tutorial will guide you through the methods to display all Ubuntu services configured to start at boot, as well as how to manage them by starting and stopping services as needed.
Read: How to Access Recovery Mode in Ubuntu Linux 22.04
Several options are available for viewing the list of services configured to start at boot. Below, we will detail the most commonly employed tools for this purpose.
`systemctl` is the primary command-line management tool for `systemd`, the system and service manager in modern Linux distributions. It provides comprehensive control over system services and allows you to inspect the current system state.
To list all services along with their current statuses using `systemctl`, open your terminal and execute the command:
systemctl -at servicesystemctl list services
To specifically display only services that are currently active, use the following command:
systemctl -t service --state=activeLinux list services – active only
Read: How to fix high memory usage in Ubuntu
To view services that are enabled to start at boot, execute the command below:
systemctl list-unit-files --state=enabledAlternatively, you can achieve the same result using the `grep` command to filter the output:
systemctl list-unit-files | grep enabledTo display a list of all currently loaded service units, use the following command:
systemctl list-units --type serviceThis command provides detailed information for each service unit, including its full name (UNIT), its loading status (LOAD), its high-level activation state (ACTIVE), its low-level activation state (SUB), and a brief description (DESCRIPTION).
By default, `systemctl list-units` only shows active units. To display all loaded units, regardless of their state, use the `–all` or `-a` options:
systemctl list-units --type service --allTo identify services that are configured to start before a particular service, for example, `ssh.service`, use the following command:
systemctl list-dependencies --after ssh.serviceServices starting before ssh service
The output displays services that are ordered to start before the ‘ssh’ service, as shown in the image above.
To find services that are ordered to start after a specific service (again, using ‘ssh’ as an example), run the following command:
systemctl list-dependencies --before ssh.serviceThe `service` command is another utility that allows you to manage daemons and other services in Linux, including starting, restarting, and stopping them. To get a list of all services using the `service` command, execute:
service --status-allUbuntu list services using service command
To verify if a particular service is enabled to start at boot, you can use the following syntax:
systemctl is-enabled {service_name}systemctl is-enabled service_name.serviceIn the example above, ‘ssh’ is the service name being checked.
To view the detailed status of a service, including its enabled state, you can use these commands:
systemctl status {service_name}systemctl status service_name.serviceAlternatively, you can utilize the following command to list unit files by service type and check their status:
systemctl list-unit-files --type serviceThe following table explains the information columns for service units:
Courtesy: Redhat
Read: Network Configuration in Ubuntu
To enable a service to automatically start during system boot, use one of these commands:
sudo systemctl enable {service_name}sudo systemctl enable service_name.serviceSimilar to enabling, `systemctl` can also disable a service from starting at boot using these commands:
sudo systemctl disable {service_name}sudo systemctl disable service_name.serviceDisabling a service prevents its service unit from automatically starting when the system boots.
This action reads the `[Install]` section of the service unit file and removes the symbolic links from `/etc/systemd/system/` and its subdirectories that point to `/usr/lib/systemd/system/name.service`. Furthermore, you can completely prevent a service unit from being started, either by other services or manually, by masking it. To mask a service, execute the following command as root:
systemctl mask name.serviceTo stop an actively running service, use one of the following commands:
sudo systemctl stop {service_name}sudo systemctl stop service_name.serviceTo start a service that is currently inactive, use one of these commands:
sudo systemctl start {service_name}sudo systemctl start service_name.serviceTo restart a service that is already running:
sudo systemctl restart {service_name}sudo systemctl restart service_name.serviceTo examine error messages and logs associated with a specific service, execute one of these commands:
journalctl -u {service_name}Alternatively:
journalctl -u service_name.serviceIn `systemd`, service dependencies can be both positive and negative. A service might require other services to be running before it can start (positive dependency), or it might require certain services to be stopped (negative dependency). When you attempt to start a service, `systemd` automatically manages these dependencies without explicit user notification. If you try to start a service that has a negative dependency on a service that’s already running, `systemd` will automatically stop the first service. For instance, if ‘postfix’ is running and you try to start ‘sendmail’, `systemd` will first stop ‘postfix’ because these two services cannot operate simultaneously on the same port.
Credit : Redhat
The post How to Manage Ubuntu Boot Services: List, Start, and Stop Systemd Services at Startup appeared first on net2.
I am excited to announce the release of llm-docs-builder, a library that transforms Markdown documentation…
On October 23rd, we announced the beta availability of silicon-optimized AI models in Ubuntu. Developers…
At NVIDIA GTC Washington D.C., Canonical is pleased to support the arrival of the NVIDIA…
How Anbox Cloud streamlines localization testing Wherever users are based, they expect apps to just…
Ubuntu now runs natively on the Thundercomm RUBIK Pi 3 developer board – a lightweight…
Validate your skills and advance your career with recognized qualifications from the publishers of Ubuntu…
View Comments