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#

  1. Process Management
  2. Network & Traffic Analysis
  3. File Operations
  4. Text Processing
  5. Git Operations
  6. Package Management
  7. Debugging & Inspection
  8. Chaining Commands
  9. Common Patterns

Process Management#

Finding Running Processes#

bash
bash
bash
bash

Killing Processes#

bash
bash

Port Usage#

bash
bash

Network & Traffic Analysis#

Network Capture with tcpdump#

bash
bash
bash
bash

Network Diagnostics#

bash
bash

Service Discovery (mDNS)#

bash
bash

File Operations#

Finding Files#

bash
bash

File Information#

bash
bash

File Content#

bash
bash

Text Processing#

bash
bash

Sed (Stream Editor)#

bash
bash

Awk (Text Processing)#

bash
bash

Cut (Column Extraction)#

bash
bash

Sort and Unique#

bash
bash

Git Operations#

Status and Information#

bash
bash

Making Changes#

bash
bash

Viewing Changes#

bash
bash

Branches#

bash
bash

Remote Operations#

bash
bash

Package Management#

npm (Node.js)#

bash
bash

Homebrew (macOS)#

bash
bash

Debugging & Inspection#

Checking File Types#

bash
bash

Binary File Inspection#

bash
bash

System Information#

bash
bash

Environment Variables#

bash
bash

Chaining Commands#

Pipes and Redirection#

bash
bash

Redirection#

bash
bash

Command Chaining#

bash
bash

Subcommands#

bash
bash

Common Patterns#

Loops in Shell#

bash
bash

Conditionals#

bash
bash

Functions#

bash
bash

Error Handling#

bash
bash

One-Liners#

bash
bash

Working with JSON#

bash
bash

Parallel Processing#

bash
bash

Keyboard Shortcuts#

Terminal Navigation#

text

History#

bash
bash

Useful Aliases#

Add these to your ~/.zshrc or ~/.bashrc:

bash
bash

Tips and Tricks#

1. Command Substitution#

bash
bash

2. Brace Expansion#

bash
bash

3. Parameter Expansion#

bash
bash

4. Here Documents#

bash
bash

5. Quick File Edits#

bash
bash

Resources for Learning More#

Man Pages (Manual)#

bash
bash

Command Help#

bash
bash

Online 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
bash

This guide covers the most useful shell commands and patterns. The key to mastering the terminal is:

  1. Start small - Learn one command at a time
  2. Use tab completion - It's your friend!
  3. Read error messages - They usually tell you exactly what's wrong
  4. Experiment safely - Use test directories
  5. Build gradually - Combine simple commands into complex pipelines

Happy shell scripting! 🚀

Viewing as guest

Shell Commands & Patterns Guide | Knowledgebase