- How to List Services in Ubuntu Server / Desktop
- List Ubuntu Services with Service command
- List Services with systemctl command
- How to List Services in Linux Using Systemctl
- Using Systemctl Command
- 1. List All the Available Services
- 2. List Only Loaded and Active Services
- 3. List Only the Running Services
- 4. List All Stopped Services
- Other Methods to Display Services in Linux
- List All Available Services using service command
- Display Only Running Services using service command
- Extract Only Stopped Services using Service Command
- Listing /etc/init.d
- Conclusion
- How to List Running Services in Linux
- Detecting the System Manger
- Listing Services in the systemd Service Manager
- Using the systemctl Command
- Listing the ACTIVE Services using the systemctl Command
- Listing the FAILED Services using the systemctl Command
- Listing the running Services using the systemctl Command
- Listing the exited Services using the systemctl Command
- Listing Services in the SysV Service Manager
- Listing the Services with service Command
- Listing Services with the ls Command
- Conclusion
How to List Services in Ubuntu Server / Desktop
In this tutorial we are going to learn how to list services in Ubuntu using the command line interface. We will see how we can list running services and services that are not running.
List Ubuntu Services with Service command
The service —status-all command will list all services on your Ubuntu Server (Both running services and Not running Services).
This will show all available services on your Ubuntu System. The status is [ + ] for running services, [ — ] for stopped services.
Using the grep command, we can filter the output to show only the running services.
To list ubuntu services that are not running, Type,
The service command can be used to list services in all Ubuntu releases, including (Ubuntu 17, 16.04, and 14.04).
List Services with systemctl command
Since Ubuntu 15, the services are managed by the systemd. With systemd we can use systemctl command to get information about running services in our Ubuntu system.
To list all running services on Ubuntu, Type:
The output of the command will look something like this:
UNIT LOAD ACTIVE SUB DESCRIPTION apache2.service loaded active running LSB: Apache2 web server apparmor.service loaded active exited LSB: AppArmor initialization cron.service loaded active running Regular networking.service loaded active exited Raise network interfaces nmbd.service loaded active running LSB: start Samba NetBIOS nameserver (nmbd) smbd.service loaded active running LSB: start Samba SMB/CIFS daemon (smbd) ssh.service loaded active running OpenBSD LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type.
To list all services, including inactive units, Type:
To List inactive unit, Type:
systemctl list-units -a --state=inactive
The systemctl command does not work for Ubuntu 14.04 and earlier releases, instead use the service —status-all command mentioned above.
How to List Services in Linux Using Systemctl
Service is a Linux program that runs continuously in the background. Some of the common examples of Linux services are reverse proxy servers, network, cron, SSH, and the high-performance web server. Linux supports multiple tools and methods to list and manage services. Some services start at the boot time and some services can be started after your system boots up. You can control Linux services with systemctl commands.
In this tutorial, we will learn how to list services in Linux using systemctl.
Using Systemctl Command
The systemctl command-line utility is used for controlling the services on Linux systems. Systemctl is part of the systemd software suite that can list all, enabled, active, stopped, or disabled services. All enabled services start at boot. Systemctl is the primary command for managing system services.
In the following examples, we will show you how to use the systemctl command to list services.
1. List All the Available Services
Systemctl provides a wide range of information about all the available services on your Linux systems. To list all available services, use the —all option.
Use the following command to list all active, inactive, failed, running, and stopped services:
systemctl --type service --all
Let us describe each column to better understand the output:
- UNIT – Every resource that systemd manages is denoted as a UNIT. It is the name of the service.
- LOAD – Denotes if the specific service was loaded into memory or not after the system boot up.
- ACTIVE – Denotes if the service is currently active or inactive.
- SUB – Denotes the current state of the Linux service units.
- DESCRIPTION – Provides a brief description of each service.
All these columns are available in the systemctl output, whether you display all available services or only the active/loaded units.
2. List Only Loaded and Active Services
To list only the active or loaded services, do not use the —all option. The following command output includes both running and stopped units, which are still active and loaded.
In this output, we see only the loaded and active services, which is also displayed under the LOAD and ACTIVE columns.
3. List Only the Running Services
Only the loaded and active services can be running, but it does not include all the available services. To list only the units that are running, use the —state option with the value running. For example:
systemctl --type service --state running
The —state filter can be used to sort out the services based on your requirements.
4. List All Stopped Services
Like listing all other services, you can also use systemctl status command to list all the stopped services. Use the —state option with the value exited and you will get a list of the services that were either stopped naturally or were stopped manually:
systemctl --type service --all --state exited
Other Methods to Display Services in Linux
Linux distributions support other options to list services, along with the systemctl. The service command is one such option.
On my Ubuntu 22.04, I am able to use the service command to list services.
List All Available Services using service command
Use the following command to list all services on your Linux system, including active, inactive, running, or stopped services:
The [ + ] and [ — ] symbols before each service name denotes the service status. The [ + ] symbol denotes that the service is running whereas [ — ] denotes that the service is stopped.
When you run this command for that first time, it may take some time for the output to display on the terminal. The service command collects data from the /etc/init.d/ directory.
Display Only Running Services using service command
You can also use the service command to run only the running services. Use the [ + ] symbol with the grep command to sort list only the services that are currently running:
Extract Only Stopped Services using Service Command
Similar to listing Linux services, which are running, using the service command, you can also use the service command to list all stopped services using the [ — ] symbol with the grep command:
Listing /etc/init.d
The service command retrieves service names and status from the /etc/init.d directory. Thus, you can directly list the units from /etc/init.d using the ls command. This method bypasses the source code execution that is required when you run the service command:
The ls command in this example merely lists the contents of the /etc/init.d directory. However, it does not provide you the status of the services. It just gets a list of all the services even if they are stopped or inactive.
Conclusion
Now almost all Linux distributions have adopted using systemd as its init system. Prefer using systemctl because it gives greater control options. Whereas service command is wrapper script and previously used for /etc/init.d scripts.
On my Ubuntu system, I am successfully able to use both systemctl and service command to list services. Over various versions of Ubuntu, users can reliably use service command to list, status check, start/stop services.
Thanks for reading, please leave your feedback and suggestion in the below comment section.
If this resource helped you, let us know your care by a Thanks Tweet. Tweet a thanks
How to List Running Services in Linux
In simpler terms, a Linux service is a server’s response to a request that performs a specific task. It is an application or a program that generally executes in the background.
As a user, you are mostly unaware of all the services running in the background because there are plenty of them.
You might have run through the term daemon most probably while working or learning about services. Daemon is a non-interactive program that runs in the background and strictly does not provide any interfaces for the user to control it.
Some of the common characteristics of a Linux service are:
- There is no GUI(Graphical User Interface).
- Most of the native services start along with the start of the OS.
- Some services wait for an interrupt or a signal to get started.
Some common examples of Linux services are mysql, apparmor, httpd and nfs.
Table of Contents
Detecting the System Manger
Detecting the system manager of your Linux system is the elementary step to listing the running services. This step is essential as the commands for listing the services are based on the system manager.
The system manager is the first process that starts in your system. So, you can use the following command to list the first process in the system.
The output looks like this if the system manager is systemd.
PID TTY TIME CMD 1 ? 00:00:02 systemd
systemd is used in the newer Linux distributions.
If the system manager used is SysV , the output looks like this.
PID TTY TIME CMD 1 ? 00:00:02 init
SysV is also known as init or initialization. It was used in early Linux distributions, and lately, it has been replaced by systemd .
Thus, you can find the system manager from the CMD column of the outputs above. According to the service manager present, you can use the respective methods.
Listing Services in the systemd Service Manager
There are a couple of ways to list the running services when the system manager is systemd , and let’s explore each of them.
Using the systemctl Command
You can use the systemctl command to list the services in your Linux system.
Using the list-units subcommand with the —type=service option will list all the services. It includes active, failed, active (exited), and active (running) services.
systemctl list-units --type=service
The output of the above command is shown below.
In the output above, you can notice several columns. Let’s get to know what they represent.
UNIT: It is an object that starts, stops and manages the services.
LOAD: It states whether the particular unit is correctly loaded.
ACTIVE: It is a high-level state that determines whether the unit is active.
SUB: It represents the low-level activation state of the unit.
DESCRIPTION: It describes the task that the unit performs.
In the sections below, you will learn to list the services according to their states. Some of the systemd states are active, inactive, activating, deactivating, failed, not-found, dead, etc.
Listing the ACTIVE Services using the systemctl Command
You can use specific options and the systemctl command to filter the services. With the —state option, you can set the state of the services. For example, if you want only the active services listed, you can use the following command.
systemctl list-units --type=service --state=active
We have used the —state option with the value active to denote only the active services. In the output below, you can see the active status of all the units.
Listing the FAILED Services using the systemctl Command
Similarly, you can list only the failed services with the following command.
systemctl list-units --type=service --state=failed
Listing the running Services using the systemctl Command
To list only the running services, use the following command.
systemctl list-units --type=service --state=running
A running service has an active value for the ACTIVE state and a running value for the SUB state.
Listing the exited Services using the systemctl Command
Exited services are the one-shot type of services which does their job and are closed. The following command can be used to list the exited services.
systemctl list-units --type=service --state=exited
The ACTIVE state holds the value active for exited service, while the SUB state has the value exited.
Listing Services in the SysV Service Manager
In this section, you will learn a few ways of listing the system’s services that use the SysV service manager.
Listing the Services with service Command
In the system with the SysV service manager, you can use the service command to list all the services.
The output of the command is shown below.
The symbols in the brackets represent the status of the services.
- –: It represents the services that are stopped.
- +: It represents the services that are running.
- ?: It represents the services without the status command.
To list only the running services, you can use the following command.
service --status-all | grep running
Listing Services with the ls Command
Another way you can list the services of init scripts is using the ls command. Using the ls command on the directory containing the init scripts does the job. The init scripts are located in the path /etc/init.d. An example is shown below.
The output of the above command is shown below.
Conclusion
In this tutorial, you learned to identify the system manager used in your Linux system. Thus, you grasped the idea of using the various commands to list the Linux services.