Package management#

Every Linux distribution is a collection of software packages that can be installed, updated, and removed during the lifetime of the system. These packages are managed by the package manager, which is usually called apt or dnf or zypper depending on the distribution. For now we focus on Red Hat-based distributions and the dnf package manager.

Note

DNF is a drop-in replacement for YUM on Red Hat-based distributions. It has been introduced in Fedora 22 and Red Hat Enterprise Linux 7, and will replace YUM in future releases.

Getting started with DNF#

All actions require the root user as the system needs to be changed.

Install the package python-pip with dnf#
# dnf install python-pip
Install the package python-pip with dnf without accepting the change#
# dnf install -y python-pip
Install the package python-pip with dnf#
# dnf remove python-pip
# dnf install <packagename>
# dnf update <packagename>
# dnf list [packagename]
# dnf search <keyword>
# dnf search all <keyword>
# dnf info <packagename>
# dnf provides <filename>
# dnf remove <packagename>
# dnf grouplist
Last metadata expiration check: 2:12:35 ago on Sat Jun  4 15:19:19 2022.
Available Environment Groups:
    Fedora Custom Operating System
    Minimal Install
    Fedora Server Edition
    Fedora Workstation
    Fedora Cloud Server
    KDE Plasma Workspaces
    Xfce Desktop
    LXDE Desktop
    LXQt Desktop
    Cinnamon Desktop
    MATE Desktop
    Sugar Desktop Environment
    Deepin Desktop
    Development and Creative Workstation
    Web Server
    Infrastructure Server
    Basic Desktop
    i3 desktop
Installed Groups:
    LibreOffice
    GNOME Desktop Environment
    Fonts
    Hardware Support
Available Groups:
    3D Printing
    Administration Tools
    Audio Production
    Authoring and Publishing
    C Development Tools and Libraries
    Cloud Infrastructure
    Cloud Management Tools
    Compiz
    Container Management
    D Development Tools and Libraries
    Design Suite
    Development Tools
    Domain Membership
    Editors
    Educational Software
    Electronic Lab
    Engineering and Scientific
    FreeIPA Server
    Headless Management
    MATE Applications
    Milkymist
    Network Servers
    Neuron Modelling Simulators
    Office/Productivity
    Pantheon Desktop
    Python Classroom
    Python Science
    Robotics
    RPM Development Tools
    Security Lab
    Text-based Internet
    Window Managers
    Deepin Desktop Environment
    Graphical Internet
    KDE (K Desktop Environment)
    Games and Entertainment
    Sound and Video
    System Tools
# dnf grouplist hidden
$ dnf group info "groupname"
$ dnf group install "Groupname"

Package installation history#

dnf logging can be found in /var/log/dnf.log

$ dnf history
$ dnf history info <id>
$ dnf history undo <id>

Maintaining repositories#

List all available repositories on the system#
# dnf repolist
repo id                                                                     repo name
azure-cli                                                                   Azure CLI
code                                                                        Visual Studio Code
fedora                                                                      Fedora 36 - x86_64
fedora-cisco-openh264                                                       Fedora 36 openh264 (From Cisco) - x86_64
fedora-modular                                                              Fedora Modular 36 - x86_64
gh-cli                                                                      packages for the GitHub CLI
google-chrome-unstable                                                      google-chrome-unstable
google-cloud-sdk                                                            Google Cloud SDK
hashicorp                                                                   Hashicorp Stable - x86_64
rpmfusion-free                                                              RPM Fusion for Fedora 36 - Free
rpmfusion-free-updates                                                      RPM Fusion for Fedora 36 - Free - Updates
rpmfusion-nonfree                                                           RPM Fusion for Fedora 36 - Nonfree
rpmfusion-nonfree-nvidia-driver                                             RPM Fusion for Fedora 36 - Nonfree - NVIDIA Driver
rpmfusion-nonfree-steam                                                     RPM Fusion for Fedora 36 - Nonfree - Steam
rpmfusion-nonfree-updates                                                   RPM Fusion for Fedora 36 - Nonfree - Updates
sbt-rpm                                                                     sbt-rpm
updates                                                                     Fedora 36 - x86_64 - Updates
updates-modular                                                             Fedora Modular 36 - x86_64 - Updates

Refreshing metadata#

dnf [options] makecache

The systemd time dnf-makecache.timer refreshes the metadata on a regular interval

Add in the [main]-section of /etc/dnf/dnf.conf the following:

metadata_timer_sync=0
metadata_expire=-1

Note

See also Building a package