configuration

dnf.conf — Package manager policy

DNF uses INI-style global settings and repository sections, usually in /etc/yum.repos.d/*.repo. gpgcheck requests package signature checks; repo_gpgcheck is a separate metadata policy. Repository-specific settings can override global defaults, subject to the RPM security policy and DNF version. Do not disable signature verification to resolve an error. installonly_limit controls retained versions of install-only packages such as kernels, not all installed packages; DNF4 defaults to 3 and a nonzero limit must be at least 2. Check DNF4 versus DNF5 documentation and distribution overrides. The example reads a synthetic INI file, not DNF itself. Before an authorized transaction, inspect effective repository settings and the transaction preview; keep a bootable fallback. Restore the policy if necessary; reverting package transactions requires separate compatibility and recovery planning.

Formal Syntax & Structure

linux syntaxlinux
[main]gpgcheck=1installonly_limit=3

Parameters & Attributes

NameTypeDescription
gpgcheckdirective or fieldPackage signature checking
repo_gpgcheckdirective or fieldRepository metadata signature checking
installonly_limitdirective or fieldRetention count for install-only packages

Return Value

configuration or inspection

Policy inputs, not a transaction result.

Working Example

Example Snippetlinux
set -eud=$(mktemp -d)trap 'rm -rf -- "$d"' EXITcat > "$d/dnf.conf" <<'EOF'[main]gpgcheck=1installonly_limit=3EOFpython3 - "$d/dnf.conf" <<'PY2'import configparser, syscfg = configparser.ConfigParser()with open(sys.argv[1]) as f:    cfg.read_file(f)assert cfg.getboolean('main','gpgcheck')assert cfg.getint('main','installonly_limit') >= 2print('fixture: signature checks enabled; retain 3 install-only versions')PY2
Linux Reference