[ About | Licence | Contacts ]
Written by Oleksandr Gavenko (AKA gavenkoa), compiled on 2024-04-01 from rev 052223c22317.

dnf package manager

List repositories

List subscription repos:

sudo subscription-manager repos --list

List enabled repositories:

sudo dnf repolist
sudo dnf repolist --enabled

List disabled repositories:

sudo dnf repolist --disabled

Activate repository:

sudo subscription-manager repos --enable $REPO

List packages

List all installed packages:

dnf repoquery --installed

List packages selected by a user (but not automatically to meet dependenciy requirements):

dnf repoquery --userinstalled
dnf history userinstalled

List packages in a repository:

dnf repository-packages $REPO list

Search for a package:

dnf search nodejs

List all package version:

dnf search --showduplicates nodejs

List all package versions together with repos:

dnf list --showduplicates nodejs

Check package details

Check if a package is installed:

dnf list $PKG
rpm --verify $PKG
rpm -V $PKG

Check a package version:

dnf info $PKG

Check repository/origin availability:

dnf whatprovides $PKG

List package's files

dnf repoquery -l $PKG
rpm -ql $PKG

Find packages a file belongs to

Using remote metadata:

dnf provides ifconfig
dnf repoquery --file /usr/sbin/ifconfig
repoquery --whatprovides python3
repoquery --whatprovides libssl*.so.*

Using installed package DB:

rpm -qf /usr/bin/rpm
rpm -q --whatprovides /bin/bash

Limit search to a specific repository:

dnf repoquery --disablerepo=* --enablerepo=$REPO -f $PATT

List package dependencies

dnf deplist $PKG
repoquery --requires --resolve $PKG

If you possess an actual RPM (-q or --query, -R or –requires):

rpm -qpR $RPM

List of packages that depend on a given

dnf repoquery --alldeps --whatrequires $PKG
dnf repoquery --installed --whatrequires $PKG
rpm -q --whatrequires $PKG

Install package

By package name:

dnf install $PKG

By a package file:

rpm -i $PKG.rpm
rpm --install $PKG.rpm

Update a package by a file (same as install but removes all earlier versions):

rpm -U $PKG.rpm
rpm --upgrade $PKG.rpm

Dealing with streams

Streams group related package at specific compatible version. Only one version could be installed in system in time.

For example Node.js has lots of parallel versions:

bash# sudo dnf module list nodejs
Name   Stream Profiles                              Summary
nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime
nodejs 12     common [d], development, minimal, s2i Javascript runtime
nodejs 14     common [d], development, minimal, s2i Javascript runtime
nodejs 16     common [d], development, minimal, s2i Javascript runtime
nodejs 18     common [d], development, minimal, s2i Javascript runtime

You select specific stream:

sudo dnf module install nodejs:18

In order to change stream one need to remove all the packages from original stream and reset the stream:

sudo dnf module remove nodejs
sudo dnf module reset nodejs
sudo dnf module install nodejs:16

Extra Packages for Enterprise Linux

EPEL stands for Extra Packages for Enterprise Linux and you can enable them by installing a special package:

sudo dnf install epel-release
sudo dnf install epel-next-release
https://docs.fedoraproject.org/en-US/epel/
Extra Packages for Enterprise Linux (EPEL).
https://fedoraproject.org/wiki/EPEL/FAQ
EPEL FAQ.

Subscription manager

https://developers.redhat.com/articles/renew-your-red-hat-developer-program-subscription
To renew subscription just login to https://developers.redhat.com/ and wait 15 min.

Cleanup actions from broken previous subscription:

sudo subscription-manager remove --all
sudo subscription-manager unregister
sudo subscription-manager clean
sudo subscription-manager register --username ...
sudo subscription-manager refresh
sudo subscription-manager attach --auto