Originally published on 2015-06-17; fully revised and updated.
This page is a structured roadmap for engineers and administrators who want to learn Bash scripting for day-to-day DevOps work. You will see the full learning sequence, practical commands, and how to move from simple scripts to production-friendly automation.

Original registration link from the source post: DevOps Training Registration.
What this Bash training covers
The original post provided a module list. Reorganized into a modern sequence, the course covers Linux shell foundations, Git basics, core Bash syntax, control flow, parameters, functions, string operations, and operational execution patterns such as background jobs and cron.
- Shell and Linux fundamentals
- Git fundamentals for script versioning
- Creating and running shell scripts safely
- Variables, input, output, and redirection
- Conditionals, loops, and control statements
- Functions and reusable script design
- Parameters,
shift, andgetopts - String handling, pattern matching, and arrays
- Execution modes: foreground, background, nohup, cron
Learning flow from basics to automation
Use this sequence to avoid common learning gaps. Each stage builds directly on the previous one.
flowchart TD
A[Linux shell basics] --> B[Git fundamentals]
B --> C[First Bash scripts]
C --> D[Variables and input output]
D --> E[If tests and return codes]
E --> F[Loops and case statements]
F --> G[Parameters and getopts]
G --> H[Functions strings arrays]
H --> I[Run with nohup cron and exec]
I --> J[Debug harden and maintain]
Curriculum breakdown by module
Foundation modules
- Why shell scripting and where it fits in DevOps workflows
- Linux internals relevant to scripting
- Prerequisites and terminal habits
- Git setup, basic operations, and GitHub usage
Core Bash scripting modules
- Script creation, shebang usage, and naming conventions
- Variables, quoting, and reading user input
- If/then/else logic, conditional expressions, and arithmetic tests
- Input/output with
echo,printf, and stream redirection - Control flow with
while,until,for,break,continue, andcase
Advanced and operational modules
- Integer variables, arithmetic expressions, readonly/exported variables, arrays
- Handling parameters with special variables,
shift, andgetopts - Functions and reusable script structure
- String slicing, search/replace, default values, and regex patterns
- Execution options including background runs,
nohup,exec,at, andcron
Hands-on Bash examples to practice
These examples match the topics in the curriculum and are suitable for lab practice.
#!/usr/bin/env bash
set -euo pipefail
note_file="${HOME}/notes.txt"
read -r -p "Enter note: " note
printf "%s | %s\n" "$(date +%F\ %T)" "$note" >> "$note_file"
echo "Saved to $note_file"Code language: PHP (php)
#!/usr/bin/env bash
set -euo pipefail
log_file="${1:-app.log}"
if [[ -f "$log_file" ]]; then
if grep -q "ERROR" "$log_file"; then
echo "Errors found in $log_file"
else
echo "No errors found in $log_file"
fi
else
echo "File not found: $log_file" >&2
exit 1
fiCode language: PHP (php)
#!/usr/bin/env bash
set -euo pipefail
file=""
count=1
while getopts ":f:n:h" opt; do
case "$opt" in
f) file="$OPTARG" ;;
n) count="$OPTARG" ;;
h)
echo "Usage: $0 -f FILE [-n COUNT]"
exit 0
;;
:)
echo "Option -$OPTARG requires an argument" >&2
exit 1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
echo "file=$file count=$count remaining_args=$*"Code language: PHP (php)
Ways to run scripts in development and operations
| Method | Best for | Caveat | Example |
|---|---|---|---|
| Direct execution | Normal script usage with shebang | Needs execute permission | ./script.sh |
| Invoke with bash | Quick tests without chmod | May bypass intended interpreter in shebang | bash script.sh |
| source (dot command) | Loading functions or environment variables into current shell | Changes affect current shell session | source ./env.sh |
| nohup and background | Long tasks that should continue after logout | No built-in scheduling/retry policy | nohup ./job.sh > job.log 2>&1 & |
| cron scheduling | Recurring automation | Runs with minimal environment | 0 2 * * * /opt/scripts/backup.sh |
chmod +x script.sh
./script.sh
bash script.sh
source ./env.sh
nohup ./job.sh > job.log 2>&1 &
crontab -e
Best practices and common pitfalls
- Start scripts with
#!/usr/bin/env bashand use strict mode (set -euo pipefail) when appropriate. - Quote variables to prevent word-splitting and globbing bugs.
- Check exit codes and handle failures explicitly.
- Use
shellcheckduring development to catch common issues early. - For cron jobs, set required environment variables inside the script.
- Keep scripts in Git and review changes like application code.
This revised page preserves the original training intent while giving you a practical, execution-focused path for learning and applying Bash scripting in DevOps environments.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals