How to Linux List Services Using Systemctl Command [5 Easy Methods]

Written by

Reviewed by

Last updated: June 16, 2024

Expert verified

SVG Image

TL;DR

To Linux list services using systemctl command, you can try following methods:

  1. Listing All Services: View a comprehensive overview of every service managed by systemd using the command systemctl list-units --type=service.
  2. Listing All Active Services: See all currently active services by running systemctl list-units --type=service --state=active.
  3. Listing Inactive Services: Identify all inactive services on your system with systemctl list-units --type=service --state=inactive.
  4. Filtering Services by Status and Unit Type: Filter services based on their status (active, inactive, or failed) and unit type using systemctl list-units --type=service --state=failed.
  5. Listing Services by Load State: Check services based on their load state (loaded, unloaded, or failed) with systemctl list-units --type=service --state=loaded.

Continue reading the guide below to learn different methods to list services using systemctl command, advanced techniques, benefits of using the systemctl command, and common errors that can occur while listing.

Managing all the services running on your Linux system can be challenging, but it doesn’t have to be. Understanding how to list and manage these services is key to maintaining a smooth, secure system. In this post, I’ll show you different methods to Linux list services using the systemctl command and share best practices for effective service management. You’ll learn how to audit services, optimize performance, and enhance security. By the end, you’ll have the tools to keep your Linux system running efficiently and securely.

What are Services?

Services are programs that run in the background on your Linux system. They perform various tasks without requiring direct user interaction. For example, services handle things like managing network connections, running web servers, and scheduling regular tasks. Services are essential for keeping your system and applications running smoothly.

Listing services is important for several reasons:

  • Monitor System Health: By listing services, you can see which services are running and ensure they are operating correctly. This helps you maintain the health and stability of your system.
  • Troubleshoot Issues: If you encounter problems on your system, checking the status of services can help identify the cause. For instance, if a web server isn’t working, you can list and check its service status to find out if it’s running or has failed.
  • Optimize Performance: Knowing which services are active lets you manage system resources better. You can disable unnecessary services to free up memory and CPU, improving overall system performance.
  • Enhance Security: Listing services helps you spot any unauthorized or suspicious services running on your system. This can be crucial for maintaining security and protecting your system from potential threats.

How to Linux List Services Using Systemctl Command

To Linux list services using the systemctl command, you can open your terminal and use the command systemctl list-units --type=service to see a comprehensive overview of all services. For more specific listings, use systemctl list-units --type=service --state=active to view active services, systemctl list-units --type=service --state=inactive for inactive services, and systemctl list-units --type=service --state=failed to see failed services. This helps in monitoring and managing your Linux system efficiently.

Here are the detailed steps for each method to list services using the systemctl command:

1. Listing All Services

Listing all services on your Linux system is a fundamental task that allows you to see a comprehensive overview of every service managed by systemd. This command is essential for system administrators and users who need to monitor and manage the system’s services efficiently. Follow these steps to systemctl list all services:

  1. Open Your Terminal.
image
  1. Type the following command and press Enter:
systemctl list-units --type=service

The output will display a list of all services with several fields. Here’s what each field represents:

  • UNIT: The name of the service unit.
  • LOAD: The load state of the service, indicating whether the unit’s configuration has been loaded.
  • ACTIVE: The high-level unit activation state, i.e., active, inactive, etc.
  • SUB: The low-level unit activation state, providing more specific information.
  • DESCRIPTION: A brief description of what the service does.
listing all available services 2

2. Listing All Active Services

This method allows you to view a comprehensive list of all currently active services running on your Linux system. By executing a simple command in the Terminal, you can quickly access crucial details such as the service name, status, description, and control group. To view all active services on your Linux system, follow these simple steps:

  1. Open a Terminal window on your Linux machine.
  1. Execute the following command in the Terminal:
systemctl list-units --type=service --state=active
  1. The Terminal will display a comprehensive list of all currently active services on your system. Each entry will include details like the service name, status, description, and control group.
listing all currently active services

2. Listing Inactive Services

Inactive services may not be running presently, but it’s essential to be aware of them for potential activation. This method enables you to identify and list all the inactive services on your Linux system, providing you with a complete overview of services that are not currently in use. To see the inactive services on your Linux system, follow these steps:

  1. Access your command window and run the following command in the Terminal:
systemctl list-units --type=service --state=inactive
  1. The Terminal will display a list of all inactive services on your system. These services are currently not running but may be available for activation.
listing all inactive services

3. Filtering Services by Status and Unit Type

When you need to focus on specific types of services or their operational status, this method is invaluable. By filtering services based on their status (active, inactive, or failed) and their unit type (service, socket, device), you gain targeted insights into your system’s service configuration. Follow these steps:

  1. Launch your Terminal window and to filter services based on failure status and see which services have failed, use:
systemctl list-units --type=service --state=failed
  1. The Terminal will display the filtered results, providing you with a more targeted view of the services based on the criteria you specified.
filtering services by status type

4. Listing Services by Load State

The load state of a service indicates whether the service’s configuration has been successfully read and loaded by systemd. This method helps you filter and list services based on their load state, allowing you to identify services that are correctly configured or need attention.

  1. Access your command window. To list all services with a loaded configuration, type:
systemctl list-units --type=service --state=loaded
  • Loaded: The service configuration has been successfully read.
  • Unloaded: The service configuration has not been read, possibly due to errors or misconfigurations.
  • Failed: The service configuration encountered errors during the loading process.
listing services by load state

Advanced Service Listing Techniques

By harnessing tools like Grep, Awk, and Regular Expressions, you can precisely filter and format service listings, gaining deeper insights into your system’s operation. Mastering these techniques enhances your ability to efficiently manage and troubleshoot services, streamlining your Linux experience for seamless operation.

1. Listing Services Using Wildcards and Regular Expressions

Take your service listing to the next level with the flexibility of wildcards and regular expressions. This method empowers you to list services with names containing multiple keywords, such as server or service, in a single command, providing a more targeted and tailored service view. Follow these steps:

  1. Open the Terminal window on your Linux system.
  2. To list services Linux with names containing either server or service, enter the following command:
systemctl list-units --type=service --all | grep -E "server|service"
  1. The Terminal will present a filtered list of services that match the specified regular expression, providing a more focused view of the relevant services.
listing services using wild cards

2. Displaying Service Properties

Displaying the properties of a specific service provides detailed information about its configuration, state, dependencies, and other vital attributes. This is particularly useful for debugging and fine-tuning services.

  1. Launch your Terminal. To display properties of a specific service (replace <service_name> with the actual service name), type:
systemctl show <service_name>

The command output will list all properties of the service. Key properties include:

  • Id: The name of the service unit.
  • Description: A brief description of the service.
  • ActiveState: The current active state (e.g., active, inactive).
  • LoadState: Whether the service configuration has been loaded.
  • ExecStart: The command or script that starts the service.
  • MemoryCurrent: The current memory usage of the service.
listing all properties of a specific service

3. Listing Services with Detailed Status

Getting a detailed status of a specific service gives you an in-depth view of its current state, recent logs, and other critical information. This method is essential for troubleshooting and ensuring services are running as expected.

  1. Access your Terminal. To get a detailed status of a specific service (replace <service_name> with the actual service name), type:
systemctl status <service_name>

The detailed status output includes:

  • Loaded: Indicates whether the service configuration is loaded.
  • Active: The current state (active, inactive, etc.).
  • Main PID: The process ID of the main service process.
  • Tasks: Number of tasks/processes being managed by the service.
  • Memory: Memory usage of the service.
  • CGroup: Control group hierarchy for the service.
  • Recent Logs: Logs generated by the service.
lisitng a service with detailed status

Best Practices for Managing Services

Managing services effectively is crucial for maintaining a stable, efficient, and secure Linux system. By following these best practices, you can ensure your services run smoothly, use resources efficiently, and stay protected from vulnerabilities. Here are some essential tips to help you manage your Linux services better.

🔍 Regular Service Audits

Regularly reviewing your services helps ensure they are necessary and functioning correctly. This keeps your system efficient and secure.

Tips:

  • List All Services: Use the command: systemctl list-units --type=service to see all active and inactive services.
  • Check Logs: Use the command: journalctl -u <service_name> to identify issues by reviewing service logs.
  • Monitor Performance: Use tools like Nagios or Prometheus to track service performance and health.

⚡ Optimizing Service Performance

Managing resource-intensive services effectively can improve system performance and ensure smooth operation.

Tips:

  • Identify Resource Hogs: Use commands like top or htop to find services consuming the most CPU and memory.
  • Limit Memory Usage: Edit the unit file to include: LimitMEMLOCK=infinity to control how much memory a service can use.
  • Set CPU Affinity: Edit the unit file to include: CPUAffinity=1 2 to allocate specific CPUs to resource-heavy services.

🔒 Ensuring Service Security

Implementing strong security measures protects your system from vulnerabilities and unauthorized access.

Tips:

  • Keep Services Updated: Run sudo apt update && sudo apt upgrade to protect against known vulnerabilities.
  • Disable Unnecessary Services: Use the command: systemctl disable <service_name> to reduce the attack surface.
  • Run Services with Least Privilege: Configure services to run with minimal permissions to minimize damage if compromised.

Systemctl List Services: Final Thoughts

In this article, I showed you various methods to Linux list services using the systemctl command, from viewing all services to filtering based on their status and load state.

To further boost your Linux management skills, I suggest exploring:

Frequently Asked Questions

How Can I List Services Running on a Specific User Account?

To view services associated with a specific user account, you can utilize the --user option with Systemctl. Run the following command in the Terminal: systemctl --user list-units --type=service. This command will display a list of services that are associated with the user account currently logged in. It provides a focused view of the services relevant to that user, allowing for easy monitoring and management of their specific services.

Is It Possible to List Services on Older Linux Distributions with Systemctl?

Systemctl is an essential component of the Systemd init system, commonly found in most modern Linux distributions. However, on older systems that do not employ Systemd, such as those using the traditional SysV init system, Systemctl may not be available. In such cases, alternative methods like init.d scripts are used for managing services.

Can I Revert Changes Made Using Systemctl?

Absolutely! Systemctl allows you to revert changes made to services. For example, if you disable a service to prevent it from starting at boot, you can re-enable it later if required. To re-enable a service, use the following command: systemctl enable <service-name>. This will set the service to start automatically at boot, undoing the previous disablement. Reverting changes with Systemctl provides flexibility and ensures that you can adapt your system’s configuration to meet changing requirements.

Ojash

Author

Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.

Akshat

Reviewer

Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

Share this article
Shareable URL
Prev Post

How to Verify Checksum Linux [4 Proven Methods]

Next Post

3 Effective Methods to Update Fedora Linux to Get the Latest Software

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next