As a DevOps engineer, your effectiveness depends heavily on your command-line proficiency. While GUIs have their place, the terminal remains the most powerful tool for system administration, automation, and troubleshooting. Here are the 50 essential Linux commands every DevOps professional must master.
File and Directory Management
Navigation and Listing
# List files with details
ls -la
# Change directory
cd /var/log
# Print working directory
pwd
# Find files by name
find /home -name "*.log" -type f
# Locate files quickly (requires updatedb)
locate nginx.conf
File Operations
# Copy files and directories
cp -r source/ destination/
# Move or rename
mv oldname.txt newname.txt
# Remove files (use with caution!)
rm -rf directory/
# Create directories recursively
mkdir -p /path/to/nested/directory
# Change file permissions
chmod 755 script.sh
# Change ownership
chown user:group file.txt
Text Processing and Searching
Essential Text Commands
# View file contents
cat /etc/hosts
# Page through large files
less /var/log/syslog
# View first/last lines
head -n 20 file.txt
tail -f /var/log/nginx/access.log
# Search within files
grep -r "error" /var/log/
# Count lines, words, bytes
wc -l file.txt
# Sort and remove duplicates
sort file.txt | uniq
Advanced Text Processing
# Stream editor for transformations
sed 's/old/new/g' file.txt
# Pattern scanning and processing
awk '{print $1, $3}' file.txt
# Compare files
diff file1.txt file2.txt
Process Management
# List running processes
ps aux | grep nginx
# Real-time process monitoring
top
htop # Enhanced version
# Kill processes
kill -9 PID
killall process_name
pkill -f "pattern"
# Run in background
command &
nohup command &
# Job control
jobs
fg %1
bg %1
System Monitoring
# Disk usage
df -h
du -sh /var/*
# Memory usage
free -h
# System uptime and load
uptime
# Who is logged in
who
w
# System information
uname -a
hostnamectl
Networking Commands
# Test connectivity
ping -c 4 google.com
# DNS lookup
nslookup domain.com
dig domain.com
# Check open ports
netstat -tulpn
ss -tulpn
# Download files
curl -O https://example.com/file.zip
wget https://example.com/file.zip
# Network interface config
ip addr show
ip route show
# Trace route to host
traceroute google.com
Package Management
Debian/Ubuntu (apt)
apt update && apt upgrade -y
apt install package-name
apt remove package-name
apt search keyword
RHEL/CentOS (yum/dnf)
dnf update -y
dnf install package-name
dnf remove package-name
dnf search keyword
Service Management (systemd)
# Start/stop/restart services
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
# Enable/disable at boot
systemctl enable nginx
systemctl disable nginx
# Check status
systemctl status nginx
# View logs
journalctl -u nginx -f
SSH and Remote Operations
# Connect to remote server
ssh user@hostname
# Copy files remotely
scp file.txt user@host:/path/
rsync -avz source/ user@host:/destination/
# SSH key generation
ssh-keygen -t ed25519
# Copy SSH key to server
ssh-copy-id user@hostname
Compression and Archives
# Create tar archive
tar -czvf archive.tar.gz directory/
# Extract tar archive
tar -xzvf archive.tar.gz
# Zip/Unzip
zip -r archive.zip directory/
unzip archive.zip
Bonus: DevOps-Specific Commands
# Docker basics
docker ps
docker logs container_id
docker exec -it container_id /bin/bash
# Kubernetes basics
kubectl get pods
kubectl logs pod-name
kubectl describe pod pod-name
# Git essentials
git status
git log --oneline
git diff
Conclusion
Mastering these commands will significantly boost your productivity as a DevOps engineer. Practice them daily, create aliases for frequently used combinations, and gradually build muscle memory. The command line is your most powerful tool - invest the time to master it.
Want to dive deeper? Explore our Bash Scripting books to take your command-line skills to the next level.