Skip to content

Instantly share code, notes, and snippets.

@demirdegerli
Last active March 20, 2024 15:22
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save demirdegerli/b7087c84ef55a1909c21e4966659a2ba to your computer and use it in GitHub Desktop.
Save demirdegerli/b7087c84ef55a1909c21e4966659a2ba to your computer and use it in GitHub Desktop.
Ubuntu Debloater
#!/bin/sh
if [ "$(whoami)" != "root" ]; then
echo "Please run this script as root."
exit
fi
printf "This script will\n\n- Remove Snap\n- Install the deb version of Firefox\n- Install Flatpak\n- Optionally replace Ubuntu Desktop with GNOME\n\n"
read -p "Continue? (Y/n) " start_prompt
case $start_prompt in
[nN] | [nN][oO] )
exit
;;
esac
read -p "Do you want to replace Ubuntu Desktop with GNOME? (y/N) " de_prompt
systemctl disable snapd.service
systemctl disable snapd.socket
systemctl disable snapd.seeded.service
snap remove --purge $(snap list | awk '!/^Name/ {print $1}')
rm -rf /var/cache/snapd/
apt autoremove --purge snapd -y
rm -rf ~/snap
printf "Package: snapd\nPin: release a=*\nPin-Priority: -10" > /etc/apt/preferences.d/nosnap.pref
apt update -y
apt upgrade -y
apt install --install-suggests gnome-software -y
printf "Package: firefox*\nPin: release o=Ubuntu*\nPin-Priority: -1" > /etc/apt/preferences.d/firefox-no-snap
add-apt-repository ppa:mozillateam/ppa -y
apt update -y
apt install -t 'o=LP-PPA-mozillateam' firefox -y
echo 'Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";' | tee /etc/apt/apt.conf.d/51unattended-upgrades-firefox
printf "Package: firefox*\nPin: release o=LP-PPA-mozillateam\nPin-Priority: 501" > /etc/apt/preferences.d/mozillafirefoxppa
apt install flatpak -y
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
case $de_prompt in
[yY] | [yY][eE][sS] )
apt install vanilla-gnome-desktop -y
apt remove aisleriot gnome-mahjongg gnome-mines gnome-sudoku *libreoffice* -y
apt purge ubuntu-desktop ubuntu-session -y
;;
esac
apt autoremove -y
read -p "Reboot now? (Y/n) " reboot_prompt
case $reboot_prompt in
"" | [yY] | [yY][eE][sS] )
reboot
;;
esac
@demirdegerli
Copy link
Author

How to run?

sudo sh -c "$(curl -fsSL https://gist.githubusercontent.com/demirdegerli/b7087c84ef55a1909c21e4966659a2ba/raw/ubuntu_debloater.sh)"

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