Created
May 14, 2026 08:07
-
-
Save afsalrahim/3b800290edb77655a39a9380349e9922 to your computer and use it in GitHub Desktop.
Bash script for automated Ubuntu system maintenance. Handles package updates, full upgrades, dependency cleanup, and checks for required reboots.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # ================================================================= | |
| # DESCRIPTION: Automated Ubuntu/Debian System Maintenance | |
| # AUTHOR: Afsal Rahim | |
| # USAGE: sudo ./update.sh OR move to /usr/local/bin/ | |
| # ================================================================= | |
| # Define colors for better status visibility | |
| GREEN='\033[0;32m' | |
| BLUE='\033[0;34m' | |
| NC='\033[0m' | |
| echo -e "${BLUE}--- Starting System Update ---${NC}" | |
| # 1. Update package lists | |
| echo -e "${GREEN}Updating package lists...${NC}" | |
| sudo apt update | |
| # 2. Upgrade packages and dependencies (Includes kernel updates) | |
| echo -e "${GREEN}Performing full upgrade...${NC}" | |
| sudo apt full-upgrade -y | |
| # 3. Clean up obsolete packages and clear the cache | |
| echo -e "${GREEN}Cleaning up...${NC}" | |
| sudo apt autoremove -y | |
| sudo apt autoclean | |
| # 4. Check if reboot is needed (Required for Kernel/Libc updates) | |
| if [ -f /var/run/reboot-required ]; then | |
| echo -e "${BLUE}***************************************${NC}" | |
| echo -e "${BLUE}* REBOOT REQUIRED: System needs restart *${NC}" | |
| echo -e "${BLUE}***************************************${NC}" | |
| else | |
| echo -e "${GREEN}Update complete. No reboot required.${NC}" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment