Day 05 — Advanced Linux Commands for DevOps

🎯 Goal

Learn how to monitor, debug, and operate real Linux systems using advanced commands.

These are the commands you use when:

  • A server is slow
  • A service is down
  • Disk is full
  • CPU is high

🧠 Mental Model

A running Linux system can be understood as:

Processes + Memory + Disk + Network

Your job as a DevOps engineer is to:

  • Inspect system state
  • Find bottlenecks
  • Take corrective action

1️⃣ Login & Remote Access

ssh — Secure Shell

ssh user@server-ip

What it does:
Connects to a remote Linux machine securely.

Why it matters:

  • Primary way to access servers
  • Used in CI/CD, cloud, automation

2️⃣ Disk Usage Commands

df — Disk Filesystem Usage

df -h

What it does:
Shows disk space usage across filesystems.

ColumnMeaning
SizeTotal disk
UsedUsed space
AvailFree space

Use case:

  • Check if disk is full

du — Directory Usage

du -sh *
du -h /var/log

What it does:
Shows space used by files/directories.

Use case:

  • Find which folder is consuming disk

3️⃣ Process Monitoring

ps — Process Snapshot

ps aux

What it does:
Shows all running processes.

Use case:

  • Check if a service is running

top — Real-time Monitoring

top

What it does:
Shows live CPU, memory, processes.

Use case:

  • Identify high CPU/memory usage

fuser — Who is using a file/port

fuser 8080/tcp

What it does:
Shows which process is using a port/file.

Use case:

  • Debug port conflicts

4️⃣ Process Control

kill — Stop process

kill PID
kill -9 PID

What it does:
Sends signals to processes.

SignalMeaning
defaultgraceful stop
-9force kill

nohup — Run in background

nohup python app.py &

What it does:
Runs command even after terminal closes.

Use case:

  • Run long jobs on servers

5️⃣ Memory Monitoring

free — Memory usage

free -h

What it does:
Shows RAM usage.


vmstat — System performance

vmstat 1

What it does:
Shows:

  • CPU usage
  • Memory
  • I/O stats

Use case:

  • Diagnose performance issues

🧪 Day-5 Lab

# SSH (if server available)
ssh user@server-ip
 
# disk usage
df -h
du -sh *
 
# processes
ps aux | head
top
 
# find process using port
fuser 8080/tcp
 
# kill process
kill PID
 
# background job
nohup sleep 1000 &
 
# memory
free -h
vmstat 1

🧠 Key Takeaways

  • ssh = access servers
  • df + du = disk debugging
  • ps + top = process monitoring
  • kill = control processes
  • free + vmstat = memory & performance

✅ Outcome

You can now:

  • Log into remote servers
  • Monitor disk usage
  • Analyze running processes
  • Debug port conflicts
  • Manage processes
  • Diagnose system performance

Next → Users & Groups Management 🚀