Skip to content

Instantly share code, notes, and snippets.

@brandleesee
Last active January 27, 2024 07:19
Show Gist options
  • Save brandleesee/79ccf8f8bdffaebbd7d251ed8ae173f6 to your computer and use it in GitHub Desktop.
Save brandleesee/79ccf8f8bdffaebbd7d251ed8ae173f6 to your computer and use it in GitHub Desktop.
Ubuntu Update Script
clear && sudo apt update -y && sudo apt dist-upgrade -y && sudo apt install -f -y && sudo apt autoremove -y && sudo apt clean
@brandleesee
Copy link
Author

brandleesee commented Jan 14, 2024

Introduction

A short and functional maintainance script to update and upgrade the packages of an Ubuntu and Debian operating system.

Usage

Either add it as an alias or copy/paste the string of commangs in the terminal and run.

Remove any commands that are not desired including the subsequent &&.

List of Commands

clear removes any text occupying the terminal window or tty. Used to declutter the screen in preparation for the updates.
update refreshes the repositories from where packages are pulled to upgrade the system.
dist-upgrade is the command that updates all the packages and installs any required dependencies that allow those updated packages to run as intended.
autoremove removes packages, including dependencies, that are no longer required by the system.
clean deletes packages left in the system for backups.

Fail-Safe Mechanisms

Using && is my preferred method for a fail-safe mechanism where if the command being executed before that produces an error, the script stops its progress. The rationale behind this is to avoid further endagering the workstation.

-f is used as a secondary fail-safe mechanism should && not quit the script because of packages incorrectly installed. It repairs errors and ameliorates package dependencies produced by the `dist-upgrade' command.

Further Reading

https://wiki.debian.org/AptCLI
https://manpages.ubuntu.com/manpages/focal/man8/apt-get.8.html
https://debian-handbook.info/browse/stable/sect.apt-get.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment