Skip to content

Instantly share code, notes, and snippets.

@charlieporth1
Last active June 19, 2022 00:23
Show Gist options
  • Save charlieporth1/75ad23d3bb503d71f4d7236c9e76d428 to your computer and use it in GitHub Desktop.
Save charlieporth1/75ad23d3bb503d71f4d7236c9e76d428 to your computer and use it in GitHub Desktop.
Lightten Ubuntu for a lighter system
#!/usr/bin/env bash
sudo apt-get purge -y btrfs-progs && sudo update-initramfs -uk all
IMPORTANT_PKGS="network\|dhcp\|avahi\|"
X11_PKGS="x11\|xauth"
DESKTOP_PKGS="xorg\|xserver|desktop\|unity\|xserver\|gnome\|wallpaper\|icon\|lxde\|lxdm\|light-dm\|lightdm\|gdm\|kdm\|kde\|xfce\|lfce"
PRINTER_PKGS="cupsd\|cups-browsed\|accountsservice\|printer\|cups"
UNNEEDED_CLI_PKGS="man-db\|mouse\|wacom\|wayland\|spreadsheet"
AUDIO_PKGS="pulseaudio\|bluetooth\|alsa\|sound\|audio"
UNNEEDED_MSIC_PKGS="netstat"
UNNEEDED_PKGS="$X11_PKGS\|$DESKTOP_PKGS\|$PRINTER_PKGS\|$AUDIO_PKGS\|$UNNEEDED_CLI_PKGS\|$UNNEEDED_MSIC_PKGS"
sudo apt list --installed \
| grep -i "$UNNEEDED_PKGS" | grep -i -v "$IMPORTANT_PKGS" \
| awk -F/ '{print $1}' | xargs sudo apt remove -y
sudo apt purge -y xserver* lightdm*
sudo apt purge -y raspberrypi-ui-mods
sudo apt purge -y ubuntu-desktop
WLAN_DEVICE_REGEX="w(i|l)((o|fi|an)?)[0-9]+"
if ! ifconfig -a | grep -oE "$WLAN_DEVICE_REGEX" > /dev/null
then
sudo apt purge -y wpasupplicant
fi
sudo apt install -y ubuntu-advantage-tools update-manager-core update-notifier-common
sudo apt install zram-tools
sudo zramswap start
if ! [[ -f /etc/cron.d/start_zram ]]; then
echo """
# Generated at `date`
# Generated by $0
@reboot sudo zramswap start
""" | sudo tee /etc/cron.d/start_zram
fi
sudo apt install -y ubuntu-advantage-tools update-manager-core update-notifier-common
sudo apt -y autoremove
sudo apt -y autoclean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment