Linux Command Line Guide: Essential Commands for Developers
The command line is the developer's most powerful tool. Whether you're writing shell scripts, debugging a production server, processing log files, or automating deployment tasks, fluency at the command line multiplies your productivity. This guide covers the commands and concepts every developer needs.
File System Navigation
The essentials: pwd (print working directory), ls -la (list all files including hidden, with permissions), cd - (go back to previous directory), find . -name "*.log" -mtime -1 (find files modified in the last day), du -sh */ (disk usage per subdirectory), df -h (filesystem disk usage).
Text Processing: grep, sed, awk
grep -r "error" /var/log/ searches recursively. grep -i "error" file.log is case-insensitive. grep -v "debug" inverts — shows lines that DON'T match. Combine with our RegExp Tester to build your grep patterns interactively before using them in the terminal.
sed 's/old/new/g' file.txt replaces all occurrences. awk '{print $1, $3}' prints columns 1 and 3. awk '/ERROR/ {count++} END {print count}' counts error lines. These three tools handle 90% of log parsing tasks without writing a script.
Pipes and Redirection
Pipes (|) chain commands by sending stdout of one command as stdin of the next. Redirection operators: > (overwrite file), >> (append to file), 2> (redirect stderr), 2>&1 (merge stderr into stdout). Power combo: cat access.log | grep "404" | awk '{print $7}' | sort | uniq -c | sort -rn | head -20 — top 20 most-requested 404 URLs.
find . -name "*.tmp" | xargs rm deletes all .tmp files. Much faster than find -exec rm for large numbers of files.Process Management
ps aux lists all running processes. top / htop gives a real-time process monitor. kill PID sends SIGTERM (graceful shutdown); kill -9 PID sends SIGKILL (immediate termination — use as last resort). lsof -i :3000 shows what's using port 3000. nohup command & runs a command that survives terminal disconnect. screen and tmux provide persistent terminal sessions.
Networking Commands
curl -I https://tools.fun fetches just HTTP headers. curl -v shows the full request/response including TLS handshake. Use our cURL Converter to build complex curl commands interactively. wget -q -O - url fetches silently to stdout. netstat -tlnp / ss -tlnp shows listening TCP ports. traceroute / mtr traces the network path. dig domain.com queries DNS; dig +short gives just the IP.
File Permissions
Linux permissions have three sets for owner/group/others, each with read (4), write (2), execute (1). chmod 755 file sets rwxr-xr-x. chmod +x script.sh makes it executable. chown user:group file changes ownership. ls -la shows permissions as -rwxr-xr-x. The leading - is regular file; d is directory; l is symlink.
/tmp directory uses the sticky bit (1777) so only file owners can delete their own files. Understanding this matters when debugging shared filesystem permission issues.SSH and Remote Access
ssh user@host connects to a remote server. ssh -i ~/.ssh/key.pem user@host uses a specific private key. ssh -L 5432:localhost:5432 user@bastion creates a local port forward — useful for connecting to a database through a bastion host. scp file.txt user@host:/tmp/ copies files. rsync -avz src/ user@host:dest/ synchronises directories efficiently.
Useful One-Liners
history | grep "docker" — find recent docker commands. watch -n 2 "df -h" — refresh disk usage every 2 seconds. tail -f /var/log/app.log | grep --line-buffered "ERROR" — live-stream errors. base64 -d <<< "encoded-string" — decode Base64 in-line (or use our Base64 tool). date +%s — print current Unix timestamp (convert with our Timestamp Converter).