By Mohamad Wael

Posted :

DNF Cheat sheet

Help:

dnf help
# List dnf main commands,
# plugin commands, and
# the general dnf options.

dnf help a_command_name
# Get help, about a specific
# dnf command.

Repositories:

dnf repolist
# Lists the enabled repositories,
# IDs, and names.
# To list the disabled repositories,
# IDs, and names, you can use:
dnf repolist --disabled
# If more detailed information,
# is what is wanted, you can use
# -v, as in:
dnf repolist -v


dnf config-manager --add-repo URL
# Adds a fedora repostiory,
# for example, to add the wine
# repo, you can use:
dnf config-manager --add-repo https://dl.winehq.org/wine-builds/fedora/35/winehq.repo


dnf config-manager --set-enabled a_repo_id
# Enable a repository


dnf config-manager --set-disabled a_repo_id
# Disable a repository

Listing:

dnf list --installed
# Lists installed packages.
# Optionally, a package name,
# can be specified, as in:
dnf list zzuf


dnf repoquery --installonly
# Lists packages, which are install
# only. These packages are never
# upgraded, for example the
# kernel.


dnf list --available
# Lists available packages.
# Optionally, a package name,
# can be specified.


dnf list --extras
# Lists packages not installed
# from repositories.
# Optionally, a package name,
# can be specified.


dnf list --obsoletes
# Lists obsoletes packages.
# Optionally, a package name,
# can be specified.


dnf list --upgrades
# Lists upgrades available,
# for the installed
# packages.
# Optionally, a package name,
# can be specified.


dnf list --autoremove
# Lists dependencies, which
# are not needed anymore,
# so which can be removed,
# using autoremove.
# Optionally, a package name,
# can be specified.


dnf repoquery --list a_package_name
# Lists files, which belong
# to the named package.



# A group is just a collection of packages.

dnf group list
# List the installed and available
# groups .
# To list only the installed groups,
# you can do:
dnf group list --installed
# To list only the available groups,
# you can do:
dnf group list --available


dnf group info a_group_name
# Displays the packages of a group.



# A module is a collection of packages, and
# dependencies, which represent a single
# application. A module has what is called
# a stream, which is just different versions
# of a module. For example, the postgresql
# module, has stream version 10, which represents
# postgresql 10, and stream version 11, which
# represents postgresql 11. A module has profiles,
# examples of profiles are: minimal, small, all.
# A module name format is:
NAME:STREAM:VERSION:CONTEXT:ARCH/PROFILE
# for example:
postgresql:14:3520220111112140:f27b74a8:x86_64


dnf module list
# List all modules streams
# To only list, module streams,
# with installed profile,
# you can do:
dnf module list --installed


dnf module repoquery a_module_name
# Lists the named module packages.

Information:

dnf info a_package_name
# Displays information about the
# named package, this includes,
# the package name, version,
# architecture, summary,
# description...
# If no package name is
# specified, as in
dnf info
# displays all packages
# information.


dnf repoquery --changelogs a_package_name
# Get a package change logs.


dnf repoquery --requires --resolve a_package_name
# Lists the packages, required
# by the named package.


dnf repoquery --whatrequires a_package_name
# Lists the packages, that
# requires the named package.


dnf module info a_module_name
# Provides information about a
# module, as in its name,
# stream, version, context,
# description ...
# If you want to get information,
# about a module profiles, you
# can use:
dnf module info --profile a_module_name

Searching:

dnf search keywords
# Search for the occurrences,
# of the keywords, anywhere,
# in a package name,
# or summary.
# keywords can contain,
# globing characters, as in:
# ?, and *
# Results, are grouped,
# depending on where
# the matching has occurred,
# as in:
# exact name, name,
# name and summary...


dnf list a_file_path
# Displays the packages, for
# which a file belong.


dnf repoquery --groupmember a_package_name
# Lists groups having this package.
# To list the packages, and
# groups, for which a
# file belongs, you can do:
dnf repoquery --groupmember a_file_path


dnf module provides a_package_name
# List all the modules, which
# have the named package.
# To list all modules, providing
# a named file, you can use:
dnf module provides a_file_path

Installation:

dnf install a_package_name
# Downloads, and installs, the
# named packages.


dnf install ~/a_package_name.rpm
# Installs a local rpm package.


dnf install https://url/package.rpm
# Downloads, and installs a
# package, from the internet.


dnf install @a_group_name
# Installs a group, wich is a collection
# of packages, for example:
# dnf install @'Text-based Internet'


dnf group install --with-optional a_group_name
# Installs all packages, belonging
# to the named group.
# If you do not want to install,
# optional packages, you can
# use:
dnf group install a_group_name


dnf install @a_module_name
# Installs a module.
# For example:
dnf install @ruby:3.0


dnf module install a_module_name
# Installs the named module.

Downgrading:

dnf downgrade a_package_name
# Downgrades, to a previous version,
# of the named package.

Updating/Upgrading:

dnf check-update
# Informs you, if updates are
# available for your system.
# if you want to check,
# for updates for a given
# package,
# you can use:
dnf check-update a_package_name
# if you want to view the
# change log, you
#can do:
dnf check-update --changelogs


dnf updateinfo --info
# List for each available update,
# its ID, type, description, severity, bugs ...


dnf upgrade
# Upgrade all packages,to the
# latest versions.
# If you only want to perform,
# upgrades for given packages,
# you can name them, as in:
dnf upgrade a_package_name a_package_name ..
# If you want to upgrade,
# a module, or a group,
# you can use:
dnf upgrade @a_group_or_module_name
# if you want to exclude,
# certain packages from
# being upgraded, you can
# use:
dnf upgrade --exclude=a_package_name,a_package_name..


dnf group upgrade a_group_name
# Updates the packages of a group.


dnf module update a_module_name
# Upgrade the module packages.

Syncing:

dnf distro-sync
# Sync installed packages,
# with enabled repo packages,
# leading, to having the installed
# packages, having the same version,
# as the enabled repo packages.
# A package name can be provided,
# to just sync, the named package.
dnf distro-sync a_package_name

Removing/Cleaning/Purging:

dnf remove a_package_name
# Remove the named packages,
# with any of their dependents.
# If you want to remove a group
# or a module, you can issue:
dnf remove @a_group_or_module_name


dnf group remove a_group_name
# Removes a group, and its
# packages.


dnf module remove a_module_name
# Removes the named module .


dnf remove --oldinstallonly
# Removes old versions of packages,
# which are only installed, and
# never upgraded, such as,
# the kernel.


dnf autoremove
# Removes unneeded dependencies.


dnf remove --duplicates
# When an update fails,
# for example, this can be
# used, to remove duplicate
# packages.


dnf clean packages
# Removes cached packages.
# If you want to remove,
# dbcache, metadata, cached
# packages, and to expire
# repositories meta data,
# you can use:
dnf clean all

Checking:

dnf check
# Checks for problems,
# related to dependencies,
# duplicates, and obsoleted
# packages.

History:

dnf history
# View the history, of what
# was done, with dnf, you will
# get the id, the action, the date
# and time...


dnf history info id
# Get additional information,
# about a history id, such as,
# the affected packages.


dnf history undo id
# Undo the actions performed,
# by this given transaction id,
# in history.


dnf history rollback id
# Undo the actions, of all
# transactions, after the
# specified transaction id.

Plugins:

# Plugins add functionality to
# DNF.
# There are core plugins.
https://dnf-plugins-core.readthedocs.io/en/latest/
dnf install 'dnf-command(plugin-name)'
# And there are community,
# also called extra plugins.
https://dnf-plugins-extras.readthedocs.io/en/latest/index.html
dnf install dnf-plugin-nameOfPlugin
....
# Example core:
dnf install 'dnf-command(versionlock)'
dnf versionlock add package
dnf versionlock delete package
dnf versionlock list
dnf versionlock clear
...
# Example extra:
dnf install dnf-plugin-system-upgrade
dnf system-upgrade download --refresh --releasever=35
dnf system-upgrade reboot