You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
List all files (incl. hidden), human-readable sizes
cd -
Jump back to previous directory
find . -name "*.csv" -type f
Recursively find files by pattern
du -sh ./dir
Disk usage of a directory, human-readable
stat file.txt
File metadata (size, permissions, timestamps)
tree -L 2
Visual directory tree, 2 levels deep
ln -s /path/to/target link_name
Create a symlink
π Redirection & Piping
Command
What it does
cmd > file.txt
Redirect stdout to file (overwrites)
cmd >> file.txt
Append stdout to file
cmd 2> err.log
Redirect stderr only to file
cmd 2>&1
Merge stderr into stdout
cmd > file.txt 2>&1
Redirect both stdout + stderr to file
cmd1 | cmd2
Pipe stdout of cmd1 into cmd2
cmd | tee file.txt
Pipe stdout AND write to file simultaneously
cmd < input.txt
Feed file as stdin to command
β οΈ Order matters: > file 2>&1 β vs 2>&1 > file β (stderr stays on terminal)
π¬ Deep dive: 2>&1 explained
Part
Meaning
2
File descriptor for stderr
>
Redirection operator
&1
"The destination of file descriptor stdout"
Anatomy:2>&1 tells the shell β "send stderr to wherever stdout is currently pointing."
# β Correct β redirect stdout to file first, then attach stderr to it
npm run build > build.log 2>&1# β Pipe both stdout + stderr into grep
npm run build 2>&1| grep error
# β Wrong β stderr binds to terminal (old stdout), then stdout moves to file
npm run build 2>&1> build.log
The & before 1 is critical β without it, the shell interprets >1 as "redirect to a file named 1".
βοΈ Process Management
Command
What it does
ps aux
List all running processes
ps aux | grep python
Filter processes by name
top / htop
Live process monitor (htop is prettier)
kill -9 <PID>
Force kill process by PID
pkill -f "script_name"
Kill process by name match
cmd &
Run command in background
jobs
List background jobs in current shell
fg %1
Bring background job 1 to foreground
nohup cmd &
Run in background, survives terminal close
Ctrl+Z β bg
Suspend foreground job, resume in background
lsof -i :8080
See what's using port 8080
π Data Wrangling (grep, awk, sed, cut)
grep β search text
Command
What it does
grep "pattern" file.txt
Search for pattern in file
grep -r "pattern" ./dir
Recursive search in directory
grep -i "pattern" file
Case-insensitive search
grep -n "pattern" file
Show line numbers
grep -v "pattern" file
Invert match (exclude pattern)
grep -E "err|warn" file
Extended regex (OR match)
grep -c "pattern" file
Count matching lines
awk β column/field processing
Command
What it does
awk '{print $1}' file
Print first column (space-delimited)
awk -F',' '{print $2}' file.csv
Print second column (comma-delimited)
awk 'NR>1' file
Skip header row
awk '$3 > 100' file
Filter rows where col 3 > 100
awk '{sum+=$2} END {print sum}' file
Sum values in column 2
sed β stream editor / find-replace
Command
What it does
sed 's/old/new/' file
Replace first occurrence per line
sed 's/old/new/g' file
Replace all occurrences per line
sed -i 's/old/new/g' file
In-place edit (modifies file directly)
sed -n '5,10p' file
Print lines 5 to 10
sed '/pattern/d' file
Delete lines matching pattern
cut β slice columns
Command
What it does
cut -d',' -f1,3 file.csv
Extract columns 1 and 3 (comma delimiter)
cut -c1-10 file
Extract characters 1β10 from each line
Bonus combos
# Count unique values in CSV column 2
cut -d',' -f2 data.csv | sort | uniq -c | sort -rn
# Extract error lines and save
grep -i "error" app.log | awk '{print $1, $2, $NF}'> errors.txt
# Replace env var in config, in-place
sed -i 's/DB_HOST=localhost/DB_HOST=prod-db/g' .env
π Networking & curl
Command
What it does
curl -X GET "https://api.example.com"
Basic GET request
curl -X POST -H "Content-Type: application/json" -d '{"key":"val"}' URL
POST with JSON body
curl -H "Authorization: Bearer $TOKEN" URL
Authenticated request
curl -o file.json URL
Save response to file
curl -s URL
Silent mode (no progress bar)
curl -v URL
Verbose (shows headers, handshake)
curl -L URL
Follow redirects
curl -w "%{http_code}" -o /dev/null -s URL
Print HTTP status code only
wget -q URL -O output.file
Download file quietly
ping -c 4 google.com
Test connectivity (4 packets)
netstat -tulpn / ss -tulpn
List open ports and listeners
π Git CLI
Setup & status
Command
What it does
git status
Working tree status
git log --oneline --graph --all
Compact visual branch history
git diff
Unstaged changes
git diff --staged
Staged changes
Branching
Command
What it does
git checkout -b feature/name
Create + switch to new branch
git branch -d branch_name
Delete local branch (safe)
git branch -D branch_name
Force delete local branch
git push origin --delete branch_name
Delete remote branch
git fetch --prune
Sync remote branches, prune deleted
Staging & committing
Command
What it does
git add -p
Interactively stage hunks
git commit --amend --no-edit
Add to last commit without changing message
git reset HEAD~1
Undo last commit, keep changes staged
git reset --hard HEAD~1
β οΈ Undo last commit, discard changes
Stashing
Command
What it does
git stash push -m "wip: feature"
Stash with label
git stash list
List all stashes
git stash pop
Apply latest stash + drop it
git stash apply stash@{2}
Apply specific stash, keep it
Remote & sync
Command
What it does
git pull --rebase
Pull and rebase local commits on top
git push -u origin branch_name
Push + set upstream tracking
git remote -v
Show remote URLs
git cherry-pick <SHA>
Apply a specific commit to current branch
Inspection & recovery
Command
What it does
git blame file.py
Show who changed each line
git bisect start
Binary search for bug-introducing commit
git reflog
Full history of HEAD movements (lifesaver)
git show <SHA>
Show diff + metadata of a commit
Generated for a Fellow-level Analytics & Data Engineering workflow.