Created
March 3, 2024 18:37
-
-
Save darkmclo/80c2b2eac95ab9ed9d54e2853835479f to your computer and use it in GitHub Desktop.
Update and upgrade Debian packages with bash script
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 | |
# Also works in Debian-based distros such as Ubuntu and Linux Mint. | |
# Do NOT forget to set the script file with execution permissions: | |
# chmod -X update_debian_packages.sh | |
# Variables | |
## Path where the log file will be located | |
LOG_FILE_PATH="/var/tmp/update_log.txt" | |
echo "[(Root) privileges required]" | |
if sudo -nv 2>/dev/null && sudo -v ; then | |
sudo whoami | |
echo "[Running with appropriate privileges]" | |
else | |
echo "[Exiting...]" | |
exit | |
fi | |
echo "Last run" | tee $LOG_FILE_PATH | |
echo "-------------------------------------" | |
echo "Datetime: " | tee -a $LOG_FILE_PATH | |
date | tee -a $LOG_FILE_PATH | |
echo "-------------------------------------" | |
echo "--------------- UPDATING REPOSITORIES (APT) ---------------" | |
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - -" | |
sudo apt-get update -y | tee -a $LOG_FILE_PATH | |
echo "--------------- UPGRADING PACKAGES (APT) ---------------" | |
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - -" | |
sudo apt-get upgrade -y | tee -a $LOG_FILE_PATH | |
echo "--------------- UPGRADING PACKAGES (SNAP) ---------------" | |
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - -" | |
sudo snap refresh | tee -a $LOG_FILE_PATH | |
echo "--------------- UPGRADING PACKAGES (FLATPAK) ---------------" | |
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - -" | |
sudo flatpak update -y | tee -a $LOG_FILE_PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment