How to list Services on Ubuntu Linux

|

|

This tutorial guides students and new users on how to list or show all services running or stopped on Ubuntu 20.04 | 18.04 LTS. The guide explains the use of the systemctl command-line utility, which manages systemd services on Linux systems. The tutorial also includes instruction for starting, stopping, enabling, disabling, and checking service status,…

This brief tutorial shows students and new users how to list or show all services running or stopped on Ubuntu 20.04 | 18.04 LTS.

Services are programs that run in the background. These services are responsible for how the system functions and how it communicates.

This post should be handy if you’re using Linux, including Ubuntu, and want to know which services are running or stopped. Knowing how to list and identify services in Ubuntu can help you debug and resolve issues.

For students or new users looking for a Linux system to start learning on, the most accessible place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners.

Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.

When you’re ready to learn how to list services on Ubuntu, follow the guide below:

Most recent Linux distributions, including Ubuntu, use systemd as their default init system and service manager.

systemctl is a command-line utility used for controlling systemd and managing services, which is part of systemd.

About systemctl command:

The systemctl command utility can control and manage systemd services on Linux systems, including Ubuntu.

Previous versions of Ubuntu will use the service command to accomplish the same. Using both systemctl and service commands, you can list all services running, stopped, or disabled.

Syntax:

The syntax is the rule and format of how the systemctl command can be used. These syntax options can be reordered, but a straight format must be followed.

Below is an example syntax of how to use the systemctl command.

systemctl [OPTIONS.] {COMMAND} .

Options:

The command line options are switches or flags that determine how the commands are executed or controlled. They modify the behavior of the commands. They are separated by spaces and followed after the commands.

Below are some options for the systemctl command:

   COMMAND.Replace COMMAND.. with the name of the command service names.
-t –type=TYPE, –state=STATEUse the -t or –type or –state=STATE to list units of a particular type of service state: Active, Inactive
-a –all Use the -a or –all to show all properties/all units currently in memory,
including dead/empty ones. To list all units installed on
the system, use the ‘list-unit-files’ command instead.
-r –recursiveUse the -r or –recursive to show a unit list of host and local containers
–helpDisplay a help message and exit.

Examples:

Below are some examples of how to run and use the systemctl on Ubuntu Linux.

Simply run the systemctl command to invoke it.

Starting and Stopping Services

To start or stop services using the systemctl command, run the commands below:

sudo systemctl start application.service

To stop:

sudo systemctl stop application.service

You can also reference the application name without the ending .service

Example:

sudo systemctl start application

Restarting and Reloading

If you instead restart or reload, you can run the commands below;

sudo systemctl restart application.service

Or reload:

sudo systemctl reload application.service

Reloading a service only reloads configuration changes to a running service and won’t entirely restart the service. To fully restart a running service, you use the restart option.

Enabling and Disabling Services

Suppose you want to turn a service on or off. In that case, you use the commands below: Enabling a service will allow that server to start up every time the server starts up automatically. If you turn off a service, it will not run unless you reenable it.

sudo systemctl enable application.service

Or disable:

sudo systemctl disable application.service

Check service status

To check the status of a service, you use the status option.

sudo systemctl status application.service

Listing all services:

To list all services running or stopped on the server, you run the commands below:

systemctl list-units --all --type=service --no-pager

That should list all services and output a similar screen as below:

 UNIT                                  LOAD      ACTIVE   SUB     DESCRIPTION                                                 
  accounts-daemon.service               loaded    active   running Accounts Service                                            
  acpid.service                         loaded    active   running ACPI event daemon                                           
  alsa-restore.service                  loaded    active   exited  Save/Restore Sound Card State                               
  alsa-state.service                    loaded    inactive dead    Manage Sound Card State (restore and store)                 
  anacron.service                       loaded    inactive dead      
..

To list all inactive services, you run the commands below:

sudo systemctl list-units --all --state=inactive

For only active services:

sudo systemctl list-units --all --state=inactive

When you run systemctl with the –help option, you’ll see the help text below:

systemctl [OPTIONS.] {COMMAND} .

Query or send control commands to the systemd manager.

  -h --help           Show this help
     --version        Show package version
     --system         Connect to system manager
     --user           Connect to user service manager
  -H --host=[USER@]HOST
units installed on
.

Previous versions of Ubuntu using the service can use the commands below:

sudo service --status-all

That’s it!

Congratulations! You’ve learned how to use the systemctl to manage and list services on Ubuntu.

You may also like the commands below:


Discover more from Geek Rewind

Subscribe to get the latest posts to your email.

Like this:



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Discover more from Geek Rewind

Subscribe now to keep reading and get access to the full archive.

Continue reading