Skip to content

Instantly share code, notes, and snippets.

@TimelessP
Created March 29, 2018 08:40
Show Gist options
  • Save TimelessP/a8d8d75cc49d4feaf456cfad9884dbad to your computer and use it in GitHub Desktop.
Save TimelessP/a8d8d75cc49d4feaf456cfad9884dbad to your computer and use it in GitHub Desktop.
Updates Debian/Ubuntu/Linux Mint and auto-removes unused kernels to keep the boot partition from running out of space.
#!/bin/bash
# Run this script as root.
# Break on any errors.
set -e
apt-get update
dpkg --configure -a
apt-get -y autoremove
echo "Uninstalling all but the current kernel - $(uname -r)..."
apt-get -y remove `dpkg --get-selections | egrep "(linux-image-|linux-headers-|linux-image-extra-)" | grep -v "$(uname -r)" | sed "s/\t.*//gi" | tr '\n' ' '`
apt-get -y upgrade
apt-get -y dist-upgrade
echo "That went well."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment