Process Filtering Methods
Basic Process Name Filtering
pkill
supports multiple filtering methods to target specific processes:
## Kill all processes with name "firefox"
pkill firefox
## Case-sensitive matching
pkill -c Firefox
Advanced Filtering Options
By User
## Kill processes owned by a specific user
pkill -u username
By Process Group
## Kill processes in a specific process group
pkill -g groupid
Filtering Criteria
Filtering Option |
Description |
Example |
-u |
Filter by user |
pkill -u john |
-g |
Filter by process group |
pkill -g 1000 |
-P |
Filter by parent process ID |
pkill -P 1234 |
-t |
Filter by terminal |
pkill -t pts/1 |
Complex Filtering Techniques
graph TD
A[Process Filtering] --> B{Matching Criteria}
B --> |Name| C[Basic Name Matching]
B --> |User| D[User-based Filtering]
B --> |Advanced| E[Multiple Criteria Combination]
C --> F[Precise Process Targeting]
D --> F
E --> F
Regex and Pattern Matching
## Use regex for advanced matching
pkill -f "python.*script"
## Match processes starting with specific pattern
pkill ^nginx
Signal Sending with Filtering
## Send specific signals during process termination
pkill -SIGTERM firefox
pkill -9 chrome ## Force kill
Best Practices
- Always verify process selection before termination
- Use
-n
flag to list matched processes without killing
- Combine multiple filtering criteria for precise targeting
In LabEx environments, these filtering methods provide powerful process management capabilities for developers and system administrators.