Linux list service names

How to list all enabled services from systemctl?

How can I list all enabled services from systemctl ? I know running systemctl command by itself lists all services, but I would like to only get the enabled ones.

Fascinating. The lowest rated answer is the most «correct» answer, even though it is clearly not the best answer. This excellent question (and its answers) is an interesting example of how systemd violates the long-standing (and brilliant) design principles of Unix & Co. @FelipeAlvarez complains that the most-accepted answer assumes systemd follows the unix design philosopy, but systemd/systemctl can do exactly what he wants (most experienced users will just consider that complete bloat). I begin to see more clearly why Linus Torvalds is so vehemently critical of systemd.

If you want to list «templated» services (blabla@instance.service), do not forget to add «—all» — thanks to @rafdouglas below.

9 Answers 9

systemctl list-unit-files | grep enabled will list all enabled ones.

If you want which ones are currently running, you need systemctl | grep running .

Use the one you’re looking for. Enabled, doesn’t mean it’s running. And running doesn’t mean it’s enabled. They are two different things.

Enabled means the system will run the service on the next boot. So if you enable a service, you still need to manually start it, or reboot and it will start.

Running means it’s actually running right now, but if it’s not enabled, it won’t restart when you reboot.

annoying to have to use an external tool (grep) to show this vital information. But thank you for showing us the way 🙂

@FelipeAlvarez Correct. But that’s how Linux works. Many small binaries that work well with each other. systemctl does what is asked, it lists services. There is no filtering command built-in to systemctl because grep already exists and can do that well with any program’s output. It’s how it’s always been 🙂

I agree and so it should be. But, systemd already tries to do SO much that I wonder why it can’t list enabled services?

Читайте также:  Создать файл конфигурации linux

systemctl | grep running do not list anything to me! Even if something is running is only listed as for his status like: enabled, disabled, masked, static

—state=

The argument should be a comma-separated list of unit LOAD , SUB , or ACTIVE states. When listing units, show only those in the specified states. Use —state=failed to show only failed units.

LOAD : Reflects whether the unit definition was properly loaded.
ACTIVE : The high-level unit activation state, i.e. generalization of SUB .
SUB : The low-level unit activation state, values depend on unit type.

Though you can also use this to only show enabled units with:

systemctl list-unit-files --state=enabled 

If a unit is enabled that means that the system will start it on startup. Though setting something to enabled doesn’t actually also start it so you will need to do that manually, or reboot the system after setting it to enabled .

Источник

How to list services in Linux using the command-line

Listing services in Linux is a key part of server management. Here’s how to do so on Ubuntu, Debian, CentOS, and Fedora.

BitLaunch

BitLaunch

How to list services in Linux using the command-line

Performing basic functions in the command-line can be challenging if you’re used to the GUI-based workflow of Windows or Linux desktops. A particular hurdle is working out how to get a list of running services when you cannot lean on hotkeys such as Ctrl + Shift + Esc or Ctrl + Alt + Del.

Listing services in Linux is a key part of server management. It allows you to check whether necessary services are running correctly or whether something is running that shouldn’t. Fortunately, there are several ways to list services in Linux, though the commands can vary depending on the distribution. In this blog, we’ll cover listing services on the most popular ones: Ubuntu, Debian, CentOS, and Fedora.

How to list services in Linux

Linux has multiple easy ways to list services, with the most obvious being the service command. This command should work on all distros that support System V init scripts.

This will list all services, whether they’re running or not, with a + next to the ones that are. You can also filter out services that are running using grep :

And the ones that aren’t by changing that + to a — :

You can find the status of a particular service by typing service status . For example, service ssh status will return:

ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2022-12-19 08:21:39 UTC; 24h ago

Listing services with systemctl

Many will prefer to use the systemctl command over service because it shows more information and outputs in a tabular format. It also works on all of the Linux distributions mentioned. The list-units option will list all services, regardless of whether they are active or not.

systemctl list-units --type=service

systemctl list-units —type=service —all , meanwhile, shows services that are active or have failed.

You can filter those to only active service by using:

systemctl list-units -a --state=active
systemctl list-units -a --state=inactive

Want to list only running services? Use this instead:

systemctl list-units --type=service --state=running

If you want to see the services that have failed (for troubleshooting purposes), you can use the —state option:

systemctl list-units --state=failed

Types of Virtual Machines & Virtualization Technology

Types of Virtual Machines & Virtualization Technology

The different types of virtual machines fall into two categories: process virtual machines and virtual system machines. Here’s how they differ, and where KVMs come into the picture.

Читайте также:  Kali linux usb encrypted persistence

How to install Yarn, the node.js package manager

How to install Yarn, the node.js package manager

Yarn’s release marked a major step forward for package management in node.js, delivering features we now take for granted such as deterministic sub-dependency resolution and an offline cache. While

Источник

How to list services in Ubuntu

Various services on your Ubuntu Linux distribution run in the background and as a system administrator, you will need to be able to view all services, including system services like process management, login, cron jobs, and syslog. Ubuntu allows you to list all these services through specific commands.

The background processes or system programs are also ‘daemons’. These services are in charge of how the system works and how it connects with other programs. When working in a Linux environment, such as Ubuntu, you can use a service manager to conveniently control all system services. The process manager ‘systemd’ is now used by the majority of recent Linux distributions, including Ubuntu. In the Ubuntu system, systemd is the default service manager that replaces the older init process.

This write up will be focusing on discussing the commands which can be used to list the services in Ubuntu. So, let’s begin:

Listing services using systemctl command in Ubuntu

The systemctl is a utility that is used to maintain the services of the system, the general syntax is mentioned below:

When systemctl command is used without options it will list all Ubuntu services. Execute the command given below to get a list of all the services:

In the output we will get the following information:

UNIT: Corresponding details of systemd unit name are displayed.

LOAD: The information about the unit is displayed, whether or not it is currently loaded in memory.

Читайте также:  Linux как установить vpn

ACTIVE: To check active status of system unit

SUB: To check running status of system unit

DESCRIPTION: Gives details about unit

Listing all unit files

Unit files are plain text ini-style files that contain information about a watched file system path, a start-up target, a socket, a device, a mount point and a timer controlled by the system, run the below-given command to list all unit files using systemctl:

Listing systemd unit files

Instead of showing the type and running status of all accessible systemd unit files, the following will do so. Use the mentioned command to list all system unit files:


Search for specific unit file: Below mentioned is syntax to search for specific unit file using “grep”:

If you want to search for “snapd” then run the below mentioned command:

Above output shows all unit files which are related to “snapd” service.

Listing systemd service unit files by state(enabled/disabled)

On Ubuntu, the systemctl command will display information about all enabled systemd unit files by below mentioned command:

On Ubuntu, the systemctl command will display information about all disabled systemd unit files by below mentioned command:

Listing all Active and Running services

To list all running services run the below mentioned command:

Listing all Excited services

To list all excited services run the below mentioned command, excited services are active services that do not find any daemon to monitor:

The output shows that currently there is no excited service in the system.

Listing all Dead services

To list all dead services run the below mentioned command:

Listing services using pstree command in Ubuntu

To list all running services of Ubuntu, run the below mentioned command:

How to list top control groups with resource utilization

Run the below mentioned command to list top control groups using “systemd-cgtop”:


Conclusion

There are many services in a Ubuntu system that work in the background. These services are also known as daemons, they describe how the system works. We can list the Ubuntu services using different commands on the terminal. In this Article we discussed the listing of unit files, running, excited, dead, enabled, disabled services using “systemctl” command. Listing services using the “pstree” command is also mentioned. After comprehending this article you will be able to list different Ubuntu services successfully.

About the author

Alishba Iftikhar

I am currently an undergraduate student in my 1st year. I am an internee author with Linuxhint and loved learning the art of technical content writing from senior authors. I am looking forward to opting my career as a full time Linux writer after I graduate.

Источник

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