Categories
SysOps

How to inspect dnf configuration

Inspect dnf configuration.

Prerequisites

Install config-manager for dnf.

$ sudo dnf install 'dnf-command(config-manager)'

Display help information.

$ dnf config-manager --help
usage: dnf config-manager [-c [config file]] [-q] [-v] [--version] [--installroot [path]] [--nodocs] [--noplugins] [--enableplugin [plugin]] [--disableplugin [plugin]]
                          [--releasever RELEASEVER] [--setopt SETOPTS] [--skip-broken] [-h] [--allowerasing] [-b | --nobest] [-C] [-R [minutes]] [-d [debug level]]
                          [--debugsolver] [--showduplicates] [-e ERRORLEVEL] [--obsoletes] [--rpmverbosity [debug level name]] [-y] [--assumeno] [--enablerepo [repo]]
                          [--disablerepo [repo] | --repo [repo]] [--enable | --disable] [-x [package]] [--disableexcludes [repo]] [--repofrompath [repo,path]] [--noautoremove]
                          [--nogpgcheck] [--color COLOR] [--refresh] [-4] [-6] [--destdir DESTDIR] [--downloadonly] [--comment COMMENT] [--bugfix] [--enhancement] [--newpackage]
                          [--security] [--advisory ADVISORY] [--bz BUGZILLA] [--cve CVES] [--sec-severity {Critical,Important,Moderate,Low}] [--forcearch ARCH] [--save]
                          [--add-repo URL] [--dump] [--dump-variables] [--set-enabled | --set-disabled]
                          [repo ...]

manage dnf configuration options and repositories

General DNF options:
  -c [config file], --config [config file]
                        config file location
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  --version             show DNF version and exit
  --installroot [path]  set install root
  --nodocs              do not install documentations
  --noplugins           disable all plugins
  --enableplugin [plugin]
                        enable plugins by name
  --disableplugin [plugin]
                        disable plugins by name
  --releasever RELEASEVER
                        override the value of $releasever in config and repo files
  --setopt SETOPTS      set arbitrary config and repo options
  --skip-broken         resolve depsolve problems by skipping packages
  -h, --help, --help-cmd
                        show command help
  --allowerasing        allow erasing of installed packages to resolve dependencies
  -b, --best            try the best available package versions in transactions.
  --nobest              do not limit the transaction to the best candidate
  -C, --cacheonly       run entirely from system cache, don't update cache
  -R [minutes], --randomwait [minutes]
                        maximum command wait time
  -d [debug level], --debuglevel [debug level]
                        debugging output level
  --debugsolver         dumps detailed solving results into files
  --showduplicates      show duplicates, in repos, in list/search commands
  -e ERRORLEVEL, --errorlevel ERRORLEVEL
                        error output level
  --obsoletes           enables dnf's obsoletes processing logic for upgrade or display capabilities that the package obsoletes for info, list and repoquery
  --rpmverbosity [debug level name]
                        debugging output level for rpm
  -y, --assumeyes       automatically answer yes for all questions
  --assumeno            automatically answer no for all questions
  --enablerepo [repo]   Enable additional repositories. List option. Supports globs, can be specified multiple times.
  --disablerepo [repo]  Disable repositories. List option. Supports globs, can be specified multiple times.
  --repo [repo], --repoid [repo]
                        enable just specific repositories by an id or a glob, can be specified multiple times
  --enable              enable repos with config-manager command (automatically saves)
  --disable             disable repos with config-manager command (automatically saves)
  -x [package], --exclude [package], --excludepkgs [package]
                        exclude packages by name or glob
  --disableexcludes [repo], --disableexcludepkgs [repo]
                        disable excludepkgs
  --repofrompath [repo,path]
                        label and path to an additional repository to use (same path as in a baseurl), can be specified multiple times.
  --noautoremove        disable removal of dependencies that are no longer used
  --nogpgcheck          disable gpg signature checking (if RPM policy allows)
  --color COLOR         control whether color is used
  --refresh             set metadata as expired before running the command
  -4                    resolve to IPv4 addresses only
  -6                    resolve to IPv6 addresses only
  --destdir DESTDIR, --downloaddir DESTDIR
                        set directory to copy packages to
  --downloadonly        only download packages
  --comment COMMENT     add a comment to transaction
  --bugfix              Include bugfix relevant packages, in updates
  --enhancement         Include enhancement relevant packages, in updates
  --newpackage          Include newpackage relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory ADVISORY, --advisories ADVISORY
                        Include packages needed to fix the given advisory, in updates
  --bz BUGZILLA, --bzs BUGZILLA
                        Include packages needed to fix the given BZ, in updates
  --cve CVES, --cves CVES
                        Include packages needed to fix the given CVE, in updates
  --sec-severity {Critical,Important,Moderate,Low}, --secseverity {Critical,Important,Moderate,Low}
                        Include security relevant packages matching the severity, in updates
  --forcearch ARCH      Force the use of an architecture

Config-manager command-specific options:
  --save                save the current options (useful with --setopt)
  --add-repo URL        add (and enable) the repo from the specified file or url
  --dump                print current configuration values to stdout
  --dump-variables      print variable values to stdout
  --set-enabled         enable repos (automatically saves)
  --set-disabled        disable repos (automatically saves)

  repo                  repo to modify

Inspect global configuration

Display current configuration.

$ dnf config-manager --dump
======================================================================================= main =======================================================================================
[main]
allow_vendor_change = 1
assumeno = 0
assumeyes = 0
autocheck_running_kernel = 1
bandwidth = 0
best = 1
bugtracker_url = https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=dnf
cachedir = /var/cache/dnf
cacheonly = 0
check_config_file_age = 1
clean_requirements_on_remove = 1
color = auto
color_list_available_downgrade = magenta
color_list_available_install = bold,cyan
color_list_available_reinstall = bold,underline,green
color_list_available_upgrade = bold,blue
color_list_installed_extra = bold,red
color_list_installed_newer = bold,yellow
color_list_installed_older = yellow
color_list_installed_reinstall = cyan
color_search_match = bold,magenta
color_update_installed = red
color_update_local = green
color_update_remote = bold,green
config_file_path = /etc/dnf/dnf.conf
countme = 0
debug_solver = 0
debuglevel = 2
defaultyes = 0
deltarpm = 1
deltarpm_percentage = 75
disable_excludes = 
diskspacecheck = 1
enabled = 1
enablegroups = 1
errorlevel = 3
exclude = 
exclude_from_weak = 
exclude_from_weak_autodetect = 1
excludepkgs = 
exit_on_lock = 0
fastestmirror = 1
gpgcheck = 1
gpgkey_dns_verification = 0
group_package_types = mandatory, default, conditional
history_list_view = commands
history_record = 1
history_record_packages = dnf, rpm
ignorearch = 0
includepkgs = 
install_weak_deps = 1
installonly_limit = 3
installonlypkgs = kernel, kernel-PAE, installonlypkg(kernel), installonlypkg(kernel-module), installonlypkg(vm), multiversion(kernel)
installroot = /
ip_resolve = whatever
keepcache = 0
localpkg_gpgcheck = 0
log_compress = 0
log_rotate = 4
log_size = 1048576
logdir = /var/log
logfilelevel = 9
max_parallel_downloads = 10
metadata_expire = 172800
metadata_timer_sync = 10800
minrate = 1000
module_obsoletes = 0
module_stream_switch = 0
multilib_policy = best
obsoletes = 1
password = 
persistdir = /var/lib/dnf
pluginconfpath = /etc/dnf/plugins
pluginpath = /usr/lib/python3.9/site-packages/dnf-plugins
plugins = 1
protect_running_kernel = 1
protected_packages = dnf, systemd, systemd-udev, dnf, yum, sudo, systemd, systemd-udev, dnf, yum, sudo
proxy = 
proxy_auth_method = any
proxy_sslcacert = 
proxy_sslclientcert = 
proxy_sslclientkey = 
proxy_sslverify = 1
recent = 7
repo_gpgcheck = 0
reposdir = /etc/yum.repos.d, /etc/yum/repos.d, /etc/distro.repos.d
reset_nice = 1
retries = 10
rpmverbosity = info
showdupesfromrepos = 0
skip_broken = 0
skip_if_unavailable = 0
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = 1
sslverifystatus = 0
strict = 1
system_cachedir = /var/cache/dnf
throttle = 0
timeout = 30
transformdb = 1
tsflags = 
upgrade_group_objects_upgrade = 1
user_agent = libdnf (CentOS Stream 9; generic; Linux.x86_64)
username = 
varsdir = /etc/yum/vars, /etc/dnf/vars
zchunk = 1

Display configuration options related to the specific phrase.

$ dnf config-manager --dump | awk -F " = " '$1~/ssl/ {print}'
proxy_sslcacert = 
proxy_sslclientcert = 
proxy_sslclientkey = 
proxy_sslverify = 1
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = 1
sslverifystatus = 0

Display particular configuration option.

$ dnf config-manager --dump | awk -F " = " '$1=="cachedir" {print $2}'
/var/cache/dnf

Display configuration variables.

$ dnf config-manager --dump-variables
arch = x86_64
basearch = x86_64
stream = 9-stream
releasever = 9

Inspect repository configuration

Display configured repositories.

$ dnf repolist
repo id                                                                         repo name
appstream                                                                       CentOS Stream 9 - AppStream
baseos                                                                          CentOS Stream 9 - BaseOS
extras-common                                                                   CentOS Stream 9 - Extras packages

Display repository configuration.

$ dnf config-manager --dump appstream
================================================================================= repo: appstream ==================================================================================
[appstream]
bandwidth = 0
baseurl = 
cachedir = /var/cache/dnf
cost = 1000
countme = 1
deltarpm = 1
deltarpm_percentage = 75
enabled = 1
enabled_metadata = 
enablegroups = 1
exclude = 
excludepkgs = 
fastestmirror = 1
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
includepkgs = 
ip_resolve = whatever
max_parallel_downloads = 10
mediaid = 
metadata_expire = 21600
metalink = https://mirrors.centos.org/metalink?repo=centos-appstream-9-stream&arch=x86_64&protocol=https,http
minrate = 1000
module_hotfixes = 0
name = CentOS Stream 9 - AppStream
password = 
priority = 99
protected_packages = dnf, systemd, systemd-udev, dnf, yum, sudo, systemd, systemd-udev, dnf, yum, sudo
proxy = 
proxy_auth_method = any
proxy_sslcacert = 
proxy_sslclientcert = 
proxy_sslclientkey = 
proxy_sslverify = 1
repo_gpgcheck = 0
retries = 10
skip_if_unavailable = 0
sslcacert = 
sslclientcert = 
sslclientkey = 
sslverify = 1
sslverifystatus = 0
throttle = 0
timeout = 30
type = 
user_agent = libdnf (CentOS Stream 9; generic; Linux.x86_64)
username = 

Store configuration option

Inspect configuration file.

$ cat /etc/dnf/dnf.conf 
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
max_parallel_downloads=10
fastestmirror=True

Alter particular configuration option.

$ dnf config-manager --setopt max_parallel_downloads=5 --save

Inspect configuration file again.

$ cat /etc/dnf/dnf.conf 
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
max_parallel_downloads=5
fastestmirror=True