Check all services linux

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

Читайте также:  Как установить драйвер sata для windows

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.

Источник

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

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

Источник

Check all services linux

Last updated on: 2019-12-20

Authored by: Rackspace Support

When you need to troubleshoot a network service, the first step is to ensure that the service is running.

If the service has an initialization (init) script installed, you can use the service command to start, stop, and check the status of the service. This command references a service by using its init script, which is stored in the /etc/init.d directory for Debian®-based distributions and the etc/rc.d/init.d directory for Red Hat®-based distributions.

If you don’t know the name that the system uses for a service, check either of the preceding directories by using the ls command followed by the directory name. Some names vary depending on your distribution. For example, Apache® is httpd on CentOS® and apache2 on the Ubuntu® operating system.

Note: Many newer Linux® distributions use systemd instead of netstat to check services. If you’re using systemd , replace all service commands with systemct1 . For more information about systemct1 commands, see the Fedora™ SysVinit to Systemd Cheatsheet.

Check the service status

A service can have any of the following statuses:

  • start : The service has started.
  • stop : The service has stopped running.
  • restart : The service is rebooting and will start after the process is complete.

The following example shows how to check the status of httpd on CentOS by using the service command:

Start the service

If a service isn’t running, you can use the service command to start it. The following example starts the httpd service:

If the application can’t be started, the system reports the failure and usually displays a message that indicates the cause of the problem.

Use netstat to find port conflicts

In the preceding example, httpd can’t be started because something is already listening on the port. To find out what’s listening, you can run the netstat command.

Run the following command to display a list of listening programs and the ports that they’re using:

The output shows that the nc program (which appears in the Program name column) is listening on port 80 (which appears in the Local Address column). Stopping this program should enable httpd to be started.

Note: For more information about the netstat command, see Check listening ports with netstat.

Check xinetd status

If the service isn’t running, it might be because a super-server such as an Extended Internet Service Daemon ( xinetd ) is being used to launch the program when a connection is received. If this is the case, starting the service might have resolved the issue. Run the following command to verify that the issue is resolved:

Check logs

If you can’t start your service, review your logs to see if they contain information about the issue.

Next steps

After you’re sure that the application is running, check the server resources to verify how much your application is consuming.

Share this information:

©2020 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

Источник

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.

Источник

Читайте также:  Как установить windows 10 x86 с флешки
Оцените статью