██████╗ █████╗ ███████╗██╗ ██╗ ███████╗ ██████╗██████╗ ██╗██████╗ ████████╗██╗███╗ ██╗ ██████╗
██╔══██╗██╔══██╗██╔════╝██║ ██║ ██╔════╝██╔════╝██╔══██╗██║██╔══██╗╚══██╔══╝██║████╗ ██║██╔════╝
██████╔╝███████║███████╗███████║ ███████╗██║ ██████╔╝██║██████╔╝ ██║ ██║██╔██╗ ██║██║ ███╗
██╔══██╗██╔══██║╚════██║██╔══██║ ╚════██║██║ ██╔══██╗██║██╔═══╝ ██║ ██║██║╚██╗██║██║ ██║
██████╔╝██║ ██║███████║██║ ██║ ███████║╚██████╗██║ ██║██║██║ ██║ ██║██║ ╚████║╚██████╔╝
╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
🐚 A curated collection of Linux Bash scripts — from beginner fundamentals to real-world automation tools. Built for learners, sysadmins, and developers who love the terminal.
- ✨ About
- 🗂️ Repository Structure
- 🚀 Getting Started
- 📜 Script Categories
- 🛠️ Usage
- 💡 Tips & Best Practices
- 🤝 Contributing
- 📄 License
This repository is a hands-on learning ground for Linux Bash Scripting.
Whether you're just starting out with shell scripts or looking to sharpen your automation game, you'll find practical, well-commented scripts covering a wide range of topics — from basic syntax and control flow to file manipulation, process management, and beyond.
$ echo "Why learn Bash?"
> Because the terminal is where the real power lives.Linux-Bash-Scripting/
│
├── 📁 basics/ # Variables, input/output, comments
├── 📁 control-flow/ # if/else, loops, case statements
├── 📁 functions/ # Reusable functions and libraries
├── 📁 file-operations/ # Read, write, parse, manipulate files
├── 📁 system-admin/ # Disk, memory, process monitoring
├── 📁 networking/ # Ping checks, port scanners, curl scripts
├── 📁 automation/ # Cron jobs, backups, schedulers
├── 📁 text-processing/ # awk, sed, grep, cut, sort
└── 📁 projects/ # End-to-end real-world mini-projects
Make sure you have the following:
- A Linux / macOS system (or WSL on Windows)
bashversion 4.0+
bash --versiongit clone https://github.com/Kishan-Miskin/Linux-Bash-Scripting.git
cd Linux-Bash-Scriptingchmod +x basics/hello_world.sh
./basics/hello_world.sh| Category | Description | Difficulty |
|---|---|---|
| 🟢 Basics | Variables, data types, user input, echo/printf | Beginner |
| 🟢 Control Flow | if/elif/else, for, while, until, case | Beginner |
| 🟡 Functions | Declaring, calling, scoping, return values | Intermediate |
| 🟡 File Operations | Reading files, writing logs, parsing CSVs | Intermediate |
| 🟡 Text Processing | awk, sed, grep, tr, cut, sort, uniq | Intermediate |
| 🔴 System Admin | CPU/RAM monitoring, disk usage, process management | Advanced |
| 🔴 Networking | Ping sweeps, port scanning, curl API calls | Advanced |
| 🔴 Automation | Backup scripts, cron jobs, scheduled tasks | Advanced |
chmod +x script_name.sh
./script_name.shbash script_name.sh./script.sh arg1 arg2
# Inside script: $1 = arg1, $2 = arg2bash -x script.sh # Trace execution
bash -n script.sh # Syntax check only# ✅ Always start with a shebang
#!/bin/bash
# ✅ Use quotes around variables
echo "$variable" # Prevents word splitting
# ✅ Check command success
if ! mkdir /tmp/mydir; then
echo "Failed to create directory"
fi
# ✅ Use meaningful variable names
user_home="$HOME"
# ✅ Trap errors for cleanup
trap 'echo "Error on line $LINENO"' ERR| ✅ Do This | ❌ Avoid This |
|---|---|
Quote your variables "$var" |
Unquoted variables $var |
Use [[ for conditionals |
Use [ without escaping |
Add set -e for strict mode |
Silent failure on errors |
| Comment your logic | Writing cryptic one-liners |
Use local for function vars |
Global vars everywhere |
Contributions are warmly welcome! 🎉
# 1. Fork the repository
# 2. Create your feature branch
git checkout -b feature/my-awesome-script
# 3. Commit your changes
git commit -m "Add: system health check script"
# 4. Push to your branch
git push origin feature/my-awesome-script
# 5. Open a Pull Request- 📝 Add comments to explain what your script does
- 🧪 Test your script before submitting
- 📁 Place scripts in the correct category folder
- 🔤 Use
snake_casefor file names (e.g.,disk_usage.sh)
This project is licensed under the MIT License — feel free to use, share, and modify.