Linux Process and Service Management
Managing Processes and Services
Linux Process and Service Management
Introduction
This article provides a basic overview of managing processes and services in Linux. We will cover common commands for viewing running processes and managing system services.
Viewing Running Processes
ps
The ps
command is used to display information about currently running processes. It has numerous options; here's a basic example:
ps aux
This will show a comprehensive list of processes.
top
The top
command provides a dynamic, real-time view of running processes. It continuously updates the list, showing CPU and memory usage.
top
Press q
to exit top
.
top
to sort processes by CPU usage, memory usage, etc.Managing Services
systemctl
systemctl
is the primary command for managing services in systemd-based systems (most modern Linux distributions). To list all services:
systemctl list-units
To start a service (replace myservice
with the actual service name):
systemctl start myservice
To stop a service:
systemctl stop myservice
service
In older init systems (like SysVinit), the service
command is used. However, systemctl
is generally preferred on modern systems.
service myservice start
service myservice stop
service
on systemd systems is generally discouraged in favor of systemctl
.Summary
- Use
ps
for a snapshot of running processes. - Use
top
for a dynamic view of processes. - Use
systemctl
to manage services in most modern Linux distributions. - Avoid using
service
on systemd systems.