Saturday, January 11, 2025
HomeProgrammingHow can I See All Running Services Linux Machine?

How can I See All Running Services Linux Machine?

To see all running services on a Linux machine, you can use several commands depending on the system’s init system (e.g., Systemd, Upstart, SysVinit). The most common modern init system is Systemd, but I’ll cover options for various systems.

1. Using systemctl (for Systemd-based systems)

If your system uses Systemd (which is common in modern Linux distributions like Ubuntu, CentOS, Fedora, Debian, and others), you can use the systemctl command to view running services.

List all active services:

systemctl list-units --type=service --state=running
  • list-units: Displays information about units (services, devices, etc.).
  • --type=service: Filters the list to show only services.
  • --state=running: Shows only services that are currently running.

This will show you a list of active services, including their status and whether they are currently running.

See also  Python String Formatting - How to format String?

Example Output:

UNIT                                LOAD   ACTIVE SUB     DESCRIPTION
nginx.service                       loaded active running A high performance web server
sshd.service                        loaded active running OpenSSH server daemon
NetworkManager.service              loaded active running Network Manager
...

List all services (including inactive ones):

systemctl list-units --type=service

This will list all services, both running and inactive.

2. Using service command (for SysVinit and Upstart systems)

If you’re using a Linux distribution that uses SysVinit or Upstart (like older Ubuntu versions), you can use the service command.

List all services:

service --status-all
  • This command lists the status of all services on the system.
  • It will show services with a + (running), - (stopped), or ? (unknown) next to their name.

Example Output:

 [ + ]  apache2
 [ - ]  cron
 [ + ]  ssh
 [ ? ]  mysql
 ...

3. Using ps Command (for Process Monitoring)

You can also use the ps command to see running processes, including those that are services.

See also  JavaScript Arrays

View all processes:

ps aux
  • This lists all processes running on the system. You can filter the output using grep to find specific services.

Example:

To find processes related to nginx:

ps aux | grep nginx

4. Using top or htop Command (for real-time monitoring)

If you want a real-time, interactive view of running processes (including services), you can use top or htop.

  • Top (built-in tool):
    top
    

    This will show you a real-time list of processes and their resource usage.

  • Htop (more user-friendly, needs to be installed):
    sudo apt install htop   # On Debian/Ubuntu-based systems
    sudo yum install htop   # On CentOS/RHEL-based systems
    htop
    

    htop provides a more interactive and color-coded interface for managing and monitoring processes.

5. Using chkconfig (for SysVinit systems)

If you’re using a SysVinit-based system, you can use the chkconfig command to view services.

List all services:

chkconfig --list

This shows the services that are configured to start at boot, and their current run-levels.

Summary of Commands:

  • Systemd: systemctl list-units --type=service --state=running
  • SysVinit/Upstart: service --status-all
  • Process list: ps aux (can be filtered with grep)
  • Interactive real-time: top or htop
  • For SysVinit: chkconfig --list
RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x