- Red Hat / CentOS Check and List Running Services Linux Command
- Red Hat / CentOS Check and List Running Services Command
- List running services using service command on a CentOS/RHEL 6.x or older
- Print the status of any service
- List all known services (configured via SysV)
- List service and their open ports
- Turn on / off service
- Red Hat / CentOS List Running Services using systemctl ( RHEL/CentOS 7.x/8.x )
- To list systemd services on CentOS/RHEL 7.x+ use
- How to List All Running Services in Linux
- The ‘service’ command line tool
- The ‘top’ command line tool
- How to List All Running Services Under Systemd in Linux
- Listing Running Services Under SystemD in Linux
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- How to List Services in Linux
- Check and Listing linux services (systemd on Centos/RHEL 7.x)
- Listing services using Netstat Command
- Viewing /etc/services file
- Systemd services status check
- Checking the status of services in older systems (Centos/Rhel 6.x)
Red Hat / CentOS Check and List Running Services Linux Command
H ow do I list all currently running services in Fedora / RHEL / CentOS Linux server? How can I check the status of a service using systemd based CentOS/RHEL 7.x and RHEL/CentOS 8.x?
There are various ways and tools to find and list all running services under a Fedora / RHEL / CentOS Linux systems.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | RHEL or CentOS Linux |
Est. reading time | 6 minutes |
Red Hat / CentOS Check and List Running Services Command
Please note that systemd based system such as CentOS/RHEL 7.x/8.x and latest version of fedora use the systemctl command to list running services
List running services using service command on a CentOS/RHEL 6.x or older
The syntax is as follows for CentOS/RHEL 6.x and older (pre systemd systems) :
service —status-all
service —status-all | more
service —status-all | grep ntpd
service —status-all | less
Print the status of any service
To print the status of apache (httpd) service:
service httpd status
Display status of sshd service:
service sshd status
List all known services (configured via SysV)
List service and their open ports
Turn on / off service
ntsysv
chkconfig service off
chkconfig service on
chkconfig httpd off
chkconfig ntpd on
ntsysv is a simple interface for configuring runlevel services which are also configurable through chkconfig. By default, it configures the current runlevel. Just type ntsysv and select service you want to run.
Red Hat / CentOS List Running Services using systemctl ( RHEL/CentOS 7.x/8.x )
If you are using systemd based Linux distros such as Fedora Linux v22/23/24/26/27/28/29/30/31 or RHEL/CentOS Linux 7.x/8.x. Try the following command to list running services using the systemctl command. It control the systemd system and service manager.
To list systemd services on CentOS/RHEL 7.x+ use
The syntax is:
systemctl
systemctl | more
systemctl | grep httpd
systemctl list-units —type service
systemctl list-units —type mount
To list all services:
systemctl list-unit-files
Sample outputs:
Fig.01: List all units installed on the CentOS /RHEL 7 systemd based system, along with their current states
Источник
How to List All Running Services in Linux
Linux-based operating systems, like all other operating systems, have processes and services that run while the machine is on. These range from various operating system services, to the command line, to different services/daemons designed to maintain the system and keep it running smoothly. Most services are vital to a process’ normal operation, ranging from helper services to special services designed to handle input, improve performance, offload resources, etc. Processes are also the backbone of a computer’s core functionality, making it important to have the resources for them all.
However, it may occur that a service can run without your knowledge, use up system resources, and even make your system vulnerable if security measures have not been taken into account. Because of possible cases like these, it’s good to know how to check and deal with such cases, as well as have the ability to monitor what processes and services are running on your machine at any moment.
In this tutorial, we will go through several methods of listing/showing all running services and processes on a Linux-based server or machine, as well as go through some useful commands that will help you find and manage these processes and services.
The ‘service’ command line tool
The ‘service’ command comes pre-installed with almost every Linux distribution out there. While its main purpose is to start and stop scripts and create processes, ‘service’ can also be used to see what services are running or stopped at any given moment. Using a simple command, we are given a complete list of services:
When you run this, an output similar to this will appear:
As you can see, a list of services is given as output, with a symbol to the left of the service’s name. A ‘+’ symbol means the service is running, a ‘-‘ means that it is stopped, and a ‘?’ means that the status is not currently known. When this is used in combination with a search tool such as ‘grep’, finding specific services that are running is very easy to do. You can then check the status on a process-by-process basis by entering the status command for a specific process:
This will then output a set of information pertaining to that specific service, including the location of the process, whether or not the service is running, and even the last few lines of the log file from the service.
Short for ‘process status’, PS is a pre-installed utility designed to display information and details about processes. It is a simple, fast tool designed to give quick results with no fuss. With one simple command, we can list a well-detailed list of currently running processes:
You can use this in conjunction with the ‘less’ command to further improve readability. When running this command, we are given details for each process currently running. You can also use the ‘grep’ command to narrow down the results to a specific process name, process ID, and so on.
The ‘top’ command line tool
‘top’ is a built-in tool designed to give an overview of all processes and services currently running on your machine. It is included on both Debian-based and RedHat-based distributions and offers a variety of features to help you figure out what’s happening on your server. You can start ‘top’ by simply writing top on the command line. This is what it should look like:
It can look a bit cluttered, but a lot of this information is very useful. For example, we can see how long the system has been running, the average load, how many users are logged in, how many processes (tasks) are running, sleeping, etc. as well as info on the amount of memory we have in total and available on the server. Top goes into even greater detail, down to a process-specific level. Each column displays a specific value that correlates with the process that is running. We can see who owns the process, how much memory it’s utilizing, how much of the CPU is being utilized, the command name, and the process ID, which is unique to that process and helps us identify it in case there’s more than one of the same process. Using all of this information, we can see exactly what each process is doing, and how many resources each process uses up, all in real-time.
Htop is a lot like ‘top’ in terms of its core features and functionality. It is not usually included in a default operating system install, however, it is available for most if not all Linux distributions through its pre-installed software repositories. Like top, htop allows the user to view detailed information about each process, as well as keep tabs on the system itself. However, htop allows for much finer control over the information displayed to you, as well as offering a suite of utilities that can be applied to processes.
For example, through htop, you can adjust the niceness (the priority) of a process, kill it with varying levels of force, and so on. There’s also sorting, which makes it easier to see only the information that is important to you. Selecting a process is possible using the space bar, making it easier to follow and keep track of a specific process (or processes, since you can select more than one at a time). And with a search function, it’s even easier to check and pay attention to specific processes. Htop even has a bar chart that represents the various system resources, allowing you to easily see how much CPU or RAM is allocated.
Here’s an example of what htop looks like:
With the bars at the top, it’s easy to know how your system is doing with just a glance, along with customizable detailed info available just below them.
By using any of these tools, you can easily find the exact information that you need regarding your services and processes.
PS. If you liked this post on how to see which services are running in Linux, please share it with your friends through social media by using the share shortcuts, or simply leave a comment below. Thanks.
Источник
How to List All Running Services Under Systemd in Linux
A Linux systems provide a variety of system services (such as process management, login, syslog, cron, etc.) and network services (such as remote login, e-mail, printers, web hosting, data storage, file transfer, domain name resolution (using DNS), dynamic IP address assignment (using DHCP), and much more).
Technically, a service is a process or group of processes (commonly known as daemons) running continuously in the background, waiting for requests to come in (especially from clients).
Linux supports different ways to manage (start, stop, restart, enable auto-start at system boot, etc.) services, typically through a process or service manager. Most if not all modern Linux distributions now use the same process manager: systemd.
Systemd is a system and service manager for Linux; a drop-in replacement for the init process, which is compatible with SysV and LSB init scripts and the systemctl command is the primary tool to manage systemd.
In this guide, we will demonstrate how to list all running services under systemd in Linux.
Listing Running Services Under SystemD in Linux
When you run the systemctl command without any arguments, it will display a list of all loaded systemd units (read the systemd documentation for more information about systemd units) including services, showing their status (whether active or not).
To list all loaded services on your system (whether active; running, exited or failed, use the list-units subcommand and —type switch with a value of service.
List All Services Under Systemd
And to list all loaded but active services, both running and those that have exited, you can add the —state option with a value of active, as follows.
List All Active Running Services in Systemd
But to get a quick glance of all running services (i.e all loaded and actively running services), run the following command.
List Running Services in Systemd
If you frequently use the previous command, you can create an alias command in your
/.bashrc file as shown, to easily invoke it.
Then add the following line under the list of aliases as shown in the screenshot.
Create a Alias for Long Command
Save the changes in the file and close it. And from now onwards, use the “running_services” command to view a list of all loaded, actively running services on your server.
View All Running Services
Besides, an important aspect of services is the port they use. To determine the port a daemon process is listening on, you can use the netstat or ss tools as shown.
Where the flag -l means print all listening sockets, -t displays all TCP connections, -u shows all UDP connections, -n means print numeric port numbers (instead of application names) and -p means show application name.
The fifth column shows the socket: Local Address:Port. In this case, the process zabbix_agentd is listening on port 10050.
Determine Process Port
Also, if your server has a firewall service running, which controls how to block or allow traffic to or from selected services or ports, you can list services or ports that have been opened in the firewall, using the firewall-cmd or ufw command (depending on the Linux distributions you are using) as shown.
List Open Services and Ports on Firewall
That’s all for now! In this guide, we demonstrated how to view running services under systemd in Linux. We also covered how to check the port a service is listening on and how to view services or ports opened in the system firewall. Do you have any additions to make or questions? If yes, reach us using the comment form below.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
How to List Services in Linux
In this article, I will show you how to list all running services on Linux. We will also check how to check the status of a service on a systemd system.
Let’s learn different commands used to list services on Centos/RHEL 7.x.
Check and Listing linux services (systemd on Centos/RHEL 7.x)
To list systemd services we will use systemctl command as below
Sample Output
To list active systemd services run
Sample Output
Another command you can use is
Sample Output
You can pipe the output to grep to search a more specific service as shown below
Output
Listing services using Netstat Command
Nestat command is a tool used for examining active network connections, interface statistics as well as the routing table. It’s available in all Linux distributions and here we will check how to list services using netstat command.
To check the services alongside the ports they are listening.
Output
Viewing /etc/services file
The /etc/services is an ASCII file that contains information about numerous services that client applications might use on the computer. Within the file is the service name, port number and protocol it uses, and any applicable aliases. ITO put t indicates whether a service is TCP or UDP and the name it goes by according to IANA. This information is helpful especially if you are unsure which service is running on which port by default.
To get a clearer picture, view the /etc/services file using a text editor of your choice.
Output
Systemd services status check
In newer versions of Linux, Systemd init is present. To check if a service is running, use the syntax below
Syntax
For example, to check if OpenSSH is running on your system, run
Output
Alternatively, you can use the syntax below to check if the service is active
In this case, to check if OpenSSH is active, execute
Output
Also, you can use the command below to check if a service is enabled
To check if OpenSSH is enabled, run
Output
Checking the status of services in older systems (Centos/Rhel 6.x)
For systems running SysV Init, you can check the status of services by running
For example, to check the status of OpenSSH, run
Output
You can also check all services by running
Output
We hope you found this article useful. Feel free to try out some of the systemd commands listed here.
Источник