View all service 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

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.

Читайте также:  Setting priority in linux

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

Источник

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.

Источник

How to view status of a service on Linux using systemctl

H ow do I use the systemctl command to view status of a systemd service on Linux operating systems?

We use systemctl status command under systemd to view the status of the given service on Linux operating systems.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux & systemd
Est. reading time 8 minutes

Viewing the Status of a Service

The syntax is as follows for the systemctl command systemctl status
systemctl status

How to view status of a service called nginx

Type:
$ systemctl status nginx.service
## ssh server status ##
$ systemctl status sshd.service
## Lighttpd web server status ##
$ systemctl status lighttpd.service

The dot (“ ● “) uses color on supported terminals to summarize the unit state at a glance. White color indicates an “inactive” or “deactivating” state. Red color indicates a “failed” or “error” state. Green indicates an “active”, “reloading” or “activating” state.

Understanding systemd service/unit states

The status of Linux service depends upon various states such as follows:

Service status Description
active (running) Service or daemon is running in the background. For example, sshd or nginx/apache web server and listing for incoming traffic.
active (exited) Service successfully started from the config file. Typically one time services configuration read before Service was exited. For example, AppArmor or Firewall service.
active (waiting) Our service is running but waiting for an event such as CPUS/printing event.
inactive Service is not running.
enabled Service is enabled at boot time.
disabled Service is disbled and will not be started at Linux server boot time.
static Service cannot be enabled on Linux, but mostly started by another systemd unit automatically. In other words, the unit file is not enabled and has no provisions for allowing in the [Install] unit file section.
masked Service is completely disabled and any start operation on it always fails.
alias Service name is an alias. It means service is symlink to another unit file.
linked Made available through one or more symlinks to the unit file (permanently in /etc/systemd/system/ or transiently in /run/systemd/system/), even though the unit file might reside outside of the unit file search path.

Currently following units are supported by systemd

  • service : Service unit configuration about a process controlled and supervised by systemd.
  • mount : File system mount point controlled and supervised by systemd.
  • swap : Swap file/disk configuration controlled by systemd.
  • socket : An IPC or network socket or a file system FIFO controlled and supervised by systemd, for socket-based activation.
  • target : It contains information about a target unit of systemd. It is used for grouping units and as well-known synchronization points during start-up. For example, graphical.target is used for GUI based desktop login. Similarly, multi-user.target is used by servers where users can log in using ssh/console.
  • device : A device unit as exposed in the sysfs/udev device tree. It includes networking and other devices.
  • automount : Automount file systems
  • timer : Cron like systemd unit to run commands and services at a given date/time format. For example, refresh firmware or clean session created by Python or PHP webapps.
  • path : A systemd special target unit that sets up all path units. For example, systemd can take certian action depend upon file system path. If /etc/foo/ modifed take some action.
  • slice : We use a systemd slice for isolating workloads. They define a hierarchy in which scopes and service is placed. The actual processes are contained in scopes or in services. Think it as lightweight Docker. For each slice, certain resource limits such as CPU or disk I/O limit may be set that apply to all processes.
  • scope : Scope units are not configured via unit configuration files, but are only created programmatically using the bus interfaces of systemd. They are named similar to filenames. A unit whose name ends in “.scope” refers to a scope unit. Scopes units manage a set of system processes. Unlike service units, scope units manage externally created processes, and do not fork off processes on its own. The main purpose of scope units is grouping worker processes of a system service for organization and for managing resources.

We can list all services unit as follows:
$ sudo systemctl —type=service
Want to see mount type units? Try:
$ sudo systemctl —type=mount
Display all systemd timer units on your Linux box:
$ sudo systemctl -t timer

To show all installed unit files use:

$ sudo systemctl list-unit-files

Linux view status of a service

Type the following command to view all services and unit status on your Linux system since boot time:
$ sudo systemctl

Click to enlarge

How to list units that systemd currently has in memory

Execute the following command:
$ sudo systemctl list-units
$ sudo systemctl list-units | more
$ sudo systemctl list-units | grep sshd
## filter by unit types ##
$ sudo systemctl list-units —type service
$ sudo systemctl list-units —type timer

List systemd/systemctl all failed units/services on Linux

$ sudo systemctl list-units —failed
$ sudo systemctl list-units —state failed
## filtering by unit type ##
$ sudo systemctl list-units —state failed —type service
$ sudo systemctl list-units —state failed —type timer

The systemctl command options to list all failed units/services

Источник

Читайте также:  Windows media player конфиденциальность
Оцените статью