Linux Commands Reference
Ask in plain English. Like "how to create user" or "check disk space".
Essential Linux Commands for DevOps
Linux command-line proficiency is the foundation of DevOps, SRE, and cloud engineering. Whether you are SSH-ing into production servers, writing shell scripts for automation, debugging containerized applications, or managing Kubernetes nodes, the Linux CLI is your primary interface for system interaction.
This reference covers the commands DevOps engineers use most frequently in real production environments, organized by task rather than alphabetically.
File Management Commands
| Command | What It Does | Production Example |
|---|---|---|
ls -la | List all files with permissions and hidden files | ls -la /etc/nginx/sites-enabled/ |
find | Search for files with complex filters | find /var/log -name '*.log' -mtime +30 -delete |
cp -r | Copy files and directories recursively | cp -r /app/config /app/config.bak |
chmod | Change file permissions | chmod 600 ~/.ssh/id_rsa |
tar -czf | Create compressed archive | tar -czf backup.tar.gz --exclude='.git' /app/ |
tail -f | Follow file output in real-time | tail -f /var/log/app/error.log | grep Exception |
Process Management Commands
| Command | What It Does | Production Example |
|---|---|---|
ps aux | Show all running processes with resource usage | ps aux --sort=-%mem | head -15 |
top -bn1 | One-shot system resource snapshot | top -bn1 -o %MEM | head -15 |
kill -9 | Force terminate a process | kill -9 $(lsof -t -i:8080) |
lsof -i | List processes using network ports | lsof -i :443 -sTCP:LISTEN |
systemctl | Manage system services | systemctl restart nginx && systemctl status nginx |
Network Troubleshooting Commands
| Command | What It Does | Production Example |
|---|---|---|
curl -I | Fetch HTTP headers from a URL | curl -sI https://api.example.com/health |
ss -tlnp | Show listening TCP ports with process names | ss -tlnp | grep :443 |
dig | DNS lookup and resolution testing | dig +short A api.example.com @8.8.8.8 |
traceroute | Trace packet path to destination | traceroute -n api.example.com |
tcpdump | Capture and analyze network packets | tcpdump -i eth0 port 443 -c 100 |
Disk and Storage Commands
| Command | What It Does | Production Example |
|---|---|---|
df -hT | Show disk usage with filesystem type | df -hT | grep -v tmpfs |
du -sh | Show directory size summary | du -sh /var/lib/docker/* | sort -rh | head |
df -i | Check inode usage | df -i / | awk 'NR==2' |
mount | Show mounted filesystems | mount | grep -E '^/dev' | column -t |
Frequently Asked Questions
What are the most used Linux commands for DevOps engineers?
The most essential Linux commands for DevOps include: ls (list files), grep (search text), find (locate files), ps and top (monitor processes), df and du (check disk usage), curl and ss (network diagnostics), chmod and chown (permissions), systemctl (service management), tail -f (log monitoring), and tar (archiving). These commands form the daily toolkit for server administration, troubleshooting, and automation.
How do you check disk space in Linux?
Use df -hT to see filesystem usage in human-readable format with filesystem type. To find which directories consume the most space, use du -sh /* | sort -rh | head -20. For Docker-specific disk usage, check docker system df. If disk shows full but files were deleted, run lsof +D /partition | grep deleted to find processes holding the space.
How to find which process is using a specific port in Linux?
Run lsof -i :8080 or ss -tlnp | grep 8080 to identify which process is bound to port 8080. To kill the process occupying the port, use kill -9 $(lsof -t -i:8080). The ss command is faster than netstat on modern Linux systems and shows both listening and established connections.
How to monitor Linux server performance in real-time?
Use top or htop for real-time CPU and memory monitoring. For a one-shot snapshot suitable for scripting, use top -bn1 | head -20. Monitor disk I/O with iostat -x 1, network throughput with iftop, and system load with uptime. Combine these for production incident investigation.
How to search for text inside files recursively in Linux?
Use grep -rn 'ERROR' /var/log/ to recursively search for "ERROR" in all files under /var/log with line numbers. For faster searching in large codebases, use grep -rn --include='*.log' 'pattern' /path/ to limit by file extension. The -C 3 flag shows 3 lines of context around each match for better debugging.