Managing system processes effectively requires administrators to monitor and control background services. When you need to list services in Ubuntu, multiple commands provide comprehensive visibility. This guide explains practical methods to check running processes.
Using the service Command to List Services in Ubuntu
The service command displays all system processes with their current status. Ubuntu systems before version 15 relied primarily on this command for process management.
Execute this command to view all processes:
service --status-all
The output shows three status indicators. Running processes display [+], stopped processes show [-], and processes without status commands show [?].
Filter the output to display only active processes:
service --status-all | grep '\[ + \]'
This command isolates running processes from the complete list. The service utility reads data from /etc/init.d directory.
How to Ubuntu List Services with systemctl
Ubuntu versions 15 and later use systemd for process management. The systemctl command provides detailed information about system processes and their states.
Display all active processes:
systemctl list-units --type=service
The command returns five columns of data. UNIT shows the process name, LOAD indicates whether systemd loaded the process, ACTIVE displays current operational status.
SUB reveals the low-level state, and DESCRIPTION provides process information. Modern Ubuntu installations rely on systemctl commands for comprehensive process control.
List Running Services on Ubuntu Systems
Administrators often need to view only currently running processes. The systemctl command filters processes by their operational state.
Display running processes specifically:
systemctl list-units --type=service --state=running
This filter excludes inactive and failed processes from the output. Running processes actively consume system resources and handle operational tasks.
Disable pagination for complete output:
systemctl --no-pager list-units --type=service
The –no-pager option prints the entire list without breaks. This proves useful when redirecting output to files or processing data with scripts.
Ubuntu List Services Including Inactive Units
Some processes remain loaded but inactive. Viewing all processes regardless of state helps identify disabled or failed processes.
Show all loaded processes:
systemctl list-units --type=service --all
The –all flag displays inactive processes alongside running ones. This command reveals processes that loaded during boot but stopped later.
View process unit files on disk:
systemctl list-unit-files --type=service
This command shows every process file available. The output includes enabled, disabled, masked, and static process files stored in system directories.
| Process State | Description | Action Required |
|---|---|---|
| active | Currently operational | Monitor regularly |
| inactive | Stopped but configured | Start if needed |
| failed | Encountered errors | Check logs immediately |
| enabled | Starts at boot | Review necessity |
| disabled | Manual start only | Enable if required |
Filter Services by State in Ubuntu
System administrators filter processes based on specific states. The –state option accepts multiple values for precise filtering.
Display failed processes only:
systemctl list-units --type=service --state=failed
Failed processes require immediate attention. These processes attempted to start but encountered errors that prevented normal operation.
Combine multiple state filters:
systemctl list-units --type=service --state=active,failed
This command shows both active and failed processes. Multiple states separated by commas allow flexible filtering options for different administrative needs.
Check Individual Process Status
Examining specific processes provides detailed operational information. The status command shows configuration details and recent log entries.
View complete process information:
systemctl status nginx.service
The output displays process ID, memory usage, active state, and recent log entries. This systemd functionality helps troubleshoot process issues quickly.
View Service Logs with journalctl
Process logs contain critical debugging information. Ubuntu stores process logs in the systemd journal for centralized management.
Display logs for specific processes:
journalctl -u apache2.service
The -u flag targets specific process logs. These logs show startup messages, errors, and operational events recorded by the process.
Follow logs in real-time:
journalctl -u nginx.service -f
The -f option streams new log entries as they occur. Real-time monitoring helps identify issues during process operation or system troubleshooting activities.
List Services by File Location
Process configuration files exist in specific system directories. Understanding file locations helps administrators modify process behavior.
System process files reside in /lib/systemd/system. Custom configurations belong in /etc/systemd/system, which takes precedence over default files.
View process file contents:
systemctl cat postgresql.service
This command displays the complete process configuration file. The output shows startup commands, dependencies, and operational parameters defined for the process.
Enable and Disable Services
Process startup configuration determines which processes launch at boot. Administrators enable necessary processes and disable unused ones.
Enable a process for automatic startup:
systemctl enable mysql.service
Disable a process from starting:
systemctl disable bluetooth.service
These commands create or remove symbolic links in system directories. Disabled processes remain available for manual starting but do not launch automatically.
Monitor Resource Usage with systemd-cgtop
Process resource consumption affects system performance. The systemd-cgtop utility displays real-time resource usage for all running processes.
Launch the resource monitor:
systemd-cgtop
The output shows CPU usage, memory consumption, and disk I/O per control group. This information helps identify resource-intensive processes that may require optimization.
Sort by CPU usage for quick identification of heavy processes. Understanding process management helps maintain system stability and performance.
Restart and Reload Services
Process configuration changes require restarting or reloading. These operations apply new settings without extended downtime.
Restart a process completely:
systemctl restart apache2.service
Reload configuration without restart:
systemctl reload nginx.service
The reload operation sends a signal to the process to re-read its configuration. Not all processes support reloading, in which case restart becomes necessary.
Mask and Unmask Services in Ubuntu
Masking prevents processes from starting under any circumstances. This operation creates a symbolic link to /dev/null for the process unit file.
Mask a process permanently:
systemctl mask cups.service
Unmask to allow starting again:
systemctl unmask cups.service
Masked processes cannot start manually or automatically. This provides stronger control than disabling alone. Administrators use masking for processes that must never run on specific systems.
Use Dependencies and Targets
Processes have dependencies on other processes or system targets. Understanding these relationships helps troubleshoot startup issues.
View process dependencies:
systemctl list-dependencies nginx.service
The output shows all processes and targets required before the specified process starts. Dependency chains explain why certain processes may not start when expected.
Check target unit status:
systemctl list-units --type=target
Target units group related processes together. The multi-user.target includes network processes, while graphical.target adds display manager processes. Using systemd timers allows scheduled process execution.
Analyze Boot Performance
Process startup time affects system boot duration. The systemd-analyze tool identifies slow-starting processes.
Display boot time statistics:
systemd-analyze blame
The command lists processes sorted by initialization time. Processes at the top consumed the most time during startup.
Generate visual timeline:
systemd-analyze plot > boot-timeline.svg
This creates a graphical representation of the boot process. The SVG file shows when each process started and how long initialization took.
FAQs
How do I list all services in Ubuntu?
Use the command systemctl list-units –type=service –all to display all processes including inactive ones. This shows every process systemd loaded during boot.
What is the difference between service and systemctl commands?
The service command works with older init systems, while systemctl controls systemd. Ubuntu versions 15 and later use systemd by default, making systemctl the primary tool.
How can I check if a specific service is running?
Run systemctl status process-name.service to view detailed information about any process. The output shows whether the process is active or inactive with recent logs.
Why are some services marked as failed?
Failed processes encountered errors during startup or operation. Check logs using journalctl -u process-name.service to identify the specific error that caused the failure.
Can I list services running on a specific port?
Use netstat -tulpn or ss -tulpn commands to show processes listening on network ports. These commands display port numbers alongside process names and PIDs.