#!/bin/bash# Cleanup routine for clearing out old APT packages and caches on Linux Mint.# Ensure we are running with sudoif["$EUID"-ne0];thenecho"Please run as root (use sudo)"exit1fi# Purge only packages that are installed. If one name in an 'apt purge' list# doesn't exist, apt aborts the whole list, so filter first.purge_installed(){localpresent=()pkg
forpkgin"$@";dodpkg-query-W-f='${Status}'"$pkg"2>/dev/null|grep-q"install ok installed"&&present+=("$pkg")doneif[${#present[@]}-eq0];thenecho" (none installed)"return0fiaptpurge-y"${present[@]}"}MINT_VERSION=$(./etc/os-release2>/dev/null&&echo"${VERSION_ID:-}")echo"--- Starting Mint ${MINT_VERSION} Debloat (Safe Mode) ---"# 1. Remove Legacy/Insecure Network Toolsecho"Removing legacy network tools (telnet, etc)..."purge_installedtelnetftprsh-clienttalk
# 2. Remove "Common" Pre-installed Bloat# This targets apps most people replace or never use.echo"Removing common bloat apps..."purge_installed\hexchat\thunderbird\transmission-common\transmission-gtk\drawing\sticky\pix\hypnotix\thingy\warpinator\gnome-calendar\gnome-logs
# 3. Remove Default Gamesecho"Removing pre-installed games..."purge_installedgnome-chessfive-or-morefour-in-a-rowgnome-klotskignome-mahjongggnome-minesgnome-nibblesgnome-robotsgnome-sudokugnome-taquingnome-tetravexhitoriiagnolightsoffquadrapasseltaliswell-foop
# 4. Cleanup Unused Dependenciesecho"Cleaning up..."aptautoremove-y
aptclean
echo"--- Debloat Complete! ---"echo"Note: Printer (CUPS) and Bluetooth services were kept intact."echo" (security/hardening/mint-hardening.sh disables both, if you run that too.)"