Configurable settings of the dnf.Base object are stored into a dnf.conf.Conf instance. The various options are described here.

class dnf.conf.Conf

Boolean option, if set to True on any user input asking for confirmation (e.g. after transaction summary) the answer is implicitly yes. Default is False.


Boolean option, True instructs the solver to either use a package with the highest available version or fail. On False, do not fail if the latest version can not be installed. Default is False.


Path to a directory used by various DNF subsystems for storing cache data. Has a reasonable root-writable default depending on the distribution. It is up to the client to set this to a location where files and directories can be created under the running user. The directory can be safely deleted after the dnf.Base object is destroyed


Boolean option. Specifies whether dnf should automatically expire metadata of repos, which are older than their corresponding configuration file (usually the dnf.conf file and the foo.repo file). Default is True (perform the check).


Boolean option. True removes dependencies that are no longer used during dnf remove. A package only qualifies for removal via clean_requirements_on_remove if it was installed through DNF but not on explicit user request, i.e. it was pulled in as a dependency. The default is True. (installonlypkgs are never automatically removed.)


Path to the default main configuration file. Default is "/etc/dnf/dnf.conf".


Debug messages output level, in the range 0 to 10. Default is 2.


Integer option. When the relative size of delta vs pkg is larger than this, delta is not used. Default value is 75 (%). Use 0 to turn off delta rpm processing. Local repositories (with file:// baseurl) have delta rpms always turned off.


Exclude packages specified by <pkgs> from the operation.


Boolean option, if set to True dnf client exits immediately when something else has the lock. Default is False.


Returns the value of the first valid reposdir or if unavailable the value of created reposdir (string)


List of the following: optional, default, mandatory. Tells dnf which type of packages in groups will be installed when ‘groupinstall’ is called. Default is: default, mandatory


List of provide names of packages that should only ever be installed, never upgraded. Kernels in particular fall into this category. These packages are never removed by dnf autoremove even if they were installed as dependencies (see clean_requirements_on_remove for auto removal details). This option overrides the default installonlypkgs list used by DNF. The number of kept package versions is regulated by installonly_limit.


An integer to limit the number of installed installonly packages (packages that do not upgrade, instead few versions are installed in parallel). Defaults to 0, that is the limiting is disabled.


When this boolean option is set to True and a new package is about to be installed, all packages linked by weak dependency relation (Recommends or Supplements flags) with this package will pulled into the transaction. Default is True.


The root of the filesystem for all packaging operations.


Keeps downloaded packages in the cache when this boolean option is set to True. Even if it is set to False and packages have not been installed they will still persist until next successful transaction. The default is False.


Directory where the log files will be stored. Default is "/var/log".


Set this to $name:$stream to override PLATFORM_ID detected from /etc/os-release. It is necessary to perform a system upgrade and switch to a new platform.


Controls how multilib packages are treated during install operations. Can either be "best" (the default) for the depsolver to prefer packages which best match the system’s architecture, or "all" to install all available packages with compatible architectures.


Directory where the data that DNF keeps track of between different runs is stored. Default is "/var/lib/dnf".


List of directories that are searched for plugin configuration to load. All configuration files found in these directories, that are named same as a plugin, are parsed. The default contains /etc/dnf/plugins path.


List of directories where DNF searches for plugins. The default contains a Python version-specific path.


URL of of a proxy server to use for network connections. Defaults to None, i.e. no proxy used. The expected format of this option is:


List of packages that DNF should never completely remove. They are protected via Obsoletes as well as user/plugin removals.


The username to use for connecting to the proxy server. Defaults to None.


The password to use for connecting to the proxy server. Defaults to None.


The authentication method used by the proxy server. Valid values are

method meaning
basic HTTP Basic authentication
digest HTTP Digest authentication
negotiate HTTP Negotiate (SPNEGO) authentication
ntlm HTTP NTLM authentication
digest_ie HTTP Digest authentication with an IE flavor
ntlm_wb NTLM delegating to winbind helper
none None auth method
any All suitable methods

Defaults to any


Used for substitution of $releasever in the repository configuration.


List of directories to search for repo configuration files. Has a reasonable default commonly used on the given distribution.


Number of times any attempt to retrieve a file should retry before returning an error. Setting this to 0 makes it try forever. Defaults to 10.


Path to the directory or file containing the certificate authorities to verify SSL certificates. Defaults to None - uses system default.


Whether SSL certificate checking should be performed at all. Defaults to True.


Path to the SSL client certificate used to connect to remote sites. Defaults to None.


Path to the SSL client key used to connect to remote sites. Defaults to None.


A mapping of substitutions used in repositories’ remote URL configuration. The commonly used ones are:

key meaning default
arch architecture of the machine autodetected
basearch the architecture family of the current “arch” autodetected
releasever release name of the system distribution None

dnf.rpm.detect_releasever() can be used to detect the releasever value.

Following example shows recommended method how to override autodetected architectures:

import dnf
import dnf.arch

base = dnf.Base()
base.conf.substitutions['arch'] = arch
base.conf.substitutions['basearch'] = dnf.rpm.basearch(arch)

List of strings adding extra flags for the RPM transaction.

tsflag RPM Transaction Flag

The nocrypto option will also set the _RPMVSF_NOSIGNATURES and _RPMVSF_NODIGESTS VS flags. The test option provides a transaction check without performing the transaction. It includes download of packages, gpg keys check (including permanent import of additional keys if necessary), and rpm check to prevent file conflicts. The nocaps is supported with rpm-4.14 or later. When nocaps is used but rpm doesn’t support it, DNF only reports it as an invalid tsflag.


The username to use for connecting to repo with basic HTTP authentication. Defaults to None.


Set this to False to disable the automatic running of group upgrade when running the upgrade command. Default is True (perform the operation).


The password to use for connecting to repo with basic HTTP authentication. Defaults to None.


The base architecture used for installing packages. By default this is auto-detected.


The architecture used for installing packages. By default this is auto-detected.


If set to True, RPM will allow attempts to install packages incompatible with the CPU’s architecture. Defaults to False.


Prefix config option named option with installroot.


Read configuration options from the main section in filename. Option values not present there are left at their current values. If filename is None, config_file_path is used. Conversely, the configuration path used to load the configuration file that was used is stored into config_file_path before the function returns.


Print configuration values, including inherited values.

write_raw_configfile(filename, section_id, substitutions, modify)

Update or create config file. Where filename represents name of config file (.conf or .repo); section_id represents id of modified section (e.g. main, fedora, updates); substitutions represents an instance of base.conf.substitutions; modify represents dict of modified options.