[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M738T72VYN2HXRCR8YY2TVNE":3,"skill-same:01M738T72VYN2HXRCR8YY2TVNE":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":14,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":33,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M738T72VYN2HXRCR8YY2TVNE","linux-shell-scripting",null,"This skill should be used when the user asks to \"create bash scripts\", \"automate Linux tasks\", \"monitor system resources\", \"backup files\", \"manage users\", or \"write production she...","kalash33\u002Fkstack","kalash33","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F90259149?v=4","01M7365X8Q0B73NYHA730SMZWN","Kalash Poddar","01M7365X9D0JK47C3Q0YCCK9Z2",0,"MIT","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Flinux-shell-scripting\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: linux-shell-scripting\ndescription: \"This skill should be used when the user asks to \\\"create bash scripts\\\", \\\"automate Linux tasks\\\", \\\"monitor system resources\\\", \\\"backup files\\\", \\\"manage users\\\", or \\\"write production she...\"\nrisk: unknown\nsource: community\nauthor: zebbern\ndate_added: \"2026-02-27\"\n---\n\n# Linux Production Shell Scripts\n\n## Purpose\n\nProvide production-ready shell script templates for common Linux system administration tasks including backups, monitoring, user management, log analysis, and automation. These scripts serve as building blocks for security operations and penetration testing environments.\n\n## Prerequisites\n\n### Required Environment\n- Linux\u002FUnix system (bash shell)\n- Appropriate permissions for tasks\n- Required utilities installed (rsync, openssl, etc.)\n\n### Required Knowledge\n- Basic bash scripting\n- Linux file system structure\n- System administration concepts\n\n## Outputs and Deliverables\n\n1. **Backup Solutions** - Automated file and database backups\n2. **Monitoring Scripts** - Resource usage tracking\n3. **Automation Tools** - Scheduled task execution\n4. **Security Scripts** - Password management, encryption\n\n## Core Workflow\n\n### Phase 1: File Backup Scripts\n\n**Basic Directory Backup**\n```bash\n#!\u002Fbin\u002Fbash\nbackup_dir=\"\u002Fpath\u002Fto\u002Fbackup\"\nsource_dir=\"\u002Fpath\u002Fto\u002Fsource\"\n\n# Create a timestamped backup of the source directory\ntar -czf \"$backup_dir\u002Fbackup_$(date +%Y%m%d_%H%M%S).tar.gz\" \"$source_dir\"\necho \"Backup completed: backup_$(date +%Y%m%d_%H%M%S).tar.gz\"\n```\n\n**Remote Server Backup**\n```bash\n#!\u002Fbin\u002Fbash\nsource_dir=\"\u002Fpath\u002Fto\u002Fsource\"\nremote_server=\"user@remoteserver:\u002Fpath\u002Fto\u002Fbackup\"\n\n# Backup files\u002Fdirectories to a remote server using rsync\nrsync -avz --progress \"$source_dir\" \"$remote_server\"\necho \"Files backed up to remote server.\"\n```\n\n**Backup Rotation Script**\n```bash\n#!\u002Fbin\u002Fbash\nbackup_dir=\"\u002Fpath\u002Fto\u002Fbackups\"\nmax_backups=5\n\n# Rotate backups by deleting the oldest if more than max_backups\nwhile [ $(ls -1 \"$backup_dir\" | wc -l) -gt \"$max_backups\" ]; do\n    oldest_backup=$(ls -1t \"$backup_dir\" | tail -n 1)\n    rm -r \"$backup_dir\u002F$oldest_backup\"\n    echo \"Removed old backup: $oldest_backup\"\ndone\necho \"Backup rotation completed.\"\n```\n\n**Database Backup Script**\n```bash\n#!\u002Fbin\u002Fbash\ndatabase_name=\"your_database\"\ndb_user=\"username\"\ndb_pass=\"password\"\noutput_file=\"database_backup_$(date +%Y%m%d).sql\"\n\n# Perform database backup using mysqldump\nmysqldump -u \"$db_user\" -p\"$db_pass\" \"$database_name\" > \"$output_file\"\ngzip \"$output_file\"\necho \"Database backup created: $output_file.gz\"\n```\n\n### Phase 2: System Monitoring Scripts\n\n**CPU Usage Monitor**\n```bash\n#!\u002Fbin\u002Fbash\nthreshold=90\n\n# Monitor CPU usage and trigger alert if threshold exceeded\ncpu_usage=$(top -bn1 | grep \"Cpu(s)\" | awk '{print $2}' | cut -d. -f1)\n\nif [ \"$cpu_usage\" -gt \"$threshold\" ]; then\n    echo \"ALERT: High CPU usage detected: $cpu_usage%\"\n    # Add notification logic (email, slack, etc.)\n    # mail -s \"CPU Alert\" admin@example.com \u003C\u003C\u003C \"CPU usage: $cpu_usage%\"\nfi\n```\n\n**Disk Space Monitor**\n```bash\n#!\u002Fbin\u002Fbash\nthreshold=90\npartition=\"\u002Fdev\u002Fsda1\"\n\n# Monitor disk usage and trigger alert if threshold exceeded\ndisk_usage=$(df -h | grep \"$partition\" | awk '{print $5}' | cut -d% -f1)\n\nif [ \"$disk_usage\" -gt \"$threshold\" ]; then\n    echo \"ALERT: High disk usage detected: $disk_usage%\"\n    # Add alert\u002Fnotification logic here\nfi\n```\n\n**CPU Usage Logger**\n```bash\n#!\u002Fbin\u002Fbash\noutput_file=\"cpu_usage_log.txt\"\n\n# Log current CPU usage to a file with timestamp\ntimestamp=$(date '+%Y-%m-%d %H:%M:%S')\ncpu_usage=$(top -bn1 | grep 'Cpu(s)' | awk '{print $2}' | cut -d. -f1)\necho \"$timestamp - CPU Usage: $cpu_usage%\" >> \"$output_file\"\necho \"CPU usage logged.\"\n```\n\n**System Health Check**\n```bash\n#!\u002Fbin\u002Fbash\noutput_file=\"system_health_check.txt\"\n\n# Perform system health check and save results to a file\n{\n    echo \"System Health Check - $(date)\"\n    echo \"================================\"\n    echo \"\"\n    echo \"Uptime:\"\n    uptime\n    echo \"\"\n    echo \"Load Average:\"\n    cat \u002Fproc\u002Floadavg\n    echo \"\"\n    echo \"Memory Usage:\"\n    free -h\n    echo \"\"\n    echo \"Disk Usage:\"\n    df -h\n    echo \"\"\n    echo \"Top Processes:\"\n    ps aux --sort=-%cpu | head -10\n} > \"$output_file\"\n\necho \"System health check saved to $output_file\"\n```\n\n### Phase 3: User Management Scripts\n\n**User Account Creation**\n```bash\n#!\u002Fbin\u002Fbash\nusername=\"newuser\"\n\n# Check if user exists; if not, create new user\nif id \"$username\" &>\u002Fdev\u002Fnull; then\n    echo \"User $username already exists.\"\nelse\n    useradd -m -s \u002Fbin\u002Fbash \"$username\"\n    echo \"User $username created.\"\n    \n    # Set password interactively\n    passwd \"$username\"\nfi\n```\n\n**Password Expiry Checker**\n```bash\n#!\u002Fbin\u002Fbash\noutput_file=\"password_expiry_report.txt\"\n\n# Check password expiry for users with bash shell\necho \"Password Expiry Report - $(date)\" > \"$output_file\"\necho \"=================================\" >> \"$output_file\"\n\nIFS=$'\\n'\nfor user in $(grep \"\u002Fbin\u002Fbash\" \u002Fetc\u002Fpasswd | cut -d: -f1); do\n    password_expires=$(chage -l \"$user\" 2>\u002Fdev\u002Fnull | grep \"Password expires\" | awk -F: '{print $2}')\n    echo \"User: $user - Password Expires: $password_expires\" >> \"$output_file\"\ndone\nunset IFS\n\necho \"Password expiry report saved to $output_file\"\n```\n\n### Phase 4: Security Scripts\n\n**Password Generator**\n```bash\n#!\u002Fbin\u002Fbash\nlength=${1:-16}\n\n# Generate a random password\npassword=$(openssl rand -base64 48 | tr -dc 'a-zA-Z0-9!@#$%^&*' | head -c\"$length\")\necho \"Generated password: $password\"\n```\n\n**File Encryption Script**\n```bash\n#!\u002Fbin\u002Fbash\nfile=\"$1\"\naction=\"${2:-encrypt}\"\n\nif [ -z \"$file\" ]; then\n    echo \"Usage: $0 \u003Cfile> [encrypt|decrypt]\"\n    exit 1\nfi\n\nif [ \"$action\" == \"encrypt\" ]; then\n    # Encrypt file using AES-256-CBC\n    openssl enc -aes-256-cbc -salt -pbkdf2 -in \"$file\" -out \"$file.enc\"\n    echo \"File encrypted: $file.enc\"\nelif [ \"$action\" == \"decrypt\" ]; then\n    # Decrypt file\n    output_file=\"${file%.enc}\"\n    openssl enc -aes-256-cbc -d -pbkdf2 -in \"$file\" -out \"$output_file\"\n    echo \"File decrypted: $output_file\"\nfi\n```\n\n### Phase 5: Log Analysis Scripts\n\n**Error Log Extractor**\n```bash\n#!\u002Fbin\u002Fbash\nlogfile=\"${1:-\u002Fvar\u002Flog\u002Fsyslog}\"\noutput_file=\"error_log_$(date +%Y%m%d).txt\"\n\n# Extract lines with \"ERROR\" from the log file\ngrep -i \"error\\|fail\\|critical\" \"$logfile\" > \"$output_file\"\necho \"Error log created: $output_file\"\necho \"Total errors found: $(wc -l \u003C \"$output_file\")\"\n```\n\n**Web Server Log Analyzer**\n```bash\n#!\u002Fbin\u002Fbash\nlog_file=\"${1:-\u002Fvar\u002Flog\u002Fapache2\u002Faccess.log}\"\n\necho \"Web Server Log Analysis\"\necho \"========================\"\necho \"\"\necho \"Top 10 IP Addresses:\"\nawk '{print $1}' \"$log_file\" | sort | uniq -c | sort -rn | head -10\necho \"\"\necho \"Top 10 Requested URLs:\"\nawk '{print $7}' \"$log_file\" | sort | uniq -c | sort -rn | head -10\necho \"\"\necho \"HTTP Status Code Distribution:\"\nawk '{print $9}' \"$log_file\" | sort | uniq -c | sort -rn\n```\n\n### Phase 6: Network Scripts\n\n**Network Connectivity Checker**\n```bash\n#!\u002Fbin\u002Fbash\nhosts=(\"8.8.8.8\" \"1.1.1.1\" \"google.com\")\n\necho \"Network Connectivity Check\"\necho \"==========================\"\n\nfor host in \"${hosts[@]}\"; do\n    if ping -c 1 -W 2 \"$host\" &>\u002Fdev\u002Fnull; then\n        echo \"[UP] $host is reachable\"\n    else\n        echo \"[DOWN] $host is unreachable\"\n    fi\ndone\n```\n\n**Website Uptime Checker**\n```bash\n#!\u002Fbin\u002Fbash\nwebsites=(\"https:\u002F\u002Fgoogle.com\" \"https:\u002F\u002Fgithub.com\")\nlog_file=\"uptime_log.txt\"\n\necho \"Website Uptime Check - $(date)\" >> \"$log_file\"\n\nfor website in \"${websites[@]}\"; do\n    if curl --output \u002Fdev\u002Fnull --silent --head --fail --max-time 10 \"$website\"; then\n        echo \"[UP] $website is accessible\" | tee -a \"$log_file\"\n    else\n        echo \"[DOWN] $website is inaccessible\" | tee -a \"$log_file\"\n    fi\ndone\n```\n\n**Network Interface Info**\n```bash\n#!\u002Fbin\u002Fbash\ninterface=\"${1:-eth0}\"\n\necho \"Network Interface Information: $interface\"\necho \"=========================================\"\nip addr show \"$interface\" 2>\u002Fdev\u002Fnull || ifconfig \"$interface\" 2>\u002Fdev\u002Fnull\necho \"\"\necho \"Routing Table:\"\nip route | grep \"$interface\"\n```\n\n### Phase 7: Automation Scripts\n\n**Automated Package Installation**\n```bash\n#!\u002Fbin\u002Fbash\npackages=(\"vim\" \"htop\" \"curl\" \"wget\" \"git\")\n\necho \"Installing packages...\"\n\nfor package in \"${packages[@]}\"; do\n    if dpkg -l | grep -q \"^ii  $package\"; then\n        echo \"[SKIP] $package is already installed\"\n    else\n        sudo apt-get install -y \"$package\"\n        echo \"[INSTALLED] $package\"\n    fi\ndone\n\necho \"Package installation completed.\"\n```\n\n**Task Scheduler (Cron Setup)**\n```bash\n#!\u002Fbin\u002Fbash\nscheduled_task=\"\u002Fpath\u002Fto\u002Fyour_script.sh\"\nschedule_time=\"0 2 * * *\"  # Run at 2 AM daily\n\n# Add task to crontab\n(crontab -l 2>\u002Fdev\u002Fnull; echo \"$schedule_time $scheduled_task\") | crontab -\necho \"Task scheduled: $schedule_time $scheduled_task\"\n```\n\n**Service Restart Script**\n```bash\n#!\u002Fbin\u002Fbash\nservice_name=\"${1:-apache2}\"\n\n# Restart a specified service\nif systemctl is-active --quiet \"$service_name\"; then\n    echo \"Restarting $service_name...\"\n    sudo systemctl restart \"$service_name\"\n    echo \"Service $service_name restarted.\"\nelse\n    echo \"Service $service_name is not running. Starting...\"\n    sudo systemctl start \"$service_name\"\n    echo \"Service $service_name started.\"\nfi\n```\n\n### Phase 8: File Operations\n\n**Directory Synchronization**\n```bash\n#!\u002Fbin\u002Fbash\nsource_dir=\"\u002Fpath\u002Fto\u002Fsource\"\ndestination_dir=\"\u002Fpath\u002Fto\u002Fdestination\"\n\n# Synchronize directories using rsync\nrsync -avz --delete \"$source_dir\u002F\" \"$destination_dir\u002F\"\necho \"Directories synchronized successfully.\"\n```\n\n**Data Cleanup Script**\n```bash\n#!\u002Fbin\u002Fbash\ndirectory=\"${1:-\u002Ftmp}\"\ndays=\"${2:-7}\"\n\necho \"Cleaning files older than $days days in $directory\"\n\n# Remove files older than specified days\nfind \"$directory\" -type f -mtime +\"$days\" -exec rm -v {} \\;\necho \"Cleanup completed.\"\n```\n\n**Folder Size Checker**\n```bash\n#!\u002Fbin\u002Fbash\nfolder_path=\"${1:-.}\"\n\necho \"Folder Size Analysis: $folder_path\"\necho \"====================================\"\n\n# Display sizes of subdirectories sorted by size\ndu -sh \"$folder_path\"\u002F* 2>\u002Fdev\u002Fnull | sort -rh | head -20\necho \"\"\necho \"Total size:\"\ndu -sh \"$folder_path\"\n```\n\n### Phase 9: System Information\n\n**System Info Collector**\n```bash\n#!\u002Fbin\u002Fbash\noutput_file=\"system_info_$(hostname)_$(date +%Y%m%d).txt\"\n\n{\n    echo \"System Information Report\"\n    echo \"Generated: $(date)\"\n    echo \"=========================\"\n    echo \"\"\n    echo \"Hostname: $(hostname)\"\n    echo \"OS: $(uname -a)\"\n    echo \"\"\n    echo \"CPU Info:\"\n    lscpu | grep -E \"Model name|CPU\\(s\\)|Thread\"\n    echo \"\"\n    echo \"Memory:\"\n    free -h\n    echo \"\"\n    echo \"Disk Space:\"\n    df -h\n    echo \"\"\n    echo \"Network Interfaces:\"\n    ip -br addr\n    echo \"\"\n    echo \"Logged In Users:\"\n    who\n} > \"$output_file\"\n\necho \"System info saved to $output_file\"\n```\n\n### Phase 10: Git and Development\n\n**Git Repository Updater**\n```bash\n#!\u002Fbin\u002Fbash\ngit_repos=(\"\u002Fpath\u002Fto\u002Frepo1\" \"\u002Fpath\u002Fto\u002Frepo2\")\n\nfor repo in \"${git_repos[@]}\"; do\n    if [ -d \"$repo\u002F.git\" ]; then\n        echo \"Updating repository: $repo\"\n        cd \"$repo\"\n        git fetch --all\n        git pull origin \"$(git branch --show-current)\"\n        echo \"Updated: $repo\"\n    else\n        echo \"Not a git repository: $repo\"\n    fi\ndone\n\necho \"All repositories updated.\"\n```\n\n**Remote Script Execution**\n```bash\n#!\u002Fbin\u002Fbash\nremote_server=\"${1:-user@remote-server}\"\nremote_script=\"${2:-\u002Fpath\u002Fto\u002Fremote\u002Fscript.sh}\"\n\n# Execute a script on a remote server via SSH\nssh \"$remote_server\" \"bash -s\" \u003C \"$remote_script\"\necho \"Remote script executed on $remote_server\"\n```\n\n## Quick Reference\n\n### Common Script Patterns\n\n| Pattern | Purpose |\n|---------|---------|\n| `#!\u002Fbin\u002Fbash` | Shebang for bash |\n| `$(date +%Y%m%d)` | Date formatting |\n| `$((expression))` | Arithmetic |\n| `${var:-default}` | Default value |\n| `\"$@\"` | All arguments |\n\n### Useful Commands\n\n| Command | Purpose |\n|---------|---------|\n| `chmod +x script.sh` | Make executable |\n| `.\u002Fscript.sh` | Run script |\n| `nohup .\u002Fscript.sh &` | Run in background |\n| `crontab -e` | Edit cron jobs |\n| `source script.sh` | Run in current shell |\n\n### Cron Format\nMinute(0-59) Hour(0-23) Day(1-31) Month(1-12) Weekday(0-7, 0\u002F7=Sun)\n\n## Constraints and Limitations\n\n- Always test scripts in non-production first\n- Use absolute paths to avoid errors\n- Quote variables to handle spaces properly\n- Many scripts require root\u002Fsudo privileges\n- Use `bash -x script.sh` for debugging\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n","# Linux Production Shell Scripts\n\n## Purpose\n\nProvide production-ready shell script templates for common Linux system administration tasks including backups, monitoring, user management, log analysis, and automation. These scripts serve as building blocks for security operations and penetration testing environments.\n\n## Prerequisites\n\n### Required Environment\n- Linux\u002FUnix system (bash shell)\n- Appropriate permissions for tasks\n- Required utilities installed (rsync, openssl, etc.)\n\n### Required Knowledge\n- Basic bash scripting\n- Linux file system structure\n- System administration concepts\n\n## Outputs and Deliverables\n\n1. **Backup Solutions** - Automated file and database backups\n2. **Monitoring Scripts** - Resource usage tracking\n3. **Automation Tools** - Scheduled task execution\n4. **Security Scripts** - Password management, encryption\n\n## Core Workflow\n\n### Phase 1: File Backup Scripts\n\n**Basic Directory Backup**\n```bash\n#!\u002Fbin\u002Fbash\nbackup_dir=\"\u002Fpath\u002Fto\u002Fbackup\"\nsource_dir=\"\u002Fpath\u002Fto\u002Fsource\"\n\n# Create a timestamped backup of the source directory\ntar -czf \"$backup_dir\u002Fbackup_$(date +%Y%m%d_%H%M%S).tar.gz\" \"$source_dir\"\necho \"Backup completed: backup_$(date +%Y%m%d_%H%M%S).tar.gz\"\n```\n\n**Remote Server Backup**\n```bash\n#!\u002Fbin\u002Fbash\nsource_dir=\"\u002Fpath\u002Fto\u002Fsource\"\nremote_server=\"user@remoteserver:\u002Fpath\u002Fto\u002Fbackup\"\n\n# Backup files\u002Fdirectories to a remote server using rsync\nrsync -avz --progress \"$source_dir\" \"$remote_server\"\necho \"Files backed up to remote server.\"\n```\n\n**Backup Rotation Script**\n```bash\n#!\u002Fbin\u002Fbash\nbackup_dir=\"\u002Fpath\u002Fto\u002Fbackups\"\nmax_backups=5\n\n# Rotate backups by deleting the oldest if more than max_backups\nwhile [ $(ls -1 \"$backup_dir\" | wc -l) -gt \"$max_backups\" ]; do\n    oldest_backup=$(ls -1t \"$backup_dir\" | tail -n 1)\n    rm -r \"$backup_dir\u002F$oldest_backup\"\n    echo \"Removed old backup: $oldest_backup\"\ndone\necho \"Backup rotation completed.\"\n```\n\n**Database Backup Script**\n```bash\n#!\u002Fbin\u002Fbash\ndatabase_name=\"your_database\"\ndb_user=\"username\"\ndb_pass=\"password\"\noutput_file=\"database_backup_$(date +%Y%m%d).sql\"\n\n# Perform database backup using mysqldump\nmysqldump -u \"$db_user\" -p\"$db_pass\" \"$database_name\" > \"$output_file\"\ngzip \"$output_file\"\necho \"Database backup created: $output_file.gz\"\n```\n\n### Phase 2: System Monitoring Scripts\n\n**CPU Usage Monitor**\n```bash\n#!\u002Fbin\u002Fbash\nthreshold=90\n\n# Monitor CPU usage and trigger alert if threshold exceeded\ncpu_usage=$(top -bn1 | grep \"Cpu(s)\" | awk '{print $2}' | cut -d. -f1)\n\nif [ \"$cpu_usage\" -gt \"$threshold\" ]; then\n    echo \"ALERT: High CPU usage detected: $cpu_usage%\"\n    # Add notification logic (email, slack, etc.)\n    # mail -s \"CPU Alert\" admin@example.com \u003C\u003C\u003C \"CPU usage: $cpu_usage%\"\nfi\n```\n\n**Disk Space Monitor**\n```bash\n#!\u002Fbin\u002Fbash\nthreshold=90\npartition=\"\u002Fdev\u002Fsda1\"\n\n# Monitor disk usage and trigger alert if threshold exceeded\ndisk_usage=$(df -h | grep \"$partition\" | awk '{print $5}' | cut -d% -f1)\n\nif [ \"$disk_usage\" -gt \"$threshold\" ]; then\n    echo \"ALERT: High disk usage detected: $disk_usage%\"\n    # Add alert\u002Fnotification logic here\nfi\n```\n\n**CPU Usage Logger**\n```bash\n#!\u002Fbin\u002Fbash\noutput_file=\"cpu_usage_log.txt\"\n\n# Log current CPU usage to a file with timestamp\ntimestamp=$(date '+%Y-%m-%d %H:%M:%S')\ncpu_usage=$(top -bn1 | grep 'Cpu(s)' | awk '{print $2}' | cut -d. -f1)\necho \"$timestamp - CPU Usage: $cpu_usage%\" >> \"$output_file\"\necho \"CPU usage logged.\"\n```\n\n**System Health Check**\n```bash\n#!\u002Fbin\u002Fbash\noutput_file=\"system_health_check.txt\"\n\n# Perform system health check and save results to a file\n{\n    echo \"System Health Check - $(date)\"\n    echo \"================================\"\n    echo \"\"\n    echo \"Uptime:\"\n    uptime\n    echo \"\"\n    echo \"Load Average:\"\n    cat \u002Fproc\u002Floadavg\n    echo \"\"\n    echo \"Memory Usage:\"\n    free -h\n    echo \"\"\n    echo \"Disk Usage:\"\n    df -h\n    echo \"\"\n    echo \"Top Processes:\"\n    ps aux --sort=-%cpu | head -10\n} > \"$output_file\"\n\necho \"System health check saved to $output_file\"\n```\n\n### Phase 3: User Management Scripts\n\n**User Account Creation**\n```bash\n#!\u002Fbin\u002Fbash\nusername=\"newuser\"\n\n# Check if user exists; if not, create new user\nif id \"$username\" &>\u002Fdev\u002Fnull; then\n    echo \"User $username already exists.\"\nelse\n    useradd -m -s \u002Fbin\u002Fbash \"$username\"\n    echo \"User $username created.\"\n    \n    # Set password interactively\n    passwd \"$username\"\nfi\n```\n\n**Password Expiry Checker**\n```bash\n#!\u002Fbin\u002Fbash\noutput_file=\"password_expiry_report.txt\"\n\n# Check password expiry for users with bash shell\necho \"Password Expiry Report - $(date)\" > \"$output_file\"\necho \"=================================\" >> \"$output_file\"\n\nIFS=$'\\n'\nfor user in $(grep \"\u002Fbin\u002Fbash\" \u002Fetc\u002Fpasswd | cut -d: -f1); do\n    password_expires=$(chage -l \"$user\" 2>\u002Fdev\u002Fnull | grep \"Password expires\" | awk -F: '{print $2}')\n    echo \"User: $user - Password Expires: $password_expires\" >> \"$output_file\"\ndone\nunset IFS\n\necho \"Password expiry report saved to $output_file\"\n```\n\n### Phase 4: Security Scripts\n\n**Password Generator**\n```bash\n#!\u002Fbin\u002Fbash\nlength=${1:-16}\n\n# Generate a random password\npassword=$(openssl rand -base64 48 | tr -dc 'a-zA-Z0-9!@#$%^&*' | head -c\"$length\")\necho \"Generated password: $password\"\n```\n\n**File Encryption Script**\n```bash\n#!\u002Fbin\u002Fbash\nfile=\"$1\"\naction=\"${2:-encrypt}\"\n\nif [ -z \"$file\" ]; then\n    echo \"Usage: $0 \u003Cfile> [encrypt|decrypt]\"\n    exit 1\nfi\n\nif [ \"$action\" == \"encrypt\" ]; then\n    # Encrypt file using AES-256-CBC\n    openssl enc -aes-256-cbc -salt -pbkdf2 -in \"$file\" -out \"$file.enc\"\n    echo \"File encrypted: $file.enc\"\nelif [ \"$action\" == \"decrypt\" ]; then\n    # Decrypt file\n    output_file=\"${file%.enc}\"\n    openssl enc -aes-256-cbc -d -pbkdf2 -in \"$file\" -out \"$output_file\"\n    echo \"File decrypted: $output_file\"\nfi\n```\n\n### Phase 5: Log Analysis Scripts\n\n**Error Log Extractor**\n```bash\n#!\u002Fbin\u002Fbash\nlogfile=\"${1:-\u002Fvar\u002Flog\u002Fsyslog}\"\noutput_file=\"error_log_$(date +%Y%m%d).txt\"\n\n# Extract lines with \"ERROR\" from the log file\ngrep -i \"error\\|fail\\|critical\" \"$logfile\" > \"$output_file\"\necho \"Error log created: $output_file\"\necho \"Total errors found: $(wc -l \u003C \"$output_file\")\"\n```\n\n**Web Server Log Analyzer**\n```bash\n#!\u002Fbin\u002Fbash\nlog_file=\"${1:-\u002Fvar\u002Flog\u002Fapache2\u002Faccess.log}\"\n\necho \"Web Server Log Analysis\"\necho \"========================\"\necho \"\"\necho \"Top 10 IP Addresses:\"\nawk '{print $1}' \"$log_file\" | sort | uniq -c | sort -rn | head -10\necho \"\"\necho \"Top 10 Requested URLs:\"\nawk '{print $7}' \"$log_file\" | sort | uniq -c | sort -rn | head -10\necho \"\"\necho \"HTTP Status Code Distribution:\"\nawk '{print $9}' \"$log_file\" | sort | uniq -c | sort -rn\n```\n\n### Phase 6: Network Scripts\n\n**Network Connectivity Checker**\n```bash\n#!\u002Fbin\u002Fbash\nhosts=(\"8.8.8.8\" \"1.1.1.1\" \"google.com\")\n\necho \"Network Connectivity Check\"\necho \"==========================\"\n\nfor host in \"${hosts[@]}\"; do\n    if ping -c 1 -W 2 \"$host\" &>\u002Fdev\u002Fnull; then\n        echo \"[UP] $host is reachable\"\n    else\n        echo \"[DOWN] $host is unreachable\"\n    fi\ndone\n```\n\n**Website Uptime Checker**\n```bash\n#!\u002Fbin\u002Fbash\nwebsites=(\"https:\u002F\u002Fgoogle.com\" \"https:\u002F\u002Fgithub.com\")\nlog_file=\"uptime_log.txt\"\n\necho \"Website Uptime Check - $(date)\" >> \"$log_file\"\n\nfor website in \"${websites[@]}\"; do\n    if curl --output \u002Fdev\u002Fnull --silent --head --fail --max-time 10 \"$website\"; then\n        echo \"[UP] $website is accessible\" | tee -a \"$log_file\"\n    else\n        echo \"[DOWN] $website is inaccessible\" | tee -a \"$log_file\"\n    fi\ndone\n```\n\n**Network Interface Info**\n```bash\n#!\u002Fbin\u002Fbash\ninterface=\"${1:-eth0}\"\n\necho \"Network Interface Information: $interface\"\necho \"=========================================\"\nip addr show \"$interface\" 2>\u002Fdev\u002Fnull || ifconfig \"$interface\" 2>\u002Fdev\u002Fnull\necho \"\"\necho \"Routing Table:\"\nip route | grep \"$interface\"\n```\n\n### Phase 7: Automation Scripts\n\n**Automated Package Installation**\n```bash\n#!\u002Fbin\u002Fbash\npackages=(\"vim\" \"htop\" \"curl\" \"wget\" \"git\")\n\necho \"Installing packages...\"\n\nfor package in \"${packages[@]}\"; do\n    if dpkg -l | grep -q \"^ii  $package\"; then\n        echo \"[SKIP] $package is already installed\"\n    else\n        sudo apt-get install -y \"$package\"\n        echo \"[INSTALLED] $package\"\n    fi\ndone\n\necho \"Package installation completed.\"\n```\n\n**Task Scheduler (Cron Setup)**\n```bash\n#!\u002Fbin\u002Fbash\nscheduled_task=\"\u002Fpath\u002Fto\u002Fyour_script.sh\"\nschedule_time=\"0 2 * * *\"  # Run at 2 AM daily\n\n# Add task to crontab\n(crontab -l 2>\u002Fdev\u002Fnull; echo \"$schedule_time $scheduled_task\") | crontab -\necho \"Task scheduled: $schedule_time $scheduled_task\"\n```\n\n**Service Restart Script**\n```bash\n#!\u002Fbin\u002Fbash\nservice_name=\"${1:-apache2}\"\n\n# Restart a specified service\nif systemctl is-active --quiet \"$service_name\"; then\n    echo \"Restarting $service_name...\"\n    sudo systemctl restart \"$service_name\"\n    echo \"Service $service_name restarted.\"\nelse\n    echo \"Service $service_name is not running. Starting...\"\n    sudo systemctl start \"$service_name\"\n    echo \"Service $service_name started.\"\nfi\n```\n\n### Phase 8: File Operations\n\n**Directory Synchronization**\n```bash\n#!\u002Fbin\u002Fbash\nsource_dir=\"\u002Fpath\u002Fto\u002Fsource\"\ndestination_dir=\"\u002Fpath\u002Fto\u002Fdestination\"\n\n# Synchronize directories using rsync\nrsync -avz --delete \"$source_dir\u002F\" \"$destination_dir\u002F\"\necho \"Directories synchronized successfully.\"\n```\n\n**Data Cleanup Script**\n```bash\n#!\u002Fbin\u002Fbash\ndirectory=\"${1:-\u002Ftmp}\"\ndays=\"${2:-7}\"\n\necho \"Cleaning files older than $days days in $directory\"\n\n# Remove files older than specified days\nfind \"$directory\" -type f -mtime +\"$days\" -exec rm -v {} \\;\necho \"Cleanup completed.\"\n```\n\n**Folder Size Checker**\n```bash\n#!\u002Fbin\u002Fbash\nfolder_path=\"${1:-.}\"\n\necho \"Folder Size Analysis: $folder_path\"\necho \"====================================\"\n\n# Display sizes of subdirectories sorted by size\ndu -sh \"$folder_path\"\u002F* 2>\u002Fdev\u002Fnull | sort -rh | head -20\necho \"\"\necho \"Total size:\"\ndu -sh \"$folder_path\"\n```\n\n### Phase 9: System Information\n\n**System Info Collector**\n```bash\n#!\u002Fbin\u002Fbash\noutput_file=\"system_info_$(hostname)_$(date +%Y%m%d).txt\"\n\n{\n    echo \"System Information Report\"\n    echo \"Generated: $(date)\"\n    echo \"=========================\"\n    echo \"\"\n    echo \"Hostname: $(hostname)\"\n    echo \"OS: $(uname -a)\"\n    echo \"\"\n    echo \"CPU Info:\"\n    lscpu | grep -E \"Model name|CPU\\(s\\)|Thread\"\n    echo \"\"\n    echo \"Memory:\"\n    free -h\n    echo \"\"\n    echo \"Disk Space:\"\n    df -h\n    echo \"\"\n    echo \"Network Interfaces:\"\n    ip -br addr\n    echo \"\"\n    echo \"Logged In Users:\"\n    who\n} > \"$output_file\"\n\necho \"System info saved to $output_file\"\n```\n\n### Phase 10: Git and Development\n\n**Git Repository Updater**\n```bash\n#!\u002Fbin\u002Fbash\ngit_repos=(\"\u002Fpath\u002Fto\u002Frepo1\" \"\u002Fpath\u002Fto\u002Frepo2\")\n\nfor repo in \"${git_repos[@]}\"; do\n    if [ -d \"$repo\u002F.git\" ]; then\n        echo \"Updating repository: $repo\"\n        cd \"$repo\"\n        git fetch --all\n        git pull origin \"$(git branch --show-current)\"\n        echo \"Updated: $repo\"\n    else\n        echo \"Not a git repository: $repo\"\n    fi\ndone\n\necho \"All repositories updated.\"\n```\n\n**Remote Script Execution**\n```bash\n#!\u002Fbin\u002Fbash\nremote_server=\"${1:-user@remote-server}\"\nremote_script=\"${2:-\u002Fpath\u002Fto\u002Fremote\u002Fscript.sh}\"\n\n# Execute a script on a remote server via SSH\nssh \"$remote_server\" \"bash -s\" \u003C \"$remote_script\"\necho \"Remote script executed on $remote_server\"\n```\n\n## Quick Reference\n\n### Common Script Patterns\n\n| Pattern | Purpose |\n|---------|---------|\n| `#!\u002Fbin\u002Fbash` | Shebang for bash |\n| `$(date +%Y%m%d)` | Date formatting |\n| `$((expression))` | Arithmetic |\n| `${var:-default}` | Default value |\n| `\"$@\"` | All arguments |\n\n### Useful Commands\n\n| Command | Purpose |\n|---------|---------|\n| `chmod +x script.sh` | Make executable |\n| `.\u002Fscript.sh` | Run script |\n| `nohup .\u002Fscript.sh &` | Run in background |\n| `crontab -e` | Edit cron jobs |\n| `source script.sh` | Run in current shell |\n\n### Cron Format\nMinute(0-59) Hour(0-23) Day(1-31) Month(1-12) Weekday(0-7, 0\u002F7=Sun)\n\n## Constraints and Limitations\n\n- Always test scripts in non-production first\n- Use absolute paths to avoid errors\n- Quote variables to handle spaces properly\n- Many scripts require root\u002Fsudo privileges\n- Use `bash -x script.sh` for debugging\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n",{"name":5,"risk":24,"author":25,"source":26,"date_added":27,"description":7},"unknown","zebbern","community","2026-02-27","main","b30820b3248f6676d5389f0ccabd4e5250c9c536","skills\u002Flinux-shell-scripting","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack","https:\u002F\u002Fgithub.com\u002Fkalash33","kalashpoddar.me","Tech-savvy Full Stack Developer 🚀 | Cybersecurity enthusiast 🔒 | Passionate about innovation and securing the digital world 🌐 | Let's code securely! 💻🔐","2026-05-20 04:11:22",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add kalash33\u002Fkstack --skill linux-shell-scripting",{"tool":42,"command":43},"bunx","bunx skills add kalash33\u002Fkstack --skill linux-shell-scripting",{"tool":45,"command":46},"pnpm","pnpm dlx skills add kalash33\u002Fkstack --skill linux-shell-scripting","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Flinux-shell-scripting\u002FSKILL.md",true,[],[51,58,65,72,79,86],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M73CFERCR43JCAP606E41EFB","zustand-store-ts","Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state\u002Faction separation. Use when building React state management, creating global stores, or implementing reacti...","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-ts\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M73CFCMFVTAQEMTZ5HR10X8V","zoom-automation","Automate Zoom meeting creation, management, recordings, webinars, and participant tracking via Rube MCP (Composio). Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzoom-automation\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M73CFAA7EBWXJVXDQ1X555MB","zoho-crm-automation","Automate Zoho CRM tasks via Rube MCP (Composio): create\u002Fupdate records, search contacts, manage leads, and convert leads. Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzoho-crm-automation\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M73CF80XCM9K81567MJ8QZFW","zod-validation-expert","Expert in Zod — TypeScript-first schema validation. Covers parsing, custom errors, refinements, type inference, and integration with React Hook Form, Next.js, and tRPC.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzod-validation-expert\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M73CF4YPMF3RA8ZJDXZSMD93","zeroize-audit","Detects missing zeroization of sensitive data in source code and identifies zeroization removed by compiler optimizations, with assembly-level analysis, and control-flow verification. Use for auditing C\u002FC++\u002FRust code handling secrets, keys, passwords, or other sensitive data.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzeroize-audit\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M73CF2S25EN3XNAMKY47XHPS","zendesk-automation","Automate Zendesk tasks via Rube MCP (Composio): tickets, users, organizations, replies. Always search tools first for current schemas.","https:\u002F\u002Fgithub.com\u002Fkalash33\u002Fkstack\u002Fblob\u002Fmain\u002Fskills\u002Fzendesk-automation\u002FSKILL.md",[],[]]