View all service linux

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?

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.

Читайте также:  Install oracle database 19c on oracle linux 8

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 can I see all services in Ubuntu?

System services are the processes or system programs known as ‘daemons’ that continuously run in the background. These services wait for client requests and are responsible for how the system works and how it communicates with other programs. When working in a Linux environment, including Ubuntu, you can easily manage all system services (start, stop, restart, enable at system boot, etc.) through a service manager. Most of the modern Linux distributions, such as Ubuntu, now use a process manager known as ‘systemd’. The systemd is a service manager in the Ubuntu system and used to replace the ‘init’ process. The systemd services manager is controlled by the primary command-line tool ‘systemctl’ command.

We will show you the various techniques in this tutorial related to listing or viewing all services in the Ubuntu 20.04 system.

How to list all services in Ubuntu?

Various services are running in the background of your Ubuntu Linux distribution. While working as a system administrator, you must know how to view all services, including system services such as (login, process management, syslog, cron jobs). You must have the knowledge to view all network services (remote login, web hosting, file transfer, DNS and DHCP, etc.) using the systemctl command and other ways you can control or manage all Linux services. We will also discuss this in this article.

List all services using the systemctl command

When the systemctl command is used without any arguments, in this case, it displays the list of loaded systemd units, including services either these are active or not.

The following command will also display all services unit files:

In the output, the details about UNIT, LOAD, ACTIVE, SUB, and service Description displays in the form of columns as follows:

  • UNIT This column shows the corresponding details about the systemd unit name.
  • LOAD The column displays the information about the unit, either currently loaded in the memory or not.
  • Active This column shows whether the systemd unit is active or not.
  • SUB This column shows the running state of the systemd unit.
  • DESCRIPTION This column displays the short details about the unit.

How to list systemd unit files?

The below-mentioned will show the all available systemd unit files rather than their type and running status info:

Use the grep command in case you are searching for a specific unit file. For example, the below command will search for an apache2 unit file:

Читайте также:  Sn1per установка kali linux

If you want to search for a specific unit file, you can also perform this action using the grep command.

For example, we want to search an apache2 service unit file by using the grep command as follows:

The above command will retrieve all unit files related to the apache2 service that you can see in the following screenshot:

How to list systemd service unit files using states?

The following systemctl command will show you the information about all enabled systemd unit files on Ubuntu 20.04 system:

To display all disabled systemd unit files, run the below-mentioned command:

The services that are enabled on your system automatically start on system reboot.

List all active or running services

Using the ‘systemctl’ command, you can filter active or running services from the all services list as follows:

List all excited services

By running the below-given command, you can easily list all services with the excited state:

List all stopped or dead services

With the help of the following command, you can easily list all disabled services on the terminal window:

Managing systemd services using systemctl

The systemctl is the most commonly used command to manage the systemd unit files and services in Ubuntu 20.04 distribution. Users can enable, disable, start and stop services using the following commands respectively.

$ sudo systemctl enable service-name
$ sudo systemctl disable service_name
$ sudo systemctl start service_name
$ sudo systemctl disable service-name

Using the above commands, you can control each service state based on your requirements.

View service status using systemctl command

To view the detailed information about a particular service, use the below-mentioned command:

For example, we want to check the complete status of the ‘ssh’ service. In this case, by running the following command, you can display the complete status of the ssh service as follows:

More commands to list services in Ubuntu

Use of pstree command

Using the ‘pstree’ command, you can list all running Ubuntu services in the form of the tree structure as follows:

List firewall services

By running the following command, the user can easily list firewall services and ports:

List top control groups with resource utilization

The ‘systemd-cgtop’ command is used to display the top control groups by their resource utilization as follows:

The previous Ubuntu distributions use the ‘service’ command to list all system services as follows:

You can also view all services by directly listing the /etc/init.d directory in older Ubuntu systems as follows:

Conclusion

We learned how to list all services in Ubuntu 20.04 system using the systemctl command. We have also experienced various commands that are also helpful in listing all Ubuntu services. Most of the commands, like the service command, are obsolete now. In the latest Ubuntu distribution, system administrators use ‘systemctl’ to get the details about all systemd services. The systemctl command also offers advanced features and is quite more useful as compared to the other service listing commands.

About the author

Samreena Aslam

Samreena Aslam holds a master’s degree in Software Engineering. Currently, she’s working as a Freelancer & Technical writer. She’s a Linux enthusiast and has written various articles on Computer programming, different Linux flavors including Ubuntu, Debian, CentOS, and Mint.

Читайте также:  Linux как остановить процесс

Источник

Listing Linux Services With Systemctl

A variety of services run continuously on a Linux background, such as network and system services. Services running on Linux are also known as daemons, which refers to a group of processes working on the back-end.

Services can be managed and listed through different methods and tools. The Systemd is a software suite of tools with the ability to manage Linux systems adopted by Linux distribution as a drop-in replacement of the init process.

All system tasks can be controlled through Systemd. The process can be started or ended using this tool, and all enabled and disabled services information can also be listed with Systemd.

List Services Using Systemctl in Linux

Systemctl is a utility with the responsibility to manage and control the systemd system. The systemctl command can be used to list all services in Linux.

We will now show you how systemctl works.

List All Services

To get a list of all the services on the system, whether they are loaded or inactive, issue the following systemctl command in the terminal:

All services in your system will appear on the screen, as you can see in the output shown in the image above.

List Loaded Services

The following command will list every loaded service that is running, active, or failed:

Running Services

In many cases, it can be difficult to distinguish the running services from all the other services. Run the following command to obtain a quick response that shows the loaded and running services in the system:

Enabled Services

Enter the following command to check the enabled services in the system:

Disabled Services

Disabled services will not start up or activate automatically. To enable a desired/required service, select the service from the disabled category. The following command is used to obtain a list of the disabled services in the system:

Check Service Status

The “cup” command is used to obtain more information about the status of a service. Cup is a modular printing system through which the computer acts as a print server and displays information. Use the cups command to obtain more information about the enabled/disabled services in the system:

Where are systemctl service files

Systemd configuration files are stored in specific directories. There are System unit directories and User unit directories.

You can find the location of the System Unit and User Unit directories using the pkg-config systemd command.

Run the following commands to find the directories on your system:

$ pkg-config systemd —variable =systemdsystemunitdir

$ pkg-config systemd —variable =systemduserunitdir

You can browse to these directories and see the systemd unit files.

Conclusion

This article showed you how to use systemctl commands to list services in Linux, including multiple options for viewing the services. With the correct knowledge, it is easy to pick the required command.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.

Источник

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