Package Management (Apt/Dnf/Pacman Internals)
Stop worrying about the deb cache killing your disk
🧩 The Challenge
Dealing with small root partitions on CI runners or edge nodes is a nightmare when apt keeps hoarding every single .deb file you have ever downloaded. You eventually get hit with a disk full error that breaks everything because of some ancient cache you forgot existed.
💡 The Fix
Tell apt to wipe those files automatically after every install so you stop playing disk space tetris during a deployment. It’s a simple config tweak that saves you from cleaning up by hand at 3 AM.
echo 'Binary::apt::APT::Keep-Downloaded-Packages "false";' | sudo tee /etc/apt/apt.conf.d/01clean-cache
⚙️ Why It Works
Setting this directive forces apt to purge the package files from /var/cache/apt/archives immediately after the transaction finishes. Normally, the package manager hangs onto them just in case you want to reinstall, but in a production environment, that is just wasted space.
🚀 Pro-Tip: If you’re really desperate for space, run sudo apt-get clean right now to nuke the existing backlog.
Linux Tips & Tricks | © ngelinux.com | 11/28/2026
