Production-ready shell scripts for Linux system administration and automation
A comprehensive collection of Bash scripts demonstrating real-world system administration automation, user management, and DevOps best practices. Built with security, error handling, and production environments in mind.
|
System Administration
|
Shell Scripting Proficiency
|
| Script | Description | Usage |
|---|---|---|
create_user.sh |
Interactive user creation with secure password input | ./create_user.sh |
create_User_usingParameter.sh |
Create user via command-line parameters | ./create_User_usingParameter.sh <username> |
delete_user.sh |
Safe user deletion with verification | ./delete_user.sh |
check_if_user_exists.sh |
Validate user existence on system | ./check_if_user_exists.sh |
| Script | Description | Usage |
|---|---|---|
backups.sh |
Automated timestamped ZIP backups | ./backups.sh <source> <destination> |
create_shell_backup.sh |
Enhanced backup with detailed logging | ./create_shell_backup.sh <source> <destination> |
install_package.sh |
Automated package installation | ./install_package.sh <package-name> |
| Script | Description | Concepts |
|---|---|---|
Variables.sh |
Variable declaration and usage patterns | Variables, command substitution |
Variables_2.sh |
Advanced variable operations | Variable manipulation |
loops_shell.sh |
Looping constructs (for, while) | Iteration, counters |
function_greet.sh |
Basic function definition | Functions |
function_with_parameters.sh |
Functions with arguments | Parameter passing |
function_with_returnType.sh |
Functions with return values | Return codes, output capture |
function_test.sh |
Comprehensive function examples | Modular programming |
read_input.sh |
User input handling | stdin, read command |
read_silent_flag.sh |
Secure password input with -s flag | Silent input, readonly vars |
args_input.sh |
Command-line argument processing | $1, |
greet_user.sh |
Interactive greeting script | Basic I/O |
# Clone the repository
git clone https://github.com/H1manshu-Kumar/shell-scripts.git
# Navigate to directory
cd shell-scripts
# Make scripts executable
chmod +x *.sh
# Run any script
./create_user.sh# Backup your project directory
./backups.sh /home/user/project /home/user/backups
# Output: backup-2024-01-15-14-30.zip created# Check if user exists
./check_if_user_exists.sh
# Create new user with secure password prompt
./create_user.sh
# Remove user when needed
./delete_user.sh# Install packages in automated workflow
./install_package.sh docker
./install_package.sh nginx- 🔐 Silent password input (
-sflag) prevents credential exposure - ✅ User existence validation before operations
- 🛡️
sudoprivilege separation for system-level changes - 📝 Input sanitization and error checking
- Linux-based OS (Ubuntu, Debian, CentOS, RHEL)
- Bash 4.0+
- sudo privileges (for user management and package installation)
This repository progressively covers:
- Basics: Variables, input/output, arguments
- Intermediate: Functions, loops, conditionals
- Advanced: User management, system automation, backup solutions
Contributions are welcome! Help improve these automation scripts.
# Fork the repo and create a feature branch
git checkout -b feature/enhanced-backup
# Commit your changes
git commit -m "Add incremental backup support"
# Push and create a Pull Request
git push origin feature/enhanced-backup✅ Shebang line (#!/bin/bash) for interpreter specification
✅ Comments and documentation blocks
✅ Error handling and validation
✅ Modular function-based design
✅ Secure credential handling
✅ Output redirection for clean execution
Himanshu Kumar - Building, Containerizing, and Deploying One Step at a Time 🚀
🔗 GitHub: https://github.com/H1manshu-Kumar
🔗 LinkedIn: https://www.linkedin.com/in/h1manshu-kumar
💻 Happy Scripting! 🚀