Shell Commands & Patterns Guide
Updated: 1/15/2025Category: general
cliworkflow
Shell Commands & Patterns Guide#
A comprehensive guide to terminal commands and patterns demonstrated during this project.
Table of Contents#
- Process Management
- Network & Traffic Analysis
- File Operations
- Text Processing
- Git Operations
- Package Management
- Debugging & Inspection
- Chaining Commands
- Common Patterns
Process Management#
Finding Running Processes#
bash
bashbash
bashKilling Processes#
bash
bashPort Usage#
bash
bashNetwork & Traffic Analysis#
Network Capture with tcpdump#
bash
bashbash
bashNetwork Diagnostics#
bash
bashService Discovery (mDNS)#
bash
bashFile Operations#
Finding Files#
bash
bashFile Information#
bash
bashFile Content#
bash
bashText Processing#
Grep (Search)#
bash
bashSed (Stream Editor)#
bash
bashAwk (Text Processing)#
bash
bashCut (Column Extraction)#
bash
bashSort and Unique#
bash
bashGit Operations#
Status and Information#
bash
bashMaking Changes#
bash
bashViewing Changes#
bash
bashBranches#
bash
bashRemote Operations#
bash
bashPackage Management#
npm (Node.js)#
bash
bashHomebrew (macOS)#
bash
bashDebugging & Inspection#
Checking File Types#
bash
bashBinary File Inspection#
bash
bashSystem Information#
bash
bashEnvironment Variables#
bash
bashChaining Commands#
Pipes and Redirection#
bash
bashRedirection#
bash
bashCommand Chaining#
bash
bashSubcommands#
bash
bashCommon Patterns#
Loops in Shell#
bash
bashConditionals#
bash
bashFunctions#
bash
bashError Handling#
bash
bashOne-Liners#
bash
bashWorking with JSON#
bash
bashParallel Processing#
bash
bashKeyboard Shortcuts#
Terminal Navigation#
textHistory#
bash
bashUseful Aliases#
Add these to your ~/.zshrc or ~/.bashrc:
bash
bashTips and Tricks#
1. Command Substitution#
bash
bash2. Brace Expansion#
bash
bash3. Parameter Expansion#
bash
bash4. Here Documents#
bash
bash5. Quick File Edits#
bash
bashResources for Learning More#
Man Pages (Manual)#
bash
bashCommand Help#
bash
bashOnline Resources#
- explainshell.com - Explains shell commands visually
- tldr.sh - Simplified man pages (install with: npm install -g tldr)
- ShellCheck - Shell script linter (shellcheck.net)
Practice#
- cmdchallenge.com - Shell command challenges
- overthewire.org/wargames/bandit - Learn through games
Debugging Shell Scripts#
bash
bashThis guide covers the most useful shell commands and patterns. The key to mastering the terminal is:
- Start small - Learn one command at a time
- Use tab completion - It's your friend!
- Read error messages - They usually tell you exactly what's wrong
- Experiment safely - Use test directories
- Build gradually - Combine simple commands into complex pipelines
Happy shell scripting! 🚀