DevOps Roadmap — Part 5: Shell Scripting for DevOps

DevOps ka real kaam yahan se start hota hai.

Jo kaam tum manually 10 baar kar rahe ho, DevOps usko script likh ke 1 baar karta hai.


What Is Shell Scripting?

Shell scripting means:

DevOps engineer ka sabse pehla automation tool = Bash


Your First Shell Script

Create script file
nano hello.sh
hello.sh
#!/bin/bash
echo "Hello DevOps World"
Run script
chmod +x hello.sh
./hello.sh

#!/bin/bash batata hai kaunsa shell use hoga.


Variables — Store Information

Example
#!/bin/bash
NAME="Suraj"
echo "Hello $NAME"

Variables help DevOps scripts become flexible.


Taking User Input

Input Example
#!/bin/bash
echo "Enter your name:"
read USER
echo "Welcome $USER"

Scripts can interact with humans or systems.


Conditions — Decision Making

if condition
#!/bin/bash
if [ -f "/etc/passwd" ]; then
  echo "File exists"
else
  echo "File missing"
fi

Production scripts are full of conditions.


Loops — Automation Power

For loop
#!/bin/bash
for i in 1 2 3 4 5
do
  echo "Deployment step $i"
done

Imagine deploying 50 servers without loops — impossible.


Real DevOps Script Example

Check disk usage and alert.

Disk Check Script
#!/bin/bash
USAGE=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')

if [ $USAGE -gt 80 ]; then
  echo "Warning: Disk usage above 80%"
else
  echo "Disk usage normal"
fi

This is real-world DevOps thinking.


Why Shell Scripting Is Mandatory

Without shell scripting, DevOps engineer incomplete hai.


Practice Daily (Very Important)


Next Step in DevOps Roadmap

Now we need team collaboration. That means Git & Version Control.

Next Part → Git & Version Control
Disclaimer:
Always test shell scripts on local or test servers. Never run unverified scripts on production systems.