A comprehensive, open-source course for mastering shell scripting on Linux and macOS
π View the Course Online: Shell Scripting Mastery β Live GitHub Page
This is a complete, production-ready course designed to take you from command-line beginner to advanced shell scripting practitioner. Every unit includes detailed explanations, commented code examples, real-world scenarios, and hands-on exercises.
- Command Line Mastery - Navigate and manage files with confidence
- Shell Scripting Fundamentals - Variables, functions, and control structures
- Text Processing - Master grep, sed, awk, and regex patterns
- Advanced Techniques - Arrays, error handling, traps, and signals
- System Administration - Package management, cron jobs, and automation
- Real-World Projects - Build production-ready scripts and tools
- Best Practices - Write secure, maintainable, professional code
- Beginners - No prior experience required
- Developers - Automate your workflow
- System Administrators - Manage servers efficiently
- DevOps Engineers - Build deployment pipelines
- Bash - Standard on most Linux distributions
- Zsh - Default on macOS (Catalina and later)
- Scripts are written for maximum portability
Estimated Time: 2-3 hours Learn the difference between terminals and shells, navigate the file system, manage files and directories, and understand Unix permissions.
Topics Covered:
- Terminal vs. Shell
- Navigation (
pwd,cd,ls) - File operations (
cp,mv,rm,mkdir) - Permissions and
chmod
Estimated Time: 2-3 hours Master the fundamentals of shell scripting including variables, quoting rules, command substitution, and exit codes.
Topics Covered:
- The shebang (
#!/bin/bash) - Variables and data types
- Quoting rules (single vs. double quotes)
- Command substitution
$() - Exit codes and error handling
Estimated Time: 2-3 hours Make your scripts intelligent with conditional logic and loops.
Topics Covered:
if/else/elifstatements- Test conditions (files, strings, numbers)
forloops and iterationwhileloops- Combining control structures
Estimated Time: 2-3 hours Write modular, reusable code with functions and proper script organization.
Topics Covered:
- Defining and calling functions
- Function arguments
- Variable scope (global vs. local)
- Return values
- The "main" function pattern
Estimated Time: 3-4 hours Master the three standard streams and the "Power Trio" of text processing.
Topics Covered:
- STDIN, STDOUT, STDERR
- Redirection operators (
>,>>,2>,&>) - Pipes (
|) grep- Search textsed- Stream editorawk- Pattern processing
Estimated Time: 2-3 hours Manipulate strings and master regular expressions for pattern matching.
Topics Covered:
- String slicing and substitution
- Parameter expansion
- Regular expressions
- Pattern matching
- Validation with regex
Estimated Time: 3-4 hours Level up with arrays, associative arrays, and robust error handling.
Topics Covered:
- Indexed arrays
- Associative arrays (hash maps)
- Error handling with
trap - Signal handling (EXIT, INT, TERM)
- Resource cleanup
Estimated Time: 2-3 hours Write cross-platform scripts that work with different package managers and automate system tasks.
Topics Covered:
apt(Debian/Ubuntu)yum/dnf(RedHat/CentOS)brew(macOS)- Cron scheduling
- System monitoring
Estimated Time: 4-6 hours Apply everything you've learned by building real-world automation projects.
Projects Include:
- System health monitor
- Automated backup system
- Log analyzer
- Deployment automation
- File organizer
Estimated Time: 3-4 hours Write production-ready, secure, and maintainable shell scripts.
Topics Covered:
- Script structure and templates
- Security best practices
- Debugging techniques
- Performance optimization
- Code review checklist
- ShellCheck and linting
A comprehensive technical manual covering shell syntax rules, core commands, and package management across different systems.
For a condensed overview of all topics, see the π Full Curriculum Document.
System Requirements:
- A Unix-based system (Linux, macOS, or WSL on Windows)
- Terminal emulator (Terminal.app, iTerm2, GNOME Terminal, etc.)
- Text editor (VS Code, vim, nano, etc.)
Knowledge Requirements:
- Basic computer literacy
- Willingness to learn
- No prior programming experience required!
-
Clone this repository:
git clone https://github.com/yourusername/shell-scripting-mastery.git cd shell-scripting-mastery -
Check your shell:
echo $SHELL
You should see
/bin/bashor/bin/zsh -
Start learning! Begin with Unit 1
- Follow in Order - Units build on each other sequentially
- Read Carefully - Each unit includes detailed explanations
- Try the Examples - Type out the code snippets yourself
- Do the Exercises - Practice is essential for mastery
- Build Projects - Apply concepts in Unit 9's practical projects
# Create a new script file
nano hello.sh
# Add this content:
#!/bin/bash
echo "Hello, World!"
# Make it executable
chmod +x hello.sh
# Run it
./hello.shAll fundamental and advanced topics with no gaps
Every code snippet includes inline explanations
Learn through practical, production-ready examples
Practice problems at the end of each unit
Learn professional coding standards from the start
See typical errors and how to avoid them
Gentle learning curve from basics to advanced
Unit 1 β Unit 2 β Unit 3 β Unit 4 β Unit 5
β
Unit 6 β Unit 7 β Unit 8 β Unit 9 β Unit 10
β
Build Your Own Projects!
Estimated Total Time: 25-35 hours
- Practice Daily - Even 30 minutes a day is better than cramming
- Type Everything - Don't copy-paste; muscle memory matters
- Break Things - Experiment and learn from errors
- Read Error Messages - They tell you exactly what's wrong
- Use ShellCheck - A static analysis tool for catching bugs
- Build Projects - Apply your knowledge to real problems
- Join Communities - Ask questions on forums and Discord
- ShellCheck - Catch bugs and bad practices
- explainshell.com - Understand complex commands
- tldr pages - Quick command reference
- VS Code - Great editor with shell script extensions
- Over The Wire - Bandit levels for Linux practice
- Bash Scripting Challenges - HackerRank exercises
- "The Linux Command Line" by William Shotts
- "Bash Cookbook" by Carl Albing
- "Classic Shell Scripting" by Arnold Robbins
shell-scripting-mastery/
βββ README.md # This file
βββ curriculum.md # Condensed curriculum overview
βββ course_material/
β βββ Unit_1_CLI_Fundamentals.md
β βββ Unit_2_Shell_Scripting_Basics.md
β βββ Unit_3_Control_Flow.md
β βββ Unit_4_Functions_and_Organization.md
β βββ Unit_5_IO_and_Text_Processing.md
β βββ Unit_6_Strings_and_Regex.md
β βββ Unit_7_Advanced_Scripting_Topics.md
β βββ Unit_8_Package_Managers_and_System_Admin.md
β βββ Unit_9_Practical_Projects.md
β βββ Unit_10_Best_Practices_and_Advanced_Techniques.md
β βββ Reference_Syntax_Commands_PackageManagement.md
βββ examples/ # (Coming soon) Code examples
This is an open-source educational project. Contributions are welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Make your changes
- Test thoroughly
- Submit a pull request
- Fix typos or improve explanations
- Add more examples
- Create additional exercises
- Translate to other languages
- Add video tutorials
This course is released under the MIT License. You are free to:
- Use this material for personal learning
- Share with others
- Modify and adapt
- Use in commercial training (with attribution)
See LICENSE file for details.
If you find this course helpful, please:
- β Star this repository
- π Report issues you encounter
- π‘ Suggest improvements
- π’ Share with others
This course was created to make shell scripting accessible to everyone. Special thanks to:
- The open-source community
- Contributors and reviewers
- Students who provided feedback
- Issues: GitHub Issues
- Discussions: GitHub Discussions
π Start Learning β
π View Full Curriculum
π Reference Guide
Happy Scripting! π
Made with β€οΈ for the open-source community