Ubuntu Tutorials - Herong's Tutorial Examples - v1.25, by Herong Yang
APT Configuration Settings and Overrides
This section provides a quick introduction of APT (Advanced Package Tool) configuration settings and overriding configuration files.
If you use the "apt" command regularly, you may want to review and modify APT (Advanced Package Tool) configuration settings.
1. Review current settings using the "apt-config dump" command.
herong$ apt-config dump APT ""; APT::Architecture "amd64"; APT::Build-Essential ""; APT::Build-Essential:: "build-essential"; APT::Install-Recommends "1"; APT::Install-Suggests "0"; APT::Sandbox ""; APT::Sandbox::User "_apt"; APT::Authentication ""; APT::Authentication::TrustCDROM "true"; APT::NeverAutoRemove ""; APT::NeverAutoRemove:: "^firmware-linux.*"; APT::NeverAutoRemove:: "^linux-firmware$"; APT::NeverAutoRemove:: "^linux-image-[a-z0-9]*$"; APT::NeverAutoRemove:: "^linux-image-[a-z0-9]*-[a-z0-9]*$"; APT::VersionedKernelPackages ""; APT::VersionedKernelPackages:: "linux-image"; APT::VersionedKernelPackages:: "linux-headers"; ... Unattended-Upgrade::DevRelease "false"; CommandLine ""; CommandLine::AsString "apt-config dump";
To understand APT configuration settings, you should read apt.conf(5) man page.
herong$ man 5 apt.conf NAME apt.conf - Configuration file for APT DESCRIPTION /etc/apt/apt.conf is the main configuration file shared by all the tools in the APT suite of tools, though it is by no means the only place options can be set. The suite also shares a common command line parser to provide a uniform environment. When an APT tool starts up it will read the configuration files in the following order: 1. the file specified by the APT_CONFIG environment variable (if any) ...
APT uses configuration files in the /etc/apt/apt.conf.d directory to override default settings. I see the following files on my Ubuntu computer:
herong$ ls -l /etc/apt/apt.conf.d total 72 -rw-r--r-- 1 root root 49 Sep 17 2019 00aptitude -rw-r--r-- 1 root root 40 Sep 17 2019 00trustcdrom -rw-r--r-- 1 root root 1018 Dec 7 2020 01autoremove -rw-r--r-- 1 root root 42 Apr 20 2018 01-vendor-ubuntu -rw-r--r-- 1 root root 129 Jun 27 2018 10periodic -rw-r--r-- 1 root root 108 Jun 27 2018 15update-stamp -rw-r--r-- 1 root root 392 Jun 24 2025 20apt-esm-hook.conf -rw-r--r-- 1 root root 85 Jun 27 2018 20archive -rw-r--r-- 1 root root 80 Dec 13 2018 20auto-upgrades -rw-r--r-- 1 root root 243 Dec 16 2009 20dbus -rw-r--r-- 1 root root 1040 Nov 8 2018 20packagekit -rw-r--r-- 1 root root 127 Dec 1 2022 20snapd.conf -rw-r--r-- 1 root root 2584 Apr 4 2018 50appstream -rw-r--r-- 1 root root 625 Mar 16 2018 50command-not-found -rw-r--r-- 1 root root 3800 Feb 17 2020 50unattended-upgrades -rw-r--r-- 1 root root 435 Apr 4 2018 60icons -rw-r--r-- 1 root root 182 Feb 28 2018 70debconf -rw-r--r-- 1 root root 305 Jun 27 2018 99update-notifier
As you can see, settings are groupd into separate files for easier access. For example, "20archive" should hold lines to override APT::Archives::* settings.
herong$ cat /etc/apt/apt.conf.d/20archive APT::Archives::MaxAge "30"; APT::Archives::MinAge "2"; APT::Archives::MaxSize "500";
You can modify and add configuration files to update existing overrides or add new ones.
Here is what I did to override the Binary::apt::APT::Keep-Downloaded-Packages setting, to see downloaded packages after installation.
herong$ sudo vim /etc/apt/apt.conf.d/01keep-debs binary::apt::APT::Keep-Downloaded-Packages "1";
Verify the setting.
herong$ apt-config dump | grep Keep-Downloaded binary::apt::APT::Keep-Downloaded-Packages "1";
Note APT configuration setting names are case sensitive. For example, Binary::apt::APT::Keep-Downloaded-Packages and binary::APT::APT::Keep-Downloaded-Packages will not be picked by the "apt" command.
See the next tutorial on where downloaded packages are archived.
Table of Contents
Introduction to Ubuntu Systems
GNOME - Desktop Interface and Environment
Shell - The Command-Line Interpreter
"apt list" - List Software Packages
"apt show" - Show Software Package Details
"sudo apt install/remove" - Install/Remove Package
"sudo apt autoremove" - Remove Unneeded Packages
Manage "apt" Package Repositories
►APT Configuration Settings and Overrides
APT Package Archives and Metadata