Stop APT from dragging in recommends you never wanted

Package Management & Distro Internals (Apt/Dnf/Pacman)

Stop APT from dragging in recommends you never wanted

Technical Briefing | 10/22/2026

You are spinning up a minimal container or a hardened edge server, and you run apt install. Suddenly, your filesystem is bloated with recommended packages you did not ask for and definitely do not need. It is a classic move for apt to treat recommendations as dependencies by default, which is the last thing you want when trying to keep your attack surface thin.

Why apt loves to over-provision

The debian-policy manual considers recommends a strong suggestion, so the package manager assumes if you want the package, you want the ecosystem surrounding it. But in a production environment, this behavior often leads to pulling in bulky documentation, unnecessary helper scripts, or even heavier language runtimes. If you are building a custom image, this bloat adds time to your CI pipeline and security risk to your runtime.

apt-get install --no-install-recommends <package-name>

Making the change permanent

  • Create a file in /etc/apt/apt.conf.d/ specifically for these preferences.
  • Add the APT::Install-Recommends line set to false to globally override the default.
  • Verify your config using apt-config dump to ensure it actually takes effect across all sub-commands.

If you really want to force this globally, drop a file like /etc/apt/apt.conf.d/01no-recommends into your provisioning scripts. Just be aware that if you do this on a desktop or a general-purpose box, you might find yourself missing pieces of desktop environments or weird proprietary drivers later on. But for servers, it is the only sane way to keep your packages lean and your audits boring.

Linux Admin Automation  |  © www.ngelinux.com  |  10/22/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted