A collection of standalone bash scripts for daily Linux system administration tasks. Each script is independent, requires no configuration files, and can be executed on its own.
- Features
- Quick Start
- Scripts Overview
- Installation
- Usage Examples
- Cron Setup
- Script Details
- Tips & Tricks
- Troubleshooting
- Customization
- License
- 16 standalone scripts - Each works independently
- No configuration files - Everything is self-contained
- Color-coded output - Easy to read at a glance
- Safe operations - Dry-run modes for destructive actions
- Cross-distro - Works on Ubuntu, Debian, RHEL, CentOS, Fedora
- Production-ready - Used in real-world environments
- Zero dependencies - Only uses standard Linux tools
# Clone or download the scripts
cd ~
mkdir sysadmin-tools
cd sysadmin-tools
# Download all scripts (or copy them manually)
# Then make them executable
chmod +x *.sh
# Run a quick health check
./check-system.sh
# Run the full daily report
./daily-report.sh| Script | Description | Use Case |
|---|---|---|
| daily-report.sh | Master wrapper - runs all checks | Daily morning report |
| check-system.sh | CPU, memory, load, uptime | Quick health check |
| check-disk.sh | Disk space, inodes, large files | Storage monitoring |
| check-load.sh | Detailed CPU & load stats | Performance analysis |
| check-services.sh | Service status | Verify critical services |
| check-network.sh | Connectivity, DNS, interfaces | Network troubleshooting |
| check-ports.sh | Open ports & listening services | Security audit |
| check-security.sh | Failed logins, user audit | Security monitoring |
| check-users.sh | User accounts, sudoers, logins | User management |
| check-failed-logins.sh | SSH attack analysis | Security incident response |
| check-cron.sh | Cron job status | Scheduled task monitoring |
| check-logs.sh | Error log analysis | Troubleshooting |
| check-ssl.sh | Certificate expiry | SSL certificate monitoring |
| check-backups.sh | Backup status | Backup verification |
| check-updates.sh | Available updates | Patch management |
| cleanup-system.sh | Temp files, caches, logs | System maintenance |
# Create directory
mkdir -p ~/sysadmin-tools
cd ~/sysadmin-tools
# Create each script file (copy content from this README)
# ... or download from repository ...
# Make executable
chmod +x *.shgit clone https://github.com/yourusername/sysadmin-tools.git ~/sysadmin-tools
cd ~/sysadmin-tools
chmod +x *.shAdd to your ~/.bashrc or ~/.zshrc:
# SysAdmin Tools Aliases
alias health='~/sysadmin-tools/check-system.sh'
alias disk='~/sysadmin-tools/check-disk.sh'
alias services='~/sysadmin-tools/check-services.sh'
alias security='~/sysadmin-tools/check-security.sh'
alias backup='~/sysadmin-tools/check-backups.sh'
alias ssl='~/sysadmin-tools/check-ssl.sh'
alias cleanup='~/sysadmin-tools/cleanup-system.sh --dry-run'
alias clean='~/sysadmin-tools/cleanup-system.sh'
alias daily='~/sysadmin-tools/daily-report.sh'Then reload: source ~/.bashrc
# Quick health check
./check-system.sh
# Check disk space
./check-disk.sh
# Check specific domain SSL
./check-ssl.sh google.com
# Check SSL on custom port
./check-ssl.sh api.example.com 8443# Full daily report
./daily-report.sh
# Quick report (skips time-consuming checks)
./daily-report.sh --quick
# Report with email notification
./daily-report.sh --email
# Save report to custom location
./daily-report.sh --output /var/log/reports/daily.txt
# Cleanup with dry-run (see what would be deleted)
./cleanup-system.sh --dry-run
# Aggressive cleanup (removes older logs)
./cleanup-system.sh --aggressive
# Check logs from last 48 hours
./check-logs.sh --hours 48# Check everything and email the report
./daily-report.sh --email
# Quick health check and save to file
./daily-report.sh --quick --output /tmp/health.txt
# Check disk and security together
./check-disk.sh && ./check-security.sh# Edit crontab
crontab -e
# Add this line
0 8 * * * /home/username/sysadmin-tools/daily-report.sh --email --output /var/log/daily-report-$(date +\%Y\%m\%d).txt# Every hour at minute 15
15 * * * * /home/username/sysadmin-tools/check-system.sh > /dev/null 2>&10 2 * * 0 /home/username/sysadmin-tools/cleanup-system.sh --aggressive0 9 * * * /home/username/sysadmin-tools/check-ssl.sh | grep -q "CRITICAL\|EXPIRED" && mail -s "SSL Alert" admin@example.comRuns all other scripts and generates a comprehensive report.
Options:
--quick- Skip time-consuming checks (backups, SSL, updates)--email- Send report via email--output FILE- Save report to custom file
Example: ./daily-report.sh --quick --email
Displays uptime, load average, memory usage, and top processes.
Output includes:
- System uptime and kernel version
- Load average vs CPU cores
- Memory usage with warning thresholds
- OOM killer events
- Top 5 CPU and memory consuming processes
Shows disk usage, inode usage, and large files.
Output includes:
- Partition usage with warnings at 70% and 85%
- Inode usage warnings
- Top 5 largest directories
- Files > 500MB
Checks common system services.
Services checked:
- SSH/SSHD
- Web servers (nginx, apache, httpd)
- Databases (mysql, postgresql)
- Docker, Kubernetes
- Cron, syslog, firewall
- Fail2ban, Prometheus, Grafana
Checks SSL/TLS certificate expiration.
Features:
- Check local certificate files
- Check remote domains:
./check-ssl.sh example.com - Check custom port:
./check-ssl.sh example.com 8443 - Shows days remaining with color coding
Locations scanned:
/etc/ssl/certs/etc/letsencrypt/live/etc/pki/tls/certs- Web server configurations
Safely removes temporary files and caches.
Options:
--dry-run- Preview what would be deleted--aggressive- Remove older logs and more files
What it cleans:
/tmpand/var/tmpfiles older than 3 days- Package manager cache (apt/dnf/yum)
- User trash directories
- Core dumps
- (Aggressive) Logs older than 30 days
Comprehensive security checks.
Checks:
- Failed SSH login attempts (last 24h)
- Users with UID 0 (root privileges)
- Users with empty passwords
- Recent sudo attempts
- Kernel vulnerability warnings
Network connectivity and performance.
Checks:
- Network interfaces and IPs
- Default gateway
- DNS servers
- Internet connectivity (8.8.8.8)
- DNS resolution
- Packet loss to gateway
Lists listening ports and services.
Output includes:
- TCP ports with service names
- UDP ports
- Common service status (SSH, HTTP, MySQL, etc.)
Checks backup status and integrity.
Checks:
- Common backup directories
- Latest backup age
- Backup tools installed
- Recent backup errors in logs
Monitors scheduled tasks.
Output includes:
- Cron service status
- System and user crontabs
- Jobs scheduled to run daily
- Recent cron logs
Analyzes system logs for errors.
Options:
--hours N- Check last N hours (default 24)
Checks:
- Systemd journal errors and warnings
- Syslog errors
- Application logs (Nginx, Apache, MySQL, PostgreSQL)
- Log rotation status
Detailed CPU and load analysis.
Output includes:
- CPU information (cores, model, speed)
- Load average with percentage of capacity
- Top CPU-consuming processes
- System CPU statistics
- Process counts with zombie detection
Analyzes failed login attempts.
Checks:
- Failed SSH attempts count
- Invalid username attempts
- Top attacking IPs
- Recent failures
- Fail2ban status
- SSH configuration hardening
Audits user accounts and activity.
Output includes:
- Total users and users with shells
- System users with shell access
- Recent and current logins
- Users with root privileges (sudoers)
- Last password changes
Checks for available system updates.
Features:
- Detects package manager (apt/dnf/yum)
- Shows number of available updates
- Highlights security updates
- Shows kernel updates requiring reboot
# Create a custom dashboard script
cat > ~/dashboard.sh << 'EOF'
#!/bin/bash
clear
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β SYSTEM DASHBOARD β"
echo "β βββββββββββββββββββββββββββββββββββββββββββββββββ£"
./check-system.sh | head -20
echo "β βββββββββββββββββββββββββββββββββββββββββββββββββ£"
./check-disk.sh | head -10
echo "β βββββββββββββββββββββββββββββββββββββββββββββββββ£"
./check-services.sh | head -10
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββ"
EOF
chmod +x ~/dashboard.sh# One-liner status
echo "Load: $(uptime | awk -F'load average:' '{print $2}') | Disk: $(df -h / | tail -1 | awk '{print $5}') | Services: $(systemctl --failed | wc -l) failed"# Update every 5 seconds
watch -n 5 ./check-system.sh
# Update every 2 seconds
watch -n 2 ./check-services.sh# Alert if disk > 90%
./check-disk.sh | grep -q "90%" && echo "Disk alert!" | mail -s "Disk Warning" admin@example.comSome scripts require root privileges for full functionality:
# Run with sudo when needed
sudo ./check-users.sh
sudo ./cleanup-system.shIf a script reports a missing command:
# Ubuntu/Debian
sudo apt install util-linux sysstat net-tools
# RHEL/CentOS/Fedora
sudo dnf install util-linux sysstat net-toolschmod +x scriptname.shSome terminals may not support color codes. Remove the color definitions or set:
export TERM=xterm-256colorEdit the script variables directly:
# In check-disk.sh
DISK_WARNING=85 # Change to 90 for less strict
INODE_WARNING=85In check-services.sh, add to the services array:
services=(
# ... existing services ...
"your-custom-service"
"another-service"
)In check-backups.sh, modify the backup_dirs array:
backup_dirs=(
"/backup"
"/var/backups"
"/mnt/nas/backups" # Add your custom path
)MIT License - Free to use, modify, and distribute.
Feel free to:
- Report bugs
- Suggest improvements
- Add new scripts
- Share your customizations
For issues:
- Check the troubleshooting section
- Run scripts with
--helpfor options - Ensure all dependencies are installed
βββββββββββββββββββββββββββββββββββββββββββββ
SYSTEM HEALTH CHECK - myserver
2024-01-15 08:30:00
βββββββββββββββββββββββββββββββββββββββββββββ
βΆ UPTIME
08:30:00 up 45 days, 3:12, 2 users, load average: 0.08, 0.03, 0.01
Kernel: 5.15.0-91-generic
OS: Ubuntu 22.04.3 LTS
βΆ LOAD AVERAGE
Load: 0.08, 0.03, 0.01 (Cores: 8)
β
Load is normal
βΆ MEMORY
total used free shared buff/cache available
Mem: 15Gi 2.3Gi 10Gi 245Mi 2.6Gi 12Gi
β
Memory usage: 15%
βββββββββββββββββββββββββββββββββββββββββββββββββ
- All scripts are designed to be non-destructive (except cleanup with proper flags)
- Always test in a non-production environment first
- Review scripts before running with sudo
- Keep scripts updated for security fixes
- Share feedback and improvements
Happy SysAdmin-ing! π§π§