Cleanup unnecessary packages
sudo apt purge --auto-remove snapd squashfs-tools friendly-recovery apport at
Very few server instances utilize these packages. Make sure you don't need
them before removing them.
Remove unattended upgrades [CAUTION]
sudo apt purge --auto-remove unattended-upgrades
sudo systemctl disable apt-daily-upgrade.timer
sudo systemctl mask apt-daily-upgrade.service
sudo systemctl disable apt-daily.timer
sudo systemctl mask apt-daily.service
This removes the unattended-upgrades package and the associated services which are reponsible for automatically updating packages in the system. Although removing this package saves disk space and also removes its services running in the background, this is not recommended. You can instead configure unattended-upgrades to install just the security updates.
Enable only security updates by commenting other origins from unattended-upgrades apt configuration. Commented lines start with //.
sudo vim /etc/apt/apt.conf.d/50unattended-upgrades
Other unwanted services
service --status-all
Use the above command to list all services running in your server. Disable
the services you don't need.
Remove orphan packages
sudo apt autoremove --purge
This removes packages required as dependencies of previously installed
packages which have been removed now.