Services managed by systemd are visible through `systemctl list-unit-files –type=service`, which shows enabled and disabled states. If you are wondering how to list services in linux, you have come to the right place. This guide covers every major method, from systemd to SysVinit, with clear steps and examples.
Knowing what services are running on your Linux system is essential for troubleshooting, security audits, and performance tuning. Services are background processes that start at boot or on demand. This article will teach you multiple ways to list them, check their status, and understand their configuration.
How To List Services In Linux
Linux uses different init systems to manage services. The most common one today is systemd, but older distributions may still use SysVinit or Upstart. We will cover all three, focusing on systemd first because it is the standard for modern distros like Ubuntu, Fedora, Debian, and CentOS.
Using Systemctl With Systemd
The primary command for listing services under systemd is systemctl. It provides detailed information about unit files, which define services, sockets, and other resources.
- List all service unit files: Run
systemctl list-unit-files --type=service. This shows every service installed, along with its state (enabled, disabled, static, or masked). - List only active services: Use
systemctl list-units --type=service --state=active. This filters out inactive or failed services. - List running services: Run
systemctl list-units --type=service --state=running. This shows only services that are currently executing. - List all loaded services: Use
systemctl list-units --type=servicewithout a state filter. It includes active, inactive, and failed services.
Each command outputs a table with columns for UNIT, LOAD, ACTIVE, SUB, and DESCRIPTION. The UNIT column shows the service name (e.g., sshd.service). The ACTIVE column indicates whether the service is running or not.
Checking Service Status
To see detailed status for a specific service, use systemctl status <service-name>. For example, systemctl status sshd shows the PID, memory usage, recent log entries, and whether it is enabled at boot.
Listing Services With Service Command
On older systems or those using SysVinit, the service command is used. It works with init scripts located in /etc/init.d/. To list all available services, run service --status-all. This shows a list with symbols indicating running (+), stopped (-), or unknown (?).
Note that service --status-all does not show services managed by systemd unless a compatibility layer is present. It is best for legacy systems.
Using Init Scripts Directly
You can also list services by looking at the init scripts themselves. Run ls /etc/init.d/ to see all SysVinit service scripts. Each script can be started, stopped, or restarted manually. This method is low-level and not recommended for daily use.
Listing Services With Ps And Grep
If you want to see all running processes that might be services, use ps aux | grep -E "systemd|init|service". This is a quick way to spot active daemons, but it does not show disabled or stopped services. It is useful for verifying if a service is actually running.
For a cleaner list, combine ps with awk or cut to extract process names. For example, ps -eo pid,comm | grep -E "systemd|sshd|nginx".
Using Htop Or Top
Interactive process viewers like htop or top can show services as processes. In htop, press F4 and type the service name to filter. This is visual but not ideal for scripting or automation.
Listing Services With Netstat Or Ss
Services that listen on network ports can be listed using netstat -tulpn or ss -tulpn. These commands show which services are bound to which ports. For example, ss -tulpn | grep LISTEN shows listening services. This is helpful for security audits.
Using Systemd-analyze
The systemd-analyze tool provides boot-time analysis. Run systemd-analyze blame to see which services took the longest to start. Run systemd-analyze critical-chain to see the dependency tree. This helps identify slow services.
Listing Services With Journalctl
Journalctl shows logs from systemd services. To list all services that have logged messages, run journalctl --list-boots or journalctl -F _SYSTEMD_UNIT. This is not a direct service list but can reveal which services are active.
Using Chkconfig For SysVinit
On older Red Hat-based systems, chkconfig --list shows all services and their runlevel states. This command is deprecated but still found on CentOS 6 and similar. It displays enabled/disabled status for each runlevel.
Listing Services With Systemctl List-dependencies
To see which services depend on a specific service, use systemctl list-dependencies <service-name>. For example, systemctl list-dependencies sshd shows all units that must be started before sshd. This is useful for debugging startup issues.
Filtering By State
You can combine systemctl list-units with state filters like --state=enabled, --state=disabled, --state=active, or --state=failed. For example, systemctl list-units --type=service --state=failed shows only failed services. This helps quickly identify problems.
Using Grep With Systemctl
Pipe the output of systemctl list-units to grep to search for specific services. For example, systemctl list-units --type=service | grep ssh finds all services with “ssh” in their name. This is faster than scrolling through long lists.
Listing Services With Lsof
The lsof command lists open files. Services often hold open sockets or files. Run lsof -i -P -n | grep LISTEN to see which processes are listening on ports. This is another way to identify network services.
Using Systemctl Show
For detailed configuration of a service, use systemctl show <service-name>. This outputs all properties of the service unit, including dependencies, environment variables, and execution details. It is useful for advanced troubleshooting.
Listing Services With Find
You can search for service unit files in the filesystem. Run find /etc/systemd/system -name "*.service" to list custom service files. Run find /lib/systemd/system -name "*.service" to list default system services. This is a manual but effective method.
Using Systemctl List-sockets
Services that use socket activation can be listed with systemctl list-sockets. This shows all socket units and which services they trigger. Socket activation starts a service only when a connection is made, saving resources.
Listing Services With Systemctl List-timers
Timer units trigger services on a schedule. Run systemctl list-timers to see all active timers and the services they start. This is useful for cron-like tasks managed by systemd.
Using Systemctl Is-enabled
To check if a specific service is enabled at boot, use systemctl is-enabled <service-name>. It returns “enabled”, “disabled”, “static”, or “masked”. This is faster than grepping the full list.
Listing Services With Systemctl Is-active
To check if a service is currently running, use systemctl is-active <service-name>. It returns “active”, “inactive”, or “failed”. This is useful in scripts.
Using Systemctl List-unit-files With Grep
Combine systemctl list-unit-files --type=service with grep enabled to see only services that start at boot. For example, systemctl list-unit-files --type=service | grep enabled. This helps you audit which services are automatically started.
Listing Services With Systemctl List-units –All
Use systemctl list-units --all --type=service to see every service unit, including inactive and failed ones. This is the most comprehensive list, but it can be long. Pipe it to less for easier reading.
Using Systemctl Cat
To view the full unit file of a service, use systemctl cat <service-name>. This shows the configuration file contents, including [Unit], [Service], and [Install] sections. It is helpful for understanding how a service is configured.
Listing Services With Systemctl Help
Run systemctl -h or man systemctl to see all available options. This is a good reference for advanced filtering and formatting.
Using Systemctl List-dependencies –Reverse
To see which services depend on a given service, use systemctl list-dependencies --reverse <service-name>. This shows reverse dependencies, which is useful when you want to stop a service and need to know what else might break.
Listing Services With Systemctl List-jobs
If services are in the process of starting or stopping, use systemctl list-jobs to see pending jobs. This shows queued operations and their status.
Using Systemctl List-machines
On systems with containers, systemctl list-machines shows services running in different containers. This is useful for multi-container environments.
Listing Services With Systemctl List-units –Type=target
Targets are groups of services. Use systemctl list-units --type=target to see all targets. For example, multi-user.target includes most services. This helps understand the boot sequence.
Using Systemctl Get-default
To see the default target (runlevel), use systemctl get-default. This tells you which target the system boots into, which determines which services start automatically.
Listing Services With Systemctl Set-default
You can change the default target with systemctl set-default <target>. For example, systemctl set-default multi-user.target boots into text mode. This affects which services are enabled.
Using Systemctl Mask And Unmask
Masking a service prevents it from being started. Use systemctl mask <service-name> to disable it completely. Use systemctl unmask <service-name> to re-enable it. Masked services appear in the list with state “masked”.
Listing Services With Systemctl Enable And Disable
To enable a service at boot, use systemctl enable <service-name>. To disable, use systemctl disable <service-name>. These commands change the state shown in list-unit-files.
Using Systemctl Start, Stop, Restart
To control services immediately, use systemctl start <service-name>, systemctl stop <service-name>, or systemctl restart <service-name>. These commands do not change the enabled state.
Listing Services With Systemctl Reload
To reload a service’s configuration without restarting, use systemctl reload <service-name>. This works for services that support it, like nginx or apache.
Using Systemctl Daemon-reload
After modifying service unit files, run systemctl daemon-reload to reload the configuration. This is necessary for changes to take effect.
Listing Services With Systemctl Isolate
To switch to a different target, use systemctl isolate <target>. This stops all services not in the target and starts those that are. It is a powerful command that can change the system state.
Using Systemctl Poweroff, Reboot, Halt
These commands stop services and shut down the system. They are the proper way to manage system state.
Listing Services With Systemctl Emergency
In case of critical issues, boot into emergency mode with systemctl emergency. This starts only essential services for troubleshooting.
Using Systemctl Rescue
Rescue mode starts a minimal set of services. Use systemctl rescue to enter this mode for repairs.
Listing Services With Systemctl List-units –Type=service –State=exited
Some services exit after completing a task. Use systemctl list-units --type=service --state=exited to see them. This is useful for one-shot services.
Using Systemctl List-units –Type=service –State=dead
Services that have stopped are shown with state “dead”. Use systemctl list-units --type=service --state=dead to see them. This includes services that failed or were stopped manually.
Listing Services With Systemctl List-units –Type=service –State=auto
The “auto” state is not a real state; it is used for filtering. Use systemctl list-units --type=service --state=auto to see services that are automatically started. This is a shortcut for enabled services.
Using Systemctl List-units –Type=service –State=static
Static services cannot be enabled or disabled; they are always started if needed. Use systemctl list-units --type=service --state=static to see them. Examples include services like systemd-journald.
Listing Services With Systemctl List-units –Type=service –State=indirect
Indirect services are enabled but only start when triggered by another service. Use systemctl list-units --type=service --state=indirect to see them. This is rare but useful for socket-activated services.
Using Systemctl List-units –Type=service –State=generated
Generated services are created dynamically. Use systemctl list-units --type=service --state=generated to see them. These are often temporary.
Listing Services With Systemctl List-units –Type=service –State=transient
Transient services are created at runtime and disappear when stopped. Use systemctl list-units --type=service --state=transient to see them. Examples include services started by user sessions.
Using Systemctl List-units –Type=service –State=bad
Bad services have errors in their unit files. Use systemctl list-units --type=service --state=bad to see them. This helps identify misconfigured services.
Listing Services With Systemctl List-units –Type=service –State=error
Error state is similar to bad. Use systemctl list-units --type=service --state=error to see services with configuration errors.
Using Systemctl List-units –Type=service –State=inactive
Inactive services are not running but are loaded. Use systemctl list-units --type=service --state=inactive to see them. This includes