How To Use ubuntu list services

How To Use ubuntu list services






Services in Ubuntu run continuously in the background to handle system operations and application functions. These processes maintain network connections, manage user sessions, and execute scheduled tasks. Access to service information enables effective system monitoring and troubleshooting.

Ubuntu uses systemd as the default service manager. The systemctl command controls and monitors services through systemd. Earlier Ubuntu versions used init with the service command for service management.

List All Ubuntu Services Using systemctl

The systemctl command manages systemd services and displays unit files. A unit file contains configuration data for processes, dependencies, and execution order.

Display all services with their current states:

$ systemctl

The output shows columns with service information:

Column Description
UNIT Service name managed by systemd
LOAD Whether the unit loaded into memory
ACTIVE Current activation state
SUB Detailed unit status
DESCRIPTION Brief service description

List all service-type units:

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

This command displays running, active, loaded, stopped, inactive, and failed services.

List Running Services

Filter output to show only running services:

$ systemctl --type service --state running
Note: Running services actively execute processes and consume system resources.

List Active Services

Display services in active state:

$ systemctl --type service --state active

Active services include running, exited, and waiting states.

List Inactive Services

View services not currently active:

$ systemctl --type service --state inactive

List Stopped Services

Show services that completed execution:

$ systemctl --type service --state exited

Exited services ran successfully and terminated.

Use service Command to List Services

The service command runs SystemV init scripts from /etc/init.d. This utility starts, stops, and restarts services. All init scripts support start and stop operations.

Display all services:

$ service --status-all

The output uses symbols to indicate service status. The [+] symbol marks running services. The [-] symbol marks stopped services.

List Running Services Only

Filter running services using grep:

$ service --status-all | grep '[ + ]'

List Stopped Services Only

Filter stopped services:

$ service --status-all | grep '[ - ]'
Tip: Combine the service command with other utilities for advanced filtering and analysis.

Count Total Services

Count all services using grep with the -c option:

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

Apply the same method to count running or stopped services by modifying the grep pattern.

List Ubuntu Services from /etc/init.d Directory

The service command retrieves data from /etc/init.d. List services directly from this directory:

$ ls -l /etc/init.d/*

This displays all init scripts stored in the directory.

Warning: Modifying files in /etc/init.d affects service behavior and system stability.

Alternative Methods to Monitor Services

Additional commands provide service information through different approaches.

Check Services with top Command

The top command displays real-time process information including services:

$ top

Press q to exit the interface.

Use htop for Enhanced Process View

Install and run htop for an improved process monitoring interface:

$ sudo apt install htop
$ htop

The tool provides color-coded output and interactive controls.

FAQs