15 Essential Linux One-Liners for Developers
TL;DR
Master these 15 Linux command combinations to handle logs, find files, process data, and monitor systems like a pro. Copy-paste ready with explanations.
I've been using Linux for development for over a decade, and these are the command combinations I find myself typing almost daily. No theory, no academic bullshit - just the stuff that actually makes my life easier.
Most of these I learned the hard way, usually at 2 AM when something was on fire and I needed answers fast.
The "Oh Shit, My Disk is Full" Commands
1. Find what's eating all your space
du -ah / | sort -hr | head -20
I probably run this once a week. Nothing like discovering your Docker containers have consumed 50GB when you're trying to deploy something urgent. The -h flag makes the output human-readable, and sorting by size puts the biggest offenders first.
2. Clean up old log files before they kill your server
find /var/log -name "*.log" -mtime +7 -delete
This deletes log files older than 7 days. I've seen too many servers die because someone forgot to rotate logs and they filled up the entire disk. Adjust the number based on how paranoid you are about keeping logs.
3. Find your biggest files quickly
find . -type f -exec ls -lh {} \; | sort -k 5 -hr | head -10
When you need to find the file that's hogging space right now. Way faster than opening a file manager and clicking around like a caveman.
Text Processing That Actually Works
4. Pull email addresses from any mess of files
grep -rho '\b[A-Za-z0-9._%+-]\+@[A-Za-z0-9.-]\+\.[A-Za-z]\{2,\}\b' . | sort -u
I've used this to extract emails from old backups, log files, and random text dumps more times than I can count. The regex isn't perfect, but it catches 99% of real email addresses.
5. Count lines of code (because managers love numbers)
find . -name "*.js" -o -name "*.py" -o -name "*.go" | xargs wc -l | tail -1
Replace the file extensions with whatever languages you're using. I usually add this to projects as a Makefile target so I can run make stats and look productive.
6. Search and replace across your entire project
find . -name "*.js" -exec sed -i 's/oldFunctionName/newFunctionName/g' {} +
This is basically "find and replace" for the command line. Way faster than doing it in your editor, especially for large codebases. Just be careful - there's no undo button.
7. Convert CSV to JSON when you're too lazy to write a script
python3 -c "import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))" < data.csv
This one-liner has saved me from writing throwaway Python scripts countless times. Pipe it to jq if you want pretty formatting: | jq .
System Monitoring for Paranoids
8. Watch your logs for problems in real-time
tail -f /var/log/app.log | grep --line-buffered -E "(ERROR|WARN|FATAL)" --color=always
I usually have this running in a terminal tab during deployments. Nothing beats seeing errors as they happen instead of discovering them hours later.
9. Find what's killing your CPU
ps aux | sort -nr -k 3 | head -5
Quick and dirty way to see what's using your CPU. Way faster than opening top or htop when you just need a quick check.
10. Count active connections to your web server
ss -tuln | grep :80 | wc -l
Useful for checking if you're getting DDoSed or if your app is actually handling traffic. Replace 80 with whatever port you're using.
Git Commands That Don't Suck
11. See who's actually working on the project
git shortlog -sn --all --no-merges | head -10
Great for figuring out who to blame when something breaks. Also useful for performance reviews and understanding team dynamics.
12. Find all your TODOs before the code review
find . -name "*.js" -o -name "*.py" -o -name "*.go" | xargs grep -n "TODO\|FIXME\|XXX\|HACK"
Nothing worse than having a reviewer find your lazy "TODO: fix this shit later" comments. Run this before every PR.
The "Emergency" Commands
13. Kill processes by name when they're misbehaving
pkill -f "node.*server.js"
When Ctrl+C isn't enough and you need to nuke specific processes. The -f flag matches the full command line, not just the process name.
14. Download and extract in one go
curl -sL https://releases.example.com/latest.tar.gz | tar -xz -C /opt/
No temporary files, no extra steps. Download, extract, done. I use this constantly for installing tools that don't have package managers.
15. Generate a decent password when you're in a hurry
openssl rand -base64 32 | tr -d "=+/" | cut -c1-16
Creates a 16-character password with letters and numbers. Not as secure as a proper password manager, but perfect for temporary accounts or development databases.
Bonus Commands I Actually Use
Check if your SSL cert is about to expire
echo | openssl s_client -connect yoursite.com:443 2>/dev/null | openssl x509 -noout -dates
Saved me from several "why is the site broken?" incidents.
Create project directories like a boss
mkdir -p project/{src,tests,docs,config}/{js,css,components}
Sets up a complete project structure in one command. Way better than clicking around in file managers.
Archive with today's date
tar -czf backup-$(date +%Y%m%d).tar.gz /important/stuff
Perfect for daily backups or creating release archives.
How I Actually Use These
I don't memorize them all. I keep the ones I use most in my shell history (searchable with Ctrl+R) and the rest in a text file on my desktop.
I test destructive commands first. Before running anything with rm or delete, I replace it with echo to see what would happen:
# Test first
find . -name "*.log" -mtime +7 -exec echo "would delete: {}" \;
# Then run for real
find . -name "*.log" -mtime +7 -delete
I make aliases for the ones I use daily:
# Add these to your ~/.bashrc
alias ll='ls -la'
alias space='du -sh * | sort -hr'
alias ports='ss -tuln'
The Real Talk
These commands aren't magic. They're just combinations of basic Unix tools that happen to solve common problems. The best way to learn them is to start with simple versions and gradually add complexity.
Don't try to memorize everything at once. Pick 3-4 that solve problems you actually have, use them until they become muscle memory, then add more.
And remember: if a one-liner gets too complex or you're using it regularly, turn it into a proper script with error handling. Your future self will thank you.
These commands work on most Linux distributions and macOS. Some flags might vary slightly between systems, so check your man pages if something doesn't work.