Managing a Linux is a critical task and sometimes very difficult if you don’t have the right tools. Often the difficulty lies in having to configure and maintain many resources and services. On a server, most of the resources are software, which makes them a bit easier to monitor. In this tutorial, you’ll learn all the basics of Linux services, including how to manage, control, and list services using .
Linux services
A service is a program that runs in the background, outside the interactive control of system users, since it lacks an interface. This in order to provide even more security, as some of these services are crucial for the operation of the operating system.
On the other hand, in systems like Unix or Linux, services are also known as daemons. Sometimes the names of these services, or daemons, end with the letter d. For example, sshd is the name of the service that handles SSH.
So, let’s move on to know how to list services in Linux.
How to list services in Linux
Let’s consider a potential scenario: you run your Linux system and you can no longer access localhost. Most likely the HTTP service was disabled and is causing the problem.
To fix problems like this and many others, it’s good to know how to list all services in Linux.
Fortunately, CentOS and Ubuntu, two of the most popular operating systems in their areas, share systemd. That means that the commands that we are going to present are compatible with both systems.
First, you have to connect to your server using SSH. If you have problems, consult our .
Once inside, you must be the root user to list the services in Linux.
its
Now you can list all services in Linux. To do so, run the command:
sudo systemctl list-unit-files –type service –all
When you run the command, you will see all the services that are on the system. However, you will also see that some have a defined state. Let’s see what all this means.
- The enabled services (enabled) are the ones that are currently running. Generally these have no problems.
- Services disabled (disabled) are the ones that are not active, but can be activated at any time without any problem.
- The masked services (masked) will not be executed unless you remove that property from them.
- Static services (static) will only be used in case another service or unit needs them.
- Finally, there are generated services (generated) via a SysV or LSB initscript with the systemd generator.
In case you only want to know which services are active, you have to use a command together with , like this:
sudo systemctl | grep running
Manage Linux services
Now that you know how to list services in Linux, it’s time to learn how to manage a specific service. Please note that each service represents software and each software works differently. In this tutorial we will only show how to start, check the status and stop the services – the basic controls.
To start a service on Linux, you need to run the following command:
sudo systemctl start
If the service is configured correctly, it will start. Now, if you want to stop it, use the following command:
sudo systemctl stop
On the other hand, to check the status of a service you can use:
sudo systemctl status
It is also possible to run a service while the operating system is loading:
sudo systemctl enable
Or remove it from the initial load:
sudo systemctl disable
Finally, it is possible to check which port is being used by a service. For this, use netstat.
To install it on Ubuntu, simply run:
sudo apt install netstat-nat
If you are using CentOS 7:
yum install net-tools
Then run the following command:
sudo netstat -plnt
The output will give you all the required network information.
conclusion
Learning to list services in Linux is easy and can greatly speed up troubleshooting! In this tutorial, we have told you how to start, enable, disable, stop and list all services in Linux! Now you can manage your Linux VPS like a pro.
Finally, if you want to know in depth all the uses of listing services in Linux, we recommend that you read more about systemctl.
Deyi is a digital marketing enthusiast, with a background in web design, content creation, copywriting, and SEO. She is part of ‘s SEO & Localization team. In her free time, she likes to develop projects, read a book or watch a good movie.