Service details in 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.

Читайте также:  Разблокировка windows 10 с помощью смартфона

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.

Источник

Управление сервисами в Linux. Команда systemctl

Что такое сервисы в Linux

Сервисы или службы — это программы, которые работают в системе Linux в фоновом режиме. Обычно они запускаются при загрузке системы. Большинство сервисов необходимы для полноценной работы системы, то есть они являются своего рода кирпичиками, из которых строится работающая система.

При запуске системы загружается целый ряд сервисов, которые включены для автозагрузки. Сервисы работают пока система запущена, и выгружаются при выключении системы.

Чаще всего в Linux дистрибутивах для инициализации сервисов используется демон Systemd. К Systemd-дистрибутивам относятся Ubuntu, Debian, Linux Mint, Fedora, openSUSE, Solus и другие.

Есть дистрибутивы, которые не используют Systemd. Вместо Systemd могут использоваться такие системы инициализации, как Upstart, SysV.

Читайте также:  Рабочий стол для линукс ubuntu

В качестве примеров сервисов можно привести: веб-сервер Apache, Network Manager, файрвол Ufw и другие.

Для управления сервисами (Systemd) используется утилита systemctl . Ниже мы рассмотрим основные команды данной утилиты.

Список сервисов

Чтобы просмотреть список всех сервисов можно воспользоваться командой:

Данная команда пробегает по алфавитному списку всех доступных сервисов и выполняет для них команду status.

В выводе команды используются следующие обозначения:

  • [ + ] — запущенный сервис.
  • [ — ] — остановленный сервис.
  • [ ? ] — для данного сервиса отсутствует команда status.

Запуск сервиса

Для запуска сервиса используется команда systemctl start имя_сервиса

Останов сервиса

Для остановки сервиса используется команда systemctl stop имя_сервиса

Перезапуск сервиса

Перезапуск сервиса выполняется командой systemctl restart имя_сервиса

Обычно перезапуск конкретного сервиса требуется, когда были изменены настройки данного сервиса.

Некоторые сервисы поддерживают «мягкую» перезагрузку. В этом случае сервис считывает связанные с ним файлы конфигурации, но не прерывает процесс сервиса. Для выполнения «мягкой» перезагрузки используется команда systemctl reload имя_сервиса . Не все сервисы поддерживают «мягкую» перезагрузку. Если она не поддерживается, то появится сообщение вида: Failed to reload ufw.service: Job type reload is not applicable for unit ufw.service.

Автозагрузка сервисов

Чтобы сервис стартовал (загружался) при запуске системы, его нужно включить в список автозагрузки. Для этого используется команда systemctl enable имя_сервиса

Чтобы включить сервис в автозапуск и сразу же запустить используется команда:

Чтобы удалить сервис из автозагрузки, используется команда systemctl disable имя_сервиса

Статус сервиса

Для вывода информации (статуса) сервиса используется команда systemctl status имя_сервиса

Чтобы проверить, запущен ли в данный момент сервис, используется команда systemctl is-active имя_сервиса

Чтобы проверить, включен ли сервис для автозапуска при загрузке системы, используется команда systemctl is-enabled имя_сервиса

Заключение

Мы рассмотрели наиболее часто используемые команды утилиты systemctl. Полный список команд и опций утилиты systemctl можно получить, выполнив:

Источник

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.

Читайте также:  Формат mac os extended журнальный или

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 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:

To list all services, including inactive units, Type:

To List inactive unit, Type:

The systemctl command does not work for Ubuntu 14.04 and earlier releases, instead use the service —status-all command mentioned above.

Источник

Оцените статью