# PipeCraft: Linux CLI & Log Analytics Cheat Sheet

Core commands for managing headless cloud servers, processing log data, and scheduling ETL cron pipelines.

---

## 🔍 1. Log Filtering & Processing

### `grep -i "error" server.log -C 3`
* **What it does:** Searches for the string "error" (case-insensitive) inside `server.log`, extracting the matching line along with 3 lines of context before and after it.

### `awk '{print $1, $7}' access.log | sort | uniq -c`
* **What it does:**
  - `awk` extracts the 1st column (IP address) and 7th column (URL path) of `access.log`.
  - `sort` organizes the output.
  - `uniq -c` counts the occurrences of duplicate lines.
* **Why it's used:** Quickly calculate access counts per IP for website logs.

### `sed -i 's/db_port=5432/db_port=6432/g' env.config`
* **What it does:** Replaces every occurrence of "db_port=5432" with "db_port=6432" directly inside the file `env.config`.

---

## 🔒 2. File Permissions & Job Scheduling

### `chmod +x /opt/pipecraft/ingest.sh`
* **What it does:** Adds the execution permission flag (`+x`) to the script, allowing it to run as an executable application.

### `crontab -e`
* **What it does:** Opens the Cron job configurations file.
* **Crontab syntax example:** `0 0 * * * /opt/pipecraft/ingest.sh` runs the ingestion script daily at midnight.

### `df -h` & `du -sh *`
* **df -h:** Displays the total disk storage space available and consumed on all mounted partitions.
* **du -sh *:** Displays the size summaries of all files and folders in the current directory.