This guide shows you how to list Linux services using the systemctl command, which is the standard tool for managing services on systems running systemd (most modern distros like Ubuntu, Debian, Fedora, CentOS, and Arch). You’ll learn to view all services, filter by state (running, stopped, failed), and get useful details like whether a service starts at boot. No special permissions are needed just to list services, but you’ll need sudo for some variations.
What You’ll Need
- A Linux system with systemd (check with
ps -p 1– if it showssystemd, you’re good). - Access to a terminal (Ctrl+Alt+T on most desktops).
- Basic familiarity with the command line.
- For some commands (like listing failed services with full details), you may need sudo privileges.
Step-by-Step
- Open a terminal. On most Linux desktop environments, you can press
Ctrl+Alt+Tor search for “Terminal” in the applications menu. - List all services (default view). Run:
systemctl list-units --type=serviceThis shows all loaded service units, their state (active, inactive, failed), and a short description. The list is paginated; press
Spaceto scroll down andqto quit. - List all services, including ones not loaded. The default only shows loaded units. To see every service file on the system (including those not currently active), run:
systemctl list-unit-files --type=serviceThis shows the state of each service file (enabled, disabled, static, masked) which tells you if it starts at boot.
- Filter by state. You can combine with
--stateto show only services in a specific state. For example, to list only running services:systemctl list-units --type=service --state=runningFor failed services (useful for troubleshooting):
systemctl list-units --type=service --state=failedYou can also use
--state=exited(services that ran and finished),--state=dead, or--state=inactive. - List only enabled or disabled services. To see which services are enabled to start at boot, use:
systemctl list-unit-files --type=service --state=enabledFor disabled ones, replace
enabledwithdisabled. - Get more details with a custom output. If you need more columns (like the load state or the unit file path), use the
--output=option. For example, to get a full, machine-readable output:systemctl list-units --type=service --output=jsonOr to see everything including the description and load state:
systemctl list-units --type=service --all --output=json - Check a specific service. To see the status of one service (e.g., sshd), run:
systemctl status sshdThis shows whether it’s active, its PID, memory usage, and recent log lines.
- Use grep to filter. If you’re looking for a specific keyword, pipe the output to grep. For example, to find all services with “ssh” in the name:
systemctl list-units --type=service | grep ssh
Common Mistakes
- Forgetting
--type=service. Without it,systemctl list-unitsshows all unit types (services, sockets, timers, mounts, etc.), which can be overwhelming. - Using
service --status-allinstead. The oldservicecommand works on SysV init and may not show systemd services correctly. Stick withsystemctlon modern systems. - Confusing
list-unitswithlist-unit-files. The former shows currently loaded units; the latter shows all unit files on disk, even those not loaded. If a service isn’t inlist-unitsbut you know it exists, checklist-unit-files. - Not using
--allto see inactive services. By default,list-unitshides inactive units. Use--allto see every loaded unit, including those that are inactive. - Running without sudo when you need it. Listing services generally works without sudo, but some operations like
systemctl statuson a service you don’t own may show partial info. For full details, usesudo systemctl status.
Tips
- Use
--no-pagerto avoid the pager. If you want to pipe the output to a file or another command, add--no-pagerto prevent the pager from interfering, e.g.,systemctl list-units --type=service --no-pager. - Combine with
--plainfor cleaner output.--plainremoves the pager and the column headers, making it easier to parse in scripts. - Count services. To count how many services are running, use:
systemctl list-units --type=service --state=running --no-pager | wc -l(subtract 1 for the header line). - Watch the service state. The
LOADcolumn shows “loaded” if the unit file is loaded, “not-found” if missing. TheACTIVEcolumn shows “active” or “inactive”, andSUBgives more detail like “running” or “exited”. - Use
systemctl list-dependenciesto see what a service depends on. This helps understand why a service might not start.
Troubleshooting
“Failed to connect to bus: No such file or directory” – This usually means systemd is not running (e.g., you’re in a container or a very minimal environment). Try ps -p 1 to check. If PID 1 is not systemd, you can’t use systemctl; use the init system’s tools instead.
“Unit sshd.service could not be found.” – The service name might be different (e.g., ssh on some distros). Use systemctl list-unit-files | grep ssh to find the exact name.
Output is cut off or not showing all services. – Remember that list-units only shows loaded units. Use --all to see all loaded, or list-unit-files to see all files. Also, the pager may truncate lines; use --no-pager or increase terminal width.
“Failed to get properties: No such interface” – This can happen when using systemctl status on a service that is not a systemd service (e.g., a SysV init script). It’s rare; try systemctl list-units --type=service | grep <name> to see if it’s actually a service.
Permission denied when listing unit files. – Some unit files might be in read-only locations. Use sudo to get full access.
Frequently Asked Questions
How do I list all running services?
Run systemctl list-units --type=service --state=running. This shows only services that are currently active and running.
What’s the difference between list-units and list-unit-files?
list-units shows units that are currently loaded into memory (i.e., they’ve been started or are known to the system). list-unit-files shows every unit file on disk, regardless of whether it’s loaded. A service can be in the file list but not in the units list if it hasn’t been started.
How do I list services that are enabled at boot?
Use systemctl list-unit-files --type=service --state=enabled. This shows services with the “enabled” state, meaning they will start automatically at boot.
Can I list services without sudo?
Yes, listing services is generally a read-only operation and works without sudo. However, for some details like the full status of a service (including log lines), you may need sudo to see all information.
How do I list services alphabetically?
The default output is already sorted alphabetically by unit name. If you want to sort by another column, you can pipe to sort, but the default is usually fine.
Why do I see services with a state of “static”?
A “static” service cannot be enabled or disabled directly; it’s typically started by another service or event. For example, systemd-sysctl.service is static because it’s triggered by systemd itself.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Hard Drive Very Slow Suddenly? Fixes That Work
- Windows Insider: Check New Windows 10 Features
- Restore Pitted Chrome Sink Drain Surrounds
- Error Performing Query Error Facebook: Fixes
- WiFi Not Working on HTC 10? Solved
- Fix Windows 100% CPU Usage: 7 Real Fixes