Windows Chocolatey
As of this writing, Chocolatey doesn’t have a build-in cache cleaner so the best way is to install the unofficial Choco Cleaner which creates a Windows Scheduled Task to run Choco-Cleaner.ps1 every Sunday at 11:00 PM.
macOS Homebrew
# Cleans up unused dependencies
brew autoremove
# Dry-run which let's you see what will be removed without actually removing anything
brew cleanup --prune=all --dry-run
# Remove outdated versions of packages that are no longer supported
brew cleanup --prune=all
Linux Flatpak
# Cleans Flatpak installation
flatpak uninstall --unused
# Removes user data for which no Flatpak is installed, unused libraries, etc.
flatpak uninstall --delete-data
# Removes invalid objects and reinstall where needed
flatpak repair
Linux Snap
# Automatically clean old revisions
sudo snap set system refresh.retain=<number-of-revisions>
# Clear Snap Cache
sudo rm -rf /var/lib/snapd/cache/*
# Remove unused Snap data
sudo rm -rf ~/snap/<package-name>
Ubuntu APT
# Remove orphaned packages
sudo apt autoremove
# Removes configuration files of packages that have been removed
sudo apt purge <package_name>
# Removes old kernels
sudo apt autoremove --purge
# Manually remove specific kernels
sudo apt remove --purge linux-image-<version> linux-headers-<version>
# Update GRUB (After removing old kernels, update GRUB to reflect the changes and reboot)
sudo update-grub && sudo reboot
Arch/Manjaro Pacman
# Remove Orphaned Packages
sudo pacman -Rns $(pacman -Qtdq)
# Clean the Package Cache
# Remove Old Versions (keeping the most recent three versions of each package)
sudo paccache -r
# Remove All Cached Packages Except the Currently Installed Ones
sudo paccache -r -k1
# Remove All Cached Packages: If you want to delete all cached packages
sudo pacman -Scc