Skip to content

Instantly share code, notes, and snippets.

@Bengt
Last active July 19, 2023 10:19
Show Gist options
  • Save Bengt/e545f797474c6aca4e0d571bb3ea2a4c to your computer and use it in GitHub Desktop.
Save Bengt/e545f797474c6aca4e0d571bb3ea2a4c to your computer and use it in GitHub Desktop.
#!/bin/bash
apt update && \
apt upgrade --yes && \
apt autoremove --yes --purge && \
apt autoclean --yes && \
snap refresh
#!/bin/bash
sudo apt update && \
sudo apt upgrade --yes && \
sudo apt autoremove --yes --purge && \
sudo apt autoclean --yes && \
sudo snap refresh
# Aliases for updating all packages
alias update="sudo apt update && \
sudo apt upgrade --yes && \
sudo apt autoremove --yes --purge && \
sudo snap refresh"
alias upgrade="update"

YOLO Update

Update all Linux packages. Don't look back.

Assumptions

  • This assumes you are using the preinstalled Bash shell under Ubuntu.

Usage (without installation)

As root:

bash <(wget -qO- https://gist.githubusercontent.com/Bengt/e545f797474c6aca4e0d571bb3ea2a4c/raw/update-ubuntu-root-script.sh)

As user:

bash <(wget -qO- https://gist.githubusercontent.com/Bengt/e545f797474c6aca4e0d571bb3ea2a4c/raw/update-ubuntu-user-script.sh)

Installation (for the current shell of the current user)

source <(wget -qO- https://gist.githubusercontent.com/Bengt/e545f797474c6aca4e0d571bb3ea2a4c/raw/update-ubuntu-user.sh)

Installation (for all future shells of the current user)

wget -qO- https://gist.githubusercontent.com/Bengt/e545f797474c6aca4e0d571bb3ea2a4c/raw/update-ubuntu-user.sh >> ~/.bashrc

Installation (permanently for all users)

sudo wget -q https://gist.githubusercontent.com/Bengt/e545f797474c6aca4e0d571bb3ea2a4c/raw/update-ubuntu-root-script.sh -O /usr/local/sbin/update && \
sudo chmod +x /usr/local/sbin/update

Usage

update

Automation

echo "0  8,20 * * *   root    /usr/local/sbin/update  # Update at 8:00 and 20:00" | sudo tee -a /etc/crontab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment