Linux Commands Every DevOps Engineer Must Know
Linux is the backbone of modern infrastructure. Whether you're SSHing into a server, debugging a container, or writing a shell script, these commands are essential.
File System Navigation
pwd # Print working directory
ls -la # List all files with details
cd /var/log # Change directory
tree -L 2 # Show directory tree (2 levels)
find / -name "*.log" -mtime -1 # Files modified in last 24h
du -sh /var/* # Disk usage per directory
df -h # Disk space on all mounts
Text Processing
These are your bread and butter for parsing logs and config files:
# Search with grep
grep -r "ERROR" /var/log/
grep -c "404" access.log # Count matches
grep -i "timeout" app.log # Case-insensitive
# Stream processing with awk
awk '{print $1, $9}' access.log # Print IP and status code
awk -F: '{print $1}' /etc/passwd # Custom delimiter
# Transform with sed
sed -i 's/old/new/g' config.txt # In-place find & replace
sed -n '10,20p' logfile.txt # Print lines 10-20
# Sort and deduplicate
sort access.log | uniq -c | sort -rn | head -20
Process Management
ps aux # All running processes
ps aux | grep nginx # Find specific process
top # Real-time process viewer
htop # Better top (if installed)
kill -15 <pid> # Graceful shutdown
kill -9 <pid> # Force kill
systemctl status nginx # Service status (systemd)
systemctl restart nginx # Restart service
journalctl -u nginx -f # Follow service logs
Networking
ip addr show # Show IP addresses
ss -tulnp # Show listening ports
curl -I https://example.com # HTTP headers only
curl -v https://example.com # Verbose HTTP request
wget -q -O - https://example.com/health # Simple health check
dig example.com # DNS lookup
nslookup example.com # Alternative DNS lookup
traceroute example.com # Network path tracing
netstat -rn # Routing table
Permissions and Users
chmod 755 script.sh # rwxr-xr-x
chmod +x deploy.sh # Add execute permission
chown -R www-data:www-data /var/www # Change ownership
whoami # Current user
id # User and group info
sudo -u postgres psql # Run command as another user
Archives and Compression
tar -czf backup.tar.gz /data # Create compressed archive
tar -xzf backup.tar.gz # Extract archive
tar -tzf backup.tar.gz # List contents
zip -r archive.zip folder/ # Create zip
System Information
uname -a # Kernel info
cat /etc/os-release # OS details
free -h # Memory usage
uptime # System uptime and load
lscpu # CPU information
Useful One-Liners
# Watch a log file in real-time
tail -f /var/log/syslog
# Find the 10 largest files
find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -10
# Check which process is using a port
lsof -i :8080
# Test if a port is open
nc -zv hostname 443
# Base64 encode/decode (useful for K8s secrets)
echo -n "mypassword" | base64
echo "bXlwYXNzd29yZA==" | base64 -d
Spend time practicing these in a sandbox. Muscle memory with Linux commands will save you hours during incident response.
Enjoyed this article?
Get more DevOps insights delivered to your inbox.
Get new posts by email
Subscribe to get an email when a new blog post is published. Skip anytime.
No spam, unsubscribe anytime.
Written by
Priya Kapoor
Tech enthusiast and creative writer sharing insights on modern development.
View all postsDiscussion
0 comments
Sign in to join the conversation.
Be the first to comment
Start a conversation about this post
