Home Ubuntu How to list services in Ubuntu

How to list services in Ubuntu

by Siddharth Bishnoi
stopped services

In Windows, services, tasks, and processes can be viewed using the task manager application. Similarly, in Ubuntu, you can view all the services using the command line. If you are a beginner or using ubuntu for general or personal use, you may not have felt the need to check the services. But, for developers and sysadmins running a server, it is important to check the services for security and stable running of the system.

Services are the background programs that run in the background for several reasons to run the system. They are responsible for how the system works. These processes or groups of processes are also called “daemons.” The default service manager in Ubuntu is systemd or system daemon, which has been used recently in most Linux distros. It was Init in the 1980s in the earlier versions of Ubuntu.

Various services are running, such as system, network, etc. System services such as corn jobs, syslog, process management, etc., are frequently monitored by developers and system admins. There are tons of services that can be viewed easily through some commands. Let’s discuss in detail different ways to list services in Ubuntu.

List services through command-line

You can check only running services rather than all mixed-up services and even have options to store them in a text file or print them. Initially, init was the service manager for Ubuntu. For init, the service command is used to list services that extract the data from /etc/init.d. But systemd is the default service manager where systemctl command is used to list services from systemd. systemctl stands for system control. Several other commands can be used to check the services in Ubuntu, but here we will stick with systemctl and service commands.

1. Systemctl command

Systemctl is a command-line utility that controls the systems and service manager. Using systemctl, you can monitor, view, edit, and delete unit files using the service manager. A unit file is a text file consisting of executing processes, what comes before and after that is to be run, and other details. You can also view services and interact with them through options such as start, stop, enable, disable, etc.

To list all the services, i.e., running, failed, stopped, etc., execute the following command in a terminal window:

systemctl
systemctl

systemctl

where

  • UNIT:- services or processes which the systemd represents as units
  • LOAD:- Shows whether the unit is loaded in the memory or not
  • ACTIVE:- Shows whether the unit is active or inactive
  • SUB:- Shows the current status of units
  • DESCRIPTION:- Shows the description of units

To list all the units of type service, execute the following command:

systemctl list-units --type service --all
list units

list-units

It will display all the services, i.e., running, active, loaded, stopped, inactive, failed

To list only running services, execute the following command:

systemctl --type service --state running
running services

running services

To list active services, change the state from running to active in the above command:

systemctl --type service --state active
active services

active services

To list all the inactive services, change the state to inactive and execute the following command:

systemctl --type service --state inactive
inactive services

inactive services

Similarly, change the state to “exited” for stopped services to view the stopped services.

systemctl --type service --state exited
stopped services

stopped services

2. service command

The service command is a command-line utility used to run a SystemV init script stored in /etc/init.d directory. Like the systemctl command, it can start, stop and restart services or daemons. It does not have many options, but at least we can start, stop, reload, and check the status of the services. All scripts should support at least the start and stop options.

To list all the services, execute the following command:

service --status-all
service command

service command

To list only the running services, execute the following command:

service --status-all | grep '\[ + \]'
running services

running services

To list the non-running services, execute the following command:

service --status-all | grep '\[ - \]'
stopped services

stopped services

The [+] is used for running services and [-] for stopped services by the status command.

To count the number of services, use the -c option with the grep command and execute the following command:

service --status-all | grep -c ''
service count

service count

Similarly, you can count the number of running and stopped services using the -c option in the above commands.

List services from /etc/init.d

The service command extracts the data from /etc/init.d, so we can directly list the services from the /etc/init.d directory in folders. Execute the following command to list the services from the /etc/init.d directory:

ls -l /etc/init.d/*
list services using init.d

list services through init.d

Conclusion

So, we discussed ways to list services in Ubuntu using the command line. Apart from systemctl and service commands, other commands such as top, htop, etc., can be used to list services. If you liked the article or if we missed something, please let me know in the comment section below.

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.