Tracking Methods
ps Command
The ps
command provides comprehensive process tracking capabilities:
## List all processes
ps aux
## List processes for current user
ps u
## Display detailed process tree
ps -ef
Top and Htop Commands
## Real-time process monitoring
top
## Enhanced interactive process viewer
htop
Proc Filesystem Tracking
Exploring /proc Directory
## List running process directories
ls /proc | grep ^[0-9]
## Examine specific process details
cat /proc/1234/status
Process Tracking Methods
flowchart TD
A[Process Tracking] --> B[Command Line Tools]
A --> C[Filesystem Exploration]
A --> D[Kernel Interface]
B --> B1[ps]
B --> B2[top]
B --> B3[htop]
C --> C1[/proc filesystem]
C --> C2[Process Directories]
D --> D1[Signal Handling]
D --> D2[Process Monitoring APIs]
Advanced Tracking Techniques
Method |
Description |
Use Case |
strace |
Trace system calls |
Debugging |
pgrep |
Search processes by name |
Quick filtering |
pidof |
Find process ID |
Scripting |
Practical Tracking Script
#!/bin/bash
## Process tracking script for LabEx environments
## Find processes by name
find_process() {
pgrep -l $1
}
## Monitor specific process
track_process() {
ps -p $1 -f
}
## Example usage
find_process sshd
track_process 1234
Signal-Based Tracking
Processes can be tracked and managed using signals:
## Send monitoring signals
kill -0 1234 ## Check process existence
killall -l ## List available signals
By mastering these tracking methods, users can effectively monitor and manage processes in Linux systems.