[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CKYAVAZ4FF9WTTYVG0Y8CF":3,"skill-same:01M7CKYAVAZ4FF9WTTYVG0Y8CF":51},{"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":31,"repositoryHtmlUrl":32,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M7CKYAVAZ4FF9WTTYVG0Y8CF","linux-shell-scripting",null,"Provide 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.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Skills-技能包\u002FYYC3-Skills-技能包-antigravity-awesome-skills\u002Fskills\u002Flinux-shell-scripting\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: linux-shell-scripting\ndescription: \"Provide 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.\"\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","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-Skills-技能包\u002FYYC3-Skills-技能包-antigravity-awesome-skills\u002Fskills\u002Flinux-shell-scripting",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill linux-shell-scripting",{"tool":43,"command":44},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill linux-shell-scripting",{"tool":46,"command":47},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill linux-shell-scripting","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Skills-技能包\u002FYYC3-Skills-技能包-antigravity-awesome-skills\u002Fskills\u002Flinux-shell-scripting\u002FSKILL.md",true,[],[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]