How to List All Running Services on Ubuntu Terminal
This is an article about how to list all running services in the terminal for users of the Linux operating system, specifically focusing on Ubuntu. In this guide, we will cover several methods that can help you identify and manage the processes currently active on your Ubuntu machine.
In today’s computing environment, it’s essential to be able to monitor what is happening behind the scenes on your computer. One critical aspect of doing so involves understanding how various services are running in the background. These services might include everything from web servers (Apache or Nginx) and database management systems (MySQL or PostgreSQL) to desktop applications that require a constant connection, like Dropbox or BitTorrent.
Read this article to find out about different commands and utilities available for listing all the processes and services currently active on your Ubuntu machine. We will also explore how to use these tools to further investigate individual services in more detail.
Using `ps` Command
The first method involves using the ps command, which stands for “process status.” This tool provides a snapshot of running processes at any given moment. However, to list all currently active services comprehensively, you may need to combine it with other commands or use more specific flags.
To start listing processes with ps, open your terminal and type:
This command lists all running processes and excludes lines containing the word “grep” itself. The output displays a lot of information about each process, including user ID, percentage of CPU usage, memory allocation, start time, PID (process identification number), and more.
While ps is very powerful, it might not provide a full list of services since it does not distinguish between regular processes and system services managed by systemd. For that reason, we recommend looking into other commands as well.
Exploring `systemctl`
Since Ubuntu has adopted the systemd init system in recent versions (Ubuntu 15.04 onwards), you can use the systemctl command to list all running services effectively:
This command provides a clear and concise overview of active services, including their status and whether they are currently running, loaded, or inactive. The output is easy to read and understand.
The systemctl utility not only lists services but also allows you to control them directly from the terminal. For example, if you want to stop a specific service (like Apache), you can do so using:
You could similarly start or restart services as needed with commands like start, restart instead of stop.
Listing Enabled and Disabled Services
Sometimes, it’s useful to know not only which services are running but also those that are enabled at boot time. This knowledge can be crucial for troubleshooting startup issues or understanding why certain applications start automatically.
To list all the services that are enabled:
This command shows a comprehensive list of all system services, whether they are running, loaded, or merely set to start at boot time. If you want to filter this information further to look for specific terms (like “mysql”), you could modify the command as follows:
This would show only those services related to MySQL.
Checking Running Services with `top`
Another approach is using the top command, which provides real-time data on system resource usage and running processes. Although it does not differentiate between regular tasks and background services as clearly as systemctl, it’s still a powerful tool for monitoring activity:
Once you run this command, press “P” to sort by CPU usage or “M” to sort by memory usage—this can help you pinpoint resource-intensive processes. To exit top, simply type ‘q’.
Using `service` Command
For older versions of Ubuntu that haven’t adopted systemd yet, the service command remains useful for managing and listing services:
This gives you an overview of all system services, indicating whether each one is running with a “+” symbol. You can further inspect individual services by appending their names to this command.
Filtering Service Output
To make the output more manageable and relevant for your needs, especially when dealing with a long list of services, you might want to filter it:
This will display only those services related to Apache.
Checking Log Files
Lastly, examining log files can provide additional insight into running and recently run processes. For this purpose, the journalctl command is very handy when using systemd-based systems:
You could further filter these logs for specific keywords to get more detailed information about recent events related to your services.
Conclusion
Listing all running services on an Ubuntu system via the terminal involves several methods and commands, each suited to different scenarios or needs. Whether you’re using systemctl for its straightforward listing capabilities, exploring log files with journalctl, or diving into real-time data with top, there’s a command that can provide the information you need.
By mastering these tools, you’ll be better equipped to manage your Ubuntu system and handle any issues related to services running in the background. Remember, understanding how each service operates is key to maintaining an efficient and secure Linux environment.
Last Modified: 23/05/2019 - 20:37:47