The wikis are now using the new authentication system.
If you did not migrate your account yet, visit https://idp-portal-info.suse.com/

SDB:DNF

Jump to: navigation, search


Tested on openSUSE

Recommended articles


DNF package manager

DNF is a package manager for RPM systems to install, update and remove packages. DNF was forked from Yum. Among the many improvements, it uses libsolv as a dependency resolver. DNF features support for plugins - which can be used to extend the core functionality of DNF -, automatic updates and parallel package downloads.


Installation

On Leap 15.3 and on Tumbleweed DNF is available from the official repositories and can be installed without adding another repository.

on the command line

# zypper install dnf rpm-repos-openSUSE

with YaST2

Start YaST2, select "Software Management" and search for DNF. Select DNF and rpm-repos-openSUSE and mark it for installation and press Accept.

Use DNF as PackageKit backend

If you want to use DNF as backend for PackageKit, use this command:

# dnf swap PackageKit-backend-zypp PackageKit-backend-dnf

DNF Usage

To refresh repos:

# dnf makecache

To install packages:

# dnf install packagename

To search the repositories for a package type:

# dnf search packagename

To remove a package:

# dnf remove packagename

Other common DNF commands include

autoremove - removes packages installed as dependencies that are no longer required by currently installed programs.

check-update - checks for updates, but does not download or install the packages.

downgrade - reverts to the previous version of a package.

info - provides basic information about the package including name, version, release, and description.

reinstall - reinstalls the currently installed package.

upgrade - checks the repositories for newer packages and updates them.

exclude - exclude a package from the transaction.

For example to update a Tumbleweed installation:

# dnf makecache
# dnf distro-sync

To update a Leap installation:

# dnf makecache
# dnf upgrade

This is the equivalent of:

# zypper refresh 
# zypper dist-upgrade

or

# zypper refresh 
# zypper update

openSUSE flavored DNF

DNF on openSUSE also offers some aliases to mimic zypper commands. These aliases can be listed:

# dnf alias

Which will output something like this:

Alias dup='distro-sync'
Alias dist-upgrade='distro-sync'
Alias ref='makecache'
Alias refresh='makecache'
Alias ri='reinstall'

Using these aliases one can update the system or refresh repos like in zypper with:

# dnf ref
# dnf dup

which are equivalent of:

# zypper ref
# zypper dup 

To add a new alias for example for remove:

# dnf alias add rm=remove

Managing repositories

Adding repositories

DNF in this sense is very similar to zypper in a sense that it has to be pointed to .repo file. The command:

# dnf config-manager --add-repo URL

To add a repository from OBS you would have to replace the zypper addrepo part with dnf config-manager --add-repo and the url at the end.

# dnf config-manager --add-repo https://download.opensuse.org/repositories/devel:languages:python/openSUSE_Tumbleweed/devel:languages:python.repo

Listing repositories

# dnf repolist

or

# dnf repolist all

These command will list the unique id and the name of the available repositories. dnf repolist all will add an extra status field after every repository listed indicating that the repository is enabled or disabled.

Enable/Disable repository

Before enabling or disabling a repository it is best to list all out with their current status

# dnf repolist all

Then using the id of the repository you wish to enable:

# dnf config-manager --set-enabled repo_id

Or to disable:

# dnf config-manager --set-disabled repo_id

Troubleshooting

DNF dup can't update the kernel

Currently DNF is marking the kernel packages as protected and in case of a kernel update - which is fairly frequent on Tumbleweed - it will refuse to update. To get around the issue disable the running kernel protection:

 # dnf --setopt=protect_running_kernel=False --refresh distro-sync 

protect_running_kernel: Controls whether the package corresponding to the running version of kernel is protected from removal. Default is True.