Linux Service Listing: Techniques for Ubuntu, Debian, and CentOS
Linux, an open-source software system originating in 1991, is renowned for its reliability and flexibility, operating across a spectrum of devices. Its versatility allows standalone use or integration into larger networked systems.
Managing services on Linux is important for efficient system operation. Similar to other operating systems, Linux operates with services and background processes that execute important tasks while the system is active. Upon system boot, these services automatically initiate and persist until the system is shut down.
Services are important processes that run continuously and can be remotely administered, making Linux ideal for distributed systems. Users also have the option to manually manage these services on Linux distributions like Ubuntu, Debian, CenOS and others.
One commonly used feature of Linux is the ability to list running services, aiding in system monitoring and error identification. This functionality is particularly beneficial for troubleshooting and ensuring system operation. Service management in Linux involves understanding the role and significance of services, which play an integral role in system stability and functionality. Efficient service management ensures the smooth operation of applications and the overall health of a Linux-based environment.
This tutorial will demonstrate the most effective method for listing services on a Linux server, tailored to each distribution and desktop environment. We will discuss the use of the most commonly utilized systemctl command that helps in listing services on Linux servers.
Service Management in Linux
Linux systems offer a wide range of system services, including process management, login functionality, syslog, cron, and various network services such as remote login, email, printers, web hosting, data storage, file transfer, domain name resolution through DNS, dynamic IP address assignment via DHCP, and more.
A service in Linux refers to a process or a set of processes commonly known as daemons or services. These processes run continuously in the background, ready to respond to incoming requests, particularly from clients.
Effectively managing services in Linux is an important task for system administration, ensuring the smooth operation of running background processes. These services perform specific tasks that contribute to the overall stability and functionality of the system. To maintain optimal system performance, administrators need to proficiently start, stop, or restart services based on the system's requirements.
For managing services in Linux, different methods are available, such as starting, stopping, restarting, and enabling auto-start at system boot. Typically, these tasks are handled through a process or service manager, with “systemd” being the predominant choice in most, if not all, modern Linux distributions.
Below, we will list different techniques for managing services in Linux, such as Ubuntu, Debian, and CenOS.
Listing Services in Ubuntu (Linux List Running Services)
In Ubuntu, a widely used Linux distribution, Linux system administrators use various methods to list currently running services. To list services, Ubuntu offers the following command:
$ sudo service --status-all
The above command is useful to list services in Ubuntu along with their current status. So, this command helps users to monitor and manage services on an Ubuntu system.
List Services Ubuntu Using the systemctl Command
Displaying a list of all services on a Linux system can be accomplished using the systemctl command. When systemctl is invoked without any arguments, it provides a comprehensive view of loaded “systemd” units, encompassing both active and inactive services. The command for this is:
$ systemctl --no-pager
Additionally, to specifically list all service unit files, you can use the following command:
$ systemctl list-units --all --type=service --no-pager
If you want to list all active and non-active services, use the following command:
$ systemctl list-units -a
To list inactive services, use the following command:
$ systemctl list-units -a --state=inactive
The output includes columns displaying information about UNIT, LOAD, ACTIVE, SUB, and service DESCRIPTION:
UNIT: Displays details about the “systemd” unit name.
LOAD: Indicates whether the unit is currently loaded in memory.
ACTIVE: Specifies whether the “systemd” unit is active.
SUB: Shows the running state of the “systemd” unit.
DESCRIPTION: It provides a brief description of the unit.
List Services Ubuntu Using the grep Command
To display information about all enabled “systemd” unit files on the Ubuntu system, use the following systemctl command:
$ systemctl list-unit-files | grep enabled
To view details about all disabled “systemd” unit files, execute the following command:
$ systemctl list-unit-files | grep disabled
It’s important to note that services marked as enabled will start automatically upon system reboot, contributing to the startup process.
Ubuntu Show Running Services
To list all running services on the Ubuntu Linux server, use the following command:
$ systemctl --type=service --state=running
To view all services in the "exited" state, execute this command:
$ systemctl list-units --all --type=service --no-pager | grep exited
To list services that have stopped or are in a "dead" state, use the following command:
$ systemctl list-units --all --type=service --no-pager | grep dead
The above commands allow for a quick and convenient display of services based on their respective states, whether exited or dead, within the terminal window.
Managing Services in Debian
In Debian, you can list services in different ways by following similar service management principles. To list services in the Debian Linux server, administrators often use the following command:
$ sudo systemctl list-units --type=service
This command provides a comprehensive view of active services in Debian, allowing administrators to oversee and control running processes effectively.
Debian List Running Services
To list running services in Linux that are also active, type:
$ systemctl list-units --type=service --state=running $ systemctl list-units --all --type=service --no-pager | grep running
If you want to enable a service on the Debian/Ubuntu distribution, use the below command:
$ sudo systemctl enable service-name
The above command enables a service to start automatically during system boot.
If you want to disable a service, use this command:
$ sudo systemctl disable service_name
To start a service, use the below command:
$ sudo systemctl start (service_name)
The above command manually starts the specified service immediately.
To stop a service, use:
$ sudo systemctl stop service-name
The above command halts or stops a running service immediately without rebooting the system.
You can also restart a running service. To restart a service on Ubuntu, you can use the below command:
$ sudo service {service-name} restart
To check the service status, use the following command:
$ sudo systemctl status (ServiceName)
Service Listing Techniques in CentOS
CentOS is another open-source Linux distribution popular for its stability and reliability. It uses methods similar to those that have been explained above for listing services.
CentOS List Services
To list services in the CenOS distribution, use the following command:
$ systemctl list-units --type=service --all
This command offers a detailed overview of all services, including both active and inactive ones. Administrators can then take appropriate actions based on the status of each service, ensuring the smooth operation of a CentOS system.
Linux List Running Services with Service Command
If you are using older Linux distributions, you can list running services in Linux by using the service command.
Open a terminal or press “Ctrl+Alt+t” and use the following command to have CentOS on Linux display running services:
$ sudo service --status-all
To print the status list of services on your computer, enter:
$ sudo service (ServiceName) status
The above command is used to stop or start a service by adding the stop or start keyword after the service name.
Listing Services Ubuntu Using Other Commands
Some other commands are also used to list different services in the Ubuntu system. The “pstree” command is used in Ubuntu to list all running services in a tree structure. Execute the command as follows:
$ pstree
List Firewall Services in Linux
For listing firewall services and ports, use the following commands:
$ sudo firewall-cmd --list-services $ sudo firewall-cmd --list-ports
To display the top control groups based on resource utilization, employ the “systemd-cgtop” command:
$ systemd-cgtop
In earlier Ubuntu distributions, the “service” command was utilized to list all system services:
$ service --status-all
Alternatively, on older Ubuntu systems, you could directly list all services in the /etc/init.d directory:
$ ls /etc/init.d
The systemctl command is more useful than outdated commands like “service.” Benefiting from its advanced features and improved utility in service listing tasks, these commands leverage the “systemctl” in the latest Ubuntu distributions.
Conclusion
In this article, we demonstrated how to list all services on Ubuntu, Debian and CentOS distributions through the systemctl command. Various solutions or distributions exist for obtaining a list of running services on Linux, and among them, “systemd” is often considered a preferred choice.
Functioning as a system and service manager, “systemd” for Linux offers a range of features, including parallel service starting, on-demand module loading, and socket activation. It provides flexibility in managing service behavior through the configuration of unit files, allowing users to exert control over their running services.
All the commands listed above are also useful in listing running services on the VPS Linux server. It's important to recognize that each distribution operates uniquely. Therefore, when selecting a Linux VPS, it's advisable to opt for one pre-installed with your preferred distribution. BlueVPS allows you to choose the Linux distribution for installation on your VPS, providing the flexibility to opt for the one that aligns with your comfort and preferences. To delve deeper into BlueVPS Linux VPS offerings, feel free to get in touch with us.