APT Config - Query APT Configuration Options

Query APT configuration options with apt-config dump. View and filter APT settings for package management.

APT Config

APT Configuration Query Tool

The apt-config command is a powerful utility for querying and understanding the configuration of the Advanced Package Tool (APT) on Debian-based Linux systems. It allows users to inspect various configuration options, making it invaluable for system administrators and developers who need to fine-tune package management behavior.

Dump All APT Configuration Options

The primary function of apt-config is to display all currently active APT configuration settings. This is achieved using the dump subcommand. This output provides a comprehensive view of how APT is configured, including settings related to repositories, package preferences, and other operational parameters.

# List all APT (and related) configuration options and their values.
apt-config dump

Filter APT NeverAutoRemove Configurations

A common use case for apt-config is to examine specific configuration directives. For instance, one might want to list packages that are explicitly marked to be excluded from automatic removal by apt-get autoremove. This can be achieved by piping the output of apt-config dump to other command-line utilities like awk for filtering.

# List regular expressions used to match packages to be ignored by apt-get(8)'s
# `autoremove` functionality. Assumes `;` or some other undesired character
# will be at the end of the string.
apt-config dump | awk '/^APT::NeverAutoRemove::/ {print(substr($2, 0, length($2) - 1))}'

Understanding APT Configuration

APT's configuration is managed through a hierarchy of files, typically located in /etc/apt/. These include apt.conf, apt.conf.d/ directories, and files within sources.list.d/. The apt-config dump command consolidates these settings, resolving any overrides or specific configurations to present the effective settings used by APT.

External Resources