Last active
August 3, 2022 18:39
-
-
Save gamesguru/f069d7ac732df26a678c49d47dede0fd to your computer and use it in GitHub Desktop.
Software updating script for Ubuntu/Debian (apt-based systems)
This file contains 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 | |
# A script for updating apt-based Linux distros | |
# ... put it in /usr/local/bin or anywhere in your $PATH | |
# Function to run | |
function run_update { | |
printf "\\n\e[1;31m%s\e[0m\\n" "apt update" | |
apt update | |
printf "\\n\e[1;31m%s\e[0m\\n" "apt dist-upgrade" | |
apt dist-upgrade | |
printf "\\n\e[1;31m%s\e[0m\\n" "apt autoremove" | |
apt autoremove | |
printf "\\n\e[1;31m%s\e[0m\\n" "dpkg -l | grep "^rc" | awk '{print \$2}' | xargs -r dpkg --purge" | |
dpkg -l | grep "^rc" | awk '{print $2}' | xargs -r dpkg --purge | |
printf "\\n\e[1;31m%s\e[0m\\n" "exit" | |
} | |
# Execute as sudo | |
printf "\\n\e[1;31m%s\e[0m\\n" "sudo su" | |
FUNC=$(declare -f run_update) | |
sudo bash -c "$FUNC; run_update" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment