apt-config
Query APT configuration values
SYNOPSIS
apt-config [options] command
PARAMETERS
dump
Dumps the entire APT configuration in a structured format.
shell
Generates shell export statements for all active APT configuration variables, useful for scripting.
list
Lists the value of a specific configuration item. Functionally similar to get.
get
Retrieves the value of a specified APT configuration item. For example, `apt-config get APT::Default-Release`.
set
Temporarily sets the value of a configuration item for the current `apt-config` invocation. Changes are not persistent.
source
Shows which configuration file defined a specific APT configuration item. Useful for debugging configuration overrides.
-o, --option
Set a configuration option directly on the command line. This allows overriding any configuration file entry for the current command execution. Format is `APT::Option::Name=value`.
-c, --config-file
Specify an alternative configuration file to use instead of the default ones.
-h, --help
Displays a short usage summary and available options.
-v, --version
Shows the program's version information.
-D, --debug
Enables various debug outputs, useful for troubleshooting.
DESCRIPTION
`apt-config` is a command-line utility from the APT (Advanced Package Tool) suite. It provides a powerful interface for querying, inspecting, and temporarily modifying APT's configuration settings. This tool is invaluable for system administrators and developers who need to understand how APT resolves its behavior from various configuration files, such as /etc/apt/apt.conf and those in /etc/apt/apt.conf.d/.
While it can set configuration options, these changes are generally temporary for the current `apt-config` invocation. For persistent changes, one typically edits the APT configuration files directly. Its primary use cases include debugging APT's behavior, scripting automated tasks that depend on specific APT settings, and verifying that APT is configured as expected before performing package operations.
CAVEATS
The `set` command in `apt-config` only applies the configuration change for the current invocation of `apt-config`. It does not make persistent changes to APT's global configuration files.
Understanding APT's configuration hierarchy (default settings, main config file, `apt.conf.d` directory, and command-line options) is crucial when interpreting `apt-config` output or attempting to modify settings. Command-line options generally override file-based settings.
APT CONFIGURATION HIERARCHY
APT resolves its configuration settings from several locations in a specific order of precedence, with later sources overriding earlier ones:
1. Default Built-in Settings: Hardcoded defaults within the APT binaries.
2. `/etc/apt/apt.conf`: The main APT configuration file.
3. `/etc/apt/apt.conf.d/`: Directory containing additional configuration snippets. Files are parsed in alphabetical order.
4. Environment Variables: Some settings can be influenced by environment variables (e.g., `APT_CONFIG`).
5. Command-line Options (`-o`): Options passed directly to `apt` commands, which always take the highest precedence. `apt-config`'s `dump` command provides a consolidated view of the final, resolved configuration.
HISTORY
`apt-config` emerged as a utility within the APT (Advanced Package Tool) suite, which was developed to replace `dselect` as a more robust and user-friendly front-end for dpkg (Debian Package management system). APT's design relies heavily on a flexible configuration system, and `apt-config` was created to provide a programmatic interface to this system. It became increasingly important as APT's configuration grew in complexity, allowing administrators to inspect and debug how various settings (like repositories, proxies, or default releases) were resolved from multiple configuration files and command-line options.