Linux pgrep Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Linux pgrep Guide
Complete beginner-friendly guide to pgrep on Linux, covering Arch Linux, CachyOS, and other distributions including finding processes by name, pattern matching, and process searching.
Table of Contents
Understanding pgrep
What is pgrep?
pgrep finds processes by name.
Uses:
- Find processes: Search for processes
- Pattern matching: Match process names
- Process search: Search running processes
- PID lookup: Get process IDs
Why it matters:
- Process finding: Find processes easily
- Pattern matching: Match multiple processes
- Process management: Manage processes
pgrep Basics
Find Process
Basic usage:
# Find process by name
pgrep process-name
# Returns PIDs
List Names
Show names:
# Show process names
pgrep -l process-name
# -l = list (shows name and PID)
Pattern Matching
Full Command Line
Match full command:
# Match full command line
pgrep -f "pattern"
# -f = full command line
Exact Match
Exact name:
# Exact match
pgrep -x process-name
# -x = exact match
Process Information
Count Processes
Count matches:
# Count processes
pgrep -c process-name
# -c = count (number of matches)
User Filter
Filter by user:
# Processes by user
pgrep -u username process-name
# -u = user
Troubleshooting
No Processes Found
Check pattern:
# Verify pattern
ps aux | grep process-name
# Check if process exists
Summary
This guide covered pgrep usage, process searching, and pattern matching for Arch Linux, CachyOS, and other distributions.
Next Steps
- pkill Guide - Kill by name
- ps Guide - Process listing
- Process Management - Process management
- pgrep Documentation:
man pgrep
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.