Overview¶
Linux provides commands to monitor processes, manage system resources, and control services. These are essential for:
-
System monitoring
-
Performance tuning
-
Troubleshooting
-
Cybersecurity and incident response
Process Monitoring Commands¶
top — Real-Time Process Viewer¶
Explanation
-
Displays running processes in real time
-
Shows CPU usage, memory usage, and system load
Key Information Displayed¶
-
PID (Process ID)
-
User
-
CPU and memory usage
-
Running time
htop — Interactive Process Viewer¶
Explanation
-
Advanced version of
top -
User-friendly interface
-
Allows scrolling, searching, and killing processes interactively
free — Memory Usage¶
Explanation
-
Displays total, used, and free memory
-
-h→ human-readable format (MB/GB)
Example Output¶
ps — Process Snapshot¶
Explanation
- Displays a snapshot of all running processes
Breakdown¶
-
a→ all users -
u→ detailed format -
x→ include background processes
kill — Terminate Process¶
Example¶
Explanation
-
Sends a signal to terminate a process
-
Default signal is
SIGTERM(graceful stop)
Force Kill Process¶
Explanation
-
-9→ SIGKILL (forcefully terminates process) -
Use only if normal kill fails
Systemd — Service Management¶
systemctl — Control Services¶
Common Actions¶
| Action | Description |
|---|---|
| start | Start service |
| stop | Stop service |
| status | Show status |
| restart | Restart service |
| reload | Reload configuration |
Example¶
Check Service Status¶
Services at Startup¶
Check if Service is Enabled¶
Enable Service at Startup¶
Disable Service at Startup¶
Reload Systemd Configuration¶
Explanation
-
Reloads service configuration files
-
Required after modifying service files
System V — Legacy Service Management¶
service Command¶
Example¶
Available Actions¶
| Action | Description |
|---|---|
| start | Start service |
| stop | Stop service |
| status | Check status |
| restart | Restart service |
Practical Examples¶
Monitor System Processes¶
Check Memory Usage¶
Find and Kill Process¶
Manage Services¶
Important Notes¶
-
htopmay need installation (sudo apt install htop) -
Always verify PID before killing a process
-
Prefer
systemctloverservicein modern systems -
Use
kill -9only when necessary
Summary Table¶
| Command | Purpose |
|---|---|
top |
Real-time process monitoring |
htop |
Interactive process viewer |
free -h |
Memory usage |
ps aux |
Process snapshot |
kill |
Terminate process |
systemctl |
Manage services |
service |
Legacy service control |
Conclusion¶
Process and service management commands are essential for:
-
Monitoring system performance
-
Managing applications and services
-
Troubleshooting issues
Mastering these tools provides complete control over Linux system operations and is crucial for system administrators and cybersecurity professionals.