Advanced Linux Commands Every DevOps Engineer Must Know
kristarking

kristarking @kristarking

About: I am a Cloud Solution Architect And DevOps Engineer. And I love Sharing What I Learn Along The Way

Joined:
Feb 26, 2025

Advanced Linux Commands Every DevOps Engineer Must Know

Publish Date: Mar 8
0 0

Linux is the backbone of DevOps. Mastering advanced Linux commands can significantly boost your productivity and troubleshooting skills. This guide covers essential system monitoring, networking, security, automation, and DevOps-specific commands.


📌 Table of Contents

  1. System and Resource Monitoring
  2. Networking and Connectivity
  3. Process and Job Management
  4. Security and User Management
  5. Disk Management and File Operations
  6. DevOps-Specific Commands
  7. Automation and Scheduling

⚙️ 1. System and Resource Monitoring

Monitor system performance and resource usage with these commands:

htop
Enter fullscreen mode Exit fullscreen mode
  • A more interactive version of top, displaying system resource usage in real-time.
vmstat 1 5
Enter fullscreen mode Exit fullscreen mode
  • Displays CPU, memory, and I/O statistics every second for five iterations.
iostat -c 2 5
Enter fullscreen mode Exit fullscreen mode
  • Monitors CPU usage every two seconds, repeated five times.
sar -u 5 5
Enter fullscreen mode Exit fullscreen mode
  • Collects and reports CPU usage statistics every five seconds.
mpstat -P ALL 5
Enter fullscreen mode Exit fullscreen mode
  • Displays per-core CPU usage every five seconds.

🌐 2. Networking and Connectivity

Diagnose and debug network issues efficiently:

ss -tulnp
Enter fullscreen mode Exit fullscreen mode
  • Lists open ports and listening services.
ip route show
Enter fullscreen mode Exit fullscreen mode
  • Displays the system's routing table.
nmap -sP 192.168.1.0/24
Enter fullscreen mode Exit fullscreen mode
  • Scans the local network for active devices.
tcpdump -i eth0 port 80
Enter fullscreen mode Exit fullscreen mode
  • Captures network packets on the eth0 interface for HTTP traffic analysis.
dig example.com +short
Enter fullscreen mode Exit fullscreen mode
  • Performs a DNS lookup to resolve domain names.
nc -zv google.com 443
Enter fullscreen mode Exit fullscreen mode
  • Checks if a remote server's port is open.

🔄 3. Process and Job Management

Manage running processes and background jobs:

jobs -l
Enter fullscreen mode Exit fullscreen mode
  • Lists all background jobs.
fg %1
Enter fullscreen mode Exit fullscreen mode
  • Brings job number 1 to the foreground.
bg %1
Enter fullscreen mode Exit fullscreen mode
  • Resumes job 1 in the background.
pkill -f "process_name"
Enter fullscreen mode Exit fullscreen mode
  • Kills a process by name.
nohup command &
Enter fullscreen mode Exit fullscreen mode
  • Runs a command even after logging out.

🔒 4. Security and User Management

Enhance system security with these commands:

sudo visudo
Enter fullscreen mode Exit fullscreen mode
  • Edits the sudoers file securely.
usermod -aG docker username
Enter fullscreen mode Exit fullscreen mode
  • Adds a user to the docker group.
passwd -l username
Enter fullscreen mode Exit fullscreen mode
  • Locks a user account.
find / -perm /4000 2>/dev/null
Enter fullscreen mode Exit fullscreen mode
  • Finds files with the SUID bit set (potential security risks).
history | awk '{print $2}' | sort | uniq -c | sort -nr | head -10
Enter fullscreen mode Exit fullscreen mode
  • Displays the top 10 most used commands.

💾 5. Disk Management and File Operations

Efficiently manage disk space and files:

lsblk
Enter fullscreen mode Exit fullscreen mode
  • Lists storage devices and partitions.
mount | column -t
Enter fullscreen mode Exit fullscreen mode
  • Displays mounted filesystems in a readable format.
du -ah /var/log | sort -rh | head -10
Enter fullscreen mode Exit fullscreen mode
  • Shows the top 10 largest log files.
rsync -avzh source/ destination/
Enter fullscreen mode Exit fullscreen mode
  • Syncs files between directories or servers efficiently.
tar -czvf backup.tar.gz /path/to/backup
Enter fullscreen mode Exit fullscreen mode
  • Compresses a directory into a .tar.gz file.

🚀 6. DevOps-Specific Commands

Essential commands for CI/CD, Docker, Kubernetes, and Terraform:

docker ps -a
Enter fullscreen mode Exit fullscreen mode
  • Lists all running and stopped Docker containers.
docker images
Enter fullscreen mode Exit fullscreen mode
  • Displays locally stored Docker images.
kubectl get pods --all-namespaces
Enter fullscreen mode Exit fullscreen mode
  • Lists all Kubernetes pods across namespaces.
kubectl logs -f pod-name
Enter fullscreen mode Exit fullscreen mode
  • Streams logs from a Kubernetes pod.
terraform fmt && terraform validate
Enter fullscreen mode Exit fullscreen mode
  • Formats and validates Terraform configuration.
ansible-playbook -i inventory playbook.yml --check
Enter fullscreen mode Exit fullscreen mode
  • Runs an Ansible playbook in dry-run mode.
git log --oneline --graph --all
Enter fullscreen mode Exit fullscreen mode
  • Displays a graphical representation of Git commit history.

🤖 7. Automation and Scheduling

Automate tasks and schedule jobs:

watch -n 5 df -h
Enter fullscreen mode Exit fullscreen mode
  • Runs df -h every five seconds.
alias ll='ls -lah'
Enter fullscreen mode Exit fullscreen mode
  • Creates a shortcut for ls -lah.
crontab -l
Enter fullscreen mode Exit fullscreen mode
  • Lists scheduled cron jobs.
at 10:30 PM tomorrow
Enter fullscreen mode Exit fullscreen mode
  • Schedules a command to run at a specific time.

🔥 Final Thoughts

Mastering these advanced Linux commands will elevate your DevOps skills, helping you debug issues, automate workflows, and optimize performance.

💬 Which Linux command do you find most useful in your DevOps journey? Let’s discuss in the comments! 🚀

Comments 0 total

    Add comment