Last active
December 28, 2025 15:28
-
-
Save demirdegerli/b7087c84ef55a1909c21e4966659a2ba to your computer and use it in GitHub Desktop.
Ubuntu Debloater
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
For users who want a Graphical User Interface(GUI):
#!/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
;;
esac
apt autoremove -y
read -p "Reboot now? (Y/n) " reboot_prompt
case $reboot_prompt in
"" | [yY] | [yY][eE][sS] )
reboot
;;
esac
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to run?
sudo sh -c "$(curl -fsSL https://gist.githubusercontent.com/demirdegerli/b7087c84ef55a1909c21e4966659a2ba/raw/ubuntu_debloater.sh)"