Skip to content

About

A centralized repository of Bash scripts built for automating tasks, optimizing systems, managing infrastructure, and daily utilities within Unix/Linux environments.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

🐚 Bash Scripting

A comprehensive and well-structured collection of 30 Bash scripts for system task automation, user management, file manipulation, network utilities, remote provisioning, and more. This repository contains useful tools for system administrators, DevOps developers, and Linux enthusiasts working in Linux/Unix environments.

Total Scripts: 30 | Lines of Code: ~1,800–2,400 | Complexity: Basic to Advanced

Note

Modular Documentation: To facilitate navigation and maintenance, each directory in this repository features its own dedicated README.md file, where you will find usage details, command options, and specific examples.

📋 Table of Contents

✨ Features

  • 🔐 User Management - System user creation, deletion, and management.
  • 📁 File Management - Compression, concatenation, copying, recursive deletion, and searching.
  • 🌐 Network Configuration - Management of network interfaces and static IPs.
  • 📊 System Monitoring - Disk usage and log analysis.
  • 🧮 Educational Algorithms - Fibonacci, master-slave patterns with POSIX communication.
  • 🔓 Security Tools - Parallelized dictionary-based password crackers.
  • 🔄 Advanced Automation - Interactive menus and file change detection.
  • ✅ Robustness - Exhaustive parameter validation, POSIX signal handling, and error handling.
  • 💾 Backup & Compression - Password-protected ZIP compression and format conversion.
  • 📚 Educational Code - 12 scripts specifically designed for learning Bash.

🔧 Requirements

  • Operating System: Linux/Unix (Debian, Ubuntu, CentOS, Fedora, etc.).
  • Shell: Bash 4.0 or higher (bash --version to check).
  • Permissions: Regular user for most scripts; sudo/root access required for:
    • User creation and deletion.
    • Network interface configuration.
    • APT package updates.
    • Remote server provisioning.
    • USB forensic scanning and image mounting.
  • Additional Tools (depending on the script):
    • zip/unzip for ZIP compression.
    • convert (ImageMagick) for file conversion.
    • python3 or python for password crackers.
    • openssl for password generation.
    • sshpass for remote server provisioning scripts.
    • ddrescue, clamav, yara, and related forensic tools for USB scanning.
    • POSIX queue support (/dev/mqueue) for master-slave scripts (recent kernel).

📥 Installation

  1. Clone this repository:
git clone https://github.com/Esperilla/Bash-Scripting.git
cd Bash-Scripting
  1. Grant execution permissions:
# To a specific script
chmod +x "User_Management/userAdd.sh"

# To all scripts recursively
find . -name "*.sh" -exec chmod +x {} \;

# Or more simply
chmod +x **/*.sh
  1. (Optional) Add the directory to your PATH for global access:
export PATH=$PATH:$(pwd)
# Or add it permanently to your ~/.bashrc
echo "export PATH=\$PATH:$(pwd)" >> ~/.bashrc
source ~/.bashrc

📂 Script Structure and Categories

To view installation details, specific usage, and examples for each script, please navigate to the README.md file inside the corresponding folder:

  • userAdd.sh - Create new users with an automatically generated random password.
  • userDeleter.sh - Safely delete system users and their home directories.
  • userDate.sh - Copy files while appending the current date to the filename and including current user information.
  • date.sh - Usage examples of variables and date commands.
  • validations.sh - Basic validation of input parameters.
  • fibonacci.sh - Recursive algorithm to calculate the n-th Fibonacci number.
  • count.sh - Count occurrences of a string across multiple files.
  • lastParameter.sh - Retrieve the last positional parameter received by the script.
  • dateFile.sh - Automated file creation with timestamps.
  • attack.sh - Detect files modified within a specific timeframe.
  • logsUse.sh - System monitoring featuring POSIX signal handling.
  • dircontMaster-Slave/ - Master-Slave concurrency pattern using POSIX IPC message queues.
  • masterSlave/ - Simpler master-slave example using POSIX signals for coordination.
  • zipCompressor.sh - Recursive ZIP compression with password protection and automated naming.
  • mergeFiles.sh - Merge the contents of two files into a third one.
  • copyMove.sh - Copy or move files and directories with safety validations.
  • recursiveEraser.sh - Recursively delete .txt files within a given directory.
  • converter.sh - Automated image conversion using ImageMagick.
  • filesList.sh - Search and list files that match multiple criteria.

🛠️ Dependencies

Required Tools by Category

Tool Scripts Using It Version Installation
bash All 4.0+ Usually pre-installed
openssl userAdd.sh Any apt install openssl
zip/unzip zipCompressor.sh Any apt install zip unzip
convert converter.sh Any apt install imagemagick
python3 improveCracker.sh 3.x apt install python3
python cracker.sh 2.7+ Usually pre-installed
git Cloning the repository Any apt install git

Verify Tool Availability:

# Check bash version
bash --version

# Check python version
python3 --version

# Check zip availability
which zip

# Check convert (ImageMagick) version
convert --version

# Install required packages on Ubuntu/Debian
sudo apt update && sudo apt install -y zip unzip imagemagick openssl python3

🎭 Patterns and Special Features

1. Master-Slave Pattern with POSIX Queues

Scripts: Didactic/dircontMaster-Slave/

Implements inter-process communication via POSIX queues (/dev/mqueue/) for parallel processing:

  • The master creates jobs and waits for results
  • Slaves process tasks in parallel and report back results
  • Efficient synchronization without relying on temporary files
bash dircontMaster.sh /dir1 /dir2 /dir3

2. Data-Splitting Parallelism

Scripts: Artifacts/cracker/cracker*.sh

Divides tasks among available CPU cores:

# Automatically detects CPUs and splits the workload
nproc  # Shows the number of CPUs

3. POSIX Signal Handling

Script: Didactic/logsUse.sh

Responds to system signals:

  • SIGUSR1 - Pauses/disables monitoring
  • SIGUSR2 - Resumes/reactivates monitoring
  • SIGTERM/SIGINT - Cleans up and terminates gracefully
# Run in the background
bash logsUse.sh 10 60 &

# Send signals
kill -USR1 $PID  # Pause
kill -USR2 $PID  # Resume

4. Interactive Menus

Script: Artifacts/updater.sh

Menu-driven user interface leveraging select:

1) Update_Repositories
2) Update_Packages
3) Install_Package
4) Exit

5. Exhaustive Parameter Validation

Ejemplo: Artifacts/cracker/improveCracker.sh

  • Type checking using regular expressions (regex)
  • File existence validation
  • Command availability checks
  • Step-by-step error handling

⚠️ Security Notes

Scripts Requiring Special Attention

Script Risk Recommendation
userAdd.sh Generates passwords that MUST be saved Store them in a secure secrets manager
userDeleter.sh Permanently deletes data Double-check the username before executing
configNetwork.sh Modifies critical system configuration Validate the confIP.txt file before use
cracker*.sh Strictly for educational/authorized use Run only on your own systems or with explicit permission
logsUse.sh Can suspend system services Test in a non-production environment

Best Practices

✅ Recommended:

  • Use sudo instead of running directly as the root user.
  • Take a backup before executing any deletion scripts.
  • Review configuration files carefully before use.
  • Run scripts with -h to view the available help menu.
  • Validate file permissions (chmod 644 for configuration files).

❌ Avoid:

  • Running unfamiliar scripts as root without reviewing their source code.
  • Reusing simple or automatically generated passwords across systems.
  • Modifying network configurations in production environments without a backup plan.

📖 Usage Examples

Case 1: Creating Multiple Users

# Create a user
sudo bash "User_Management/userAdd.sh"
# Follow the interactive prompts

Case 2: Creating a Compressed Backup of an Important Directory

cd "File_Management"
bash zipCompressor.sh -p -v ~/Documents backup_docs.zip
# You will be securely prompted for a password (without echo)

Case 3: Monitoring Disk Usage

cd Artifacts
# Check usage on /home
bash percentUse_Disk.sh /home
# Expected output if usage is over 80%:
# WARNING! Disk usage is high
# /home: 82%

Case 4: Searching for Files by Criteria

cd "File_Management"
bash filesList.sh /home/user "project bash"
# Finds files containing ALL specified words in their name

Case 5: Detecting Recent Changes in Files

cd Didactic
# Files modified within the last 300 seconds
bash attack.sh /home 300

🏗️ Repository Structure

Bash-Scripting/
├── README.md                          # This file (general guide)
│
├── User_Management/
│   ├── README.md                      # User management details
│   ├── userAdd.sh                     # Create users with a random password
│   ├── userDeleter.sh                 # Safely delete system users
│   └── userDate.sh                    # Copy files with user/date timestamp
│
├── Artifacts/
│   ├── README.md                      # Artifacts and tools details
│   ├── configNetwork/                 # Static IP configuration
│   │   ├── configNetwork.sh           # Configure static IPs
│   │   └── confIP.txt                 # Configuration file (example)
│   ├── percentUse_Disk.sh             # Disk usage monitoring with alerts
│   ├── updater.sh                     # Interactive menu for package manager
│   ├── cracker/                       # Security tools
│   │   ├── cracker.sh                 # Basic dictionary cracker
│   │   ├── improveCracker.sh          # Robust professional cracker
│   │   └── generalList.txt            # Dictionary for testing
│   ├── server/                        # Remote provisioning scripts
│   │   ├── confServer.sh              # Provision users on multiple servers
│   │   ├── confServer_v2.sh           # Provisioning with validation and reporting
│   │   └── servers.conf               # Sample server list
│   └── usbMalware_Scan/               # USB forensics scripts
│       ├── usbMalware_Scan.sh         # Original forensic scanner
│       ├── usbMalware_Scan_V2.sh      # Improved forensic scanner
│       ├── usb_Scan.conf              # Configuration file
│       └── USB_SCAN_V2_README.md      # Extended documentation
│
├── Didactic/                          # Scripts for learning Bash
│   ├── README.md                      # Educational scripts details
│   ├── date.sh                        # Date variables usage
│   ├── validations.sh                 # Parameter validation
│   ├── fibonacci.sh                   # Recursive algorithm
│   ├── count.sh                       # File processing
│   ├── lastParameter.sh               # Positional parameters
│   ├── dateFile.sh                    # File creation with timestamps
│   ├── attack.sh                      # File modification detection
│   ├── logsUse.sh                     # POSIX signal handling
│   ├── dircontMaster-Slave/           # Master-slave pattern with POSIX IPC
│   │   ├── dircontMaster.sh           # Coordinator master process
│   │   └── slave.sh                   # Worker slave process
│   └── masterSlave/                   # Master-slave pattern with POSIX signals
│       ├── master.sh                  # Coordinator master process
│       └── slave.sh                   # Worker slave process
│
├── File_Management/
│   ├── README.md                      # File management details
│   ├── zipCompressor.sh               # Password-protected ZIP compression
│   ├── mergeFiles.sh                  # Merge multiple files
│   ├── copyMove.sh                    # Copy or move with safety validations
│   ├── recursiveEraser.sh             # Recursively delete .txt files
│   ├── converter.sh                   # Convert image formats (ImageMagick)
│   └── filesList.sh                   # Search files by multiple criteria

Total: 30 bash scripts | ~1,800–2,400 lines of code | Complexity: Basic to Advanced

Repository Statistics

Metric Value
Total scripts 30
Scripts requiring root 4
Educational scripts 12
Average lines of code ~50–100
Most complex script usbMalware_Scan_V2.sh / improveCracker.sh
Simplest script date.sh
Implemented patterns 5 (master-slave, parallelism, signals, menus, validations)

📚 Additional Resources


📄 License

This project is licensed under the MIT License. Feel free to use it for learning and personal projects.


Last update: July 2026
Maintainer: @Esperilla

About

A centralized repository of Bash scripts built for automating tasks, optimizing systems, managing infrastructure, and daily utilities within Unix/Linux environments.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages