DNF
DNF is the The Fedora Project package manager that is able to query for information about packages, fetch packages from repositories, install and uninstall packages using automatic dependency resolution, and update an entire system to the latest available packages. DNF performs automatic dependency resolution on packages you are updating, installing or removing, and thus is able to automatically determine, fetch and install all available dependent packages. DNF can be configured with new, additional repositories, or package sources, and also provides many plug-ins which enhance and extend its capabilities. DNF is able to perform many of the same tasks that RPM can; additionally, many of the command line options are similar. DNF enables easy and simple package management on a single machine or on groups of them.
|
Secure package management with GPG-signed packages
DNF provides secure package management by enabling GPG (Gnu Privacy Guard; also known as GnuPG) signature verification on GPG-signed packages to be turned on for all package repositories (package sources), or for individual repositories. When signature verification is enabled, DNF will refuse to install any packages not GPG-signed with the correct key for that repository. This means that you can trust that the RPM packages you download and install on your system are from a trusted source, such as The Fedora Project, and were not modified during transfer. See Configuring DNF and DNF Repositories for details on enabling signature-checking with DNF, or Checking Package Signatures for information on working with and verifying GPG-signed RPM packages in general. |
DNF also enables you to easily set up your own repositories of RPM packages for download and installation on other machines.
Learning DNF is a worthwhile investment because it is often the fastest way to perform system administration tasks, and it provides capabilities beyond those provided by the PackageKit graphical package management tools.
|
DNF and superuser privileges
You must have superuser privileges in order to use the dnf command to install, update or remove packages on your system. All examples in this chapter assume that you have already obtained superuser privileges by using either the su or sudo command. |
Checking For and Updating Packages
Checking For Updates
The quickest way to check for updates is to attempt to install any available updates by using the dnf upgrade command as follows:
~]# dnf upgrade Last metadata expiration check performed 1:24:32 ago on Thu May 14 23:23:51 2015. Dependencies resolved. Nothing to do. Complete!
Note that dnf upgrade installs only those updates that can be installed. If a package cannot be updated, because of dependency problems for example, it is skipped.
The dnf check-update command can be used see which installed packages on your system have new versions available, however it does not mean that they can be successfully installed. This command is therefore mostly useful in scripts and for checking for updated packages that were not installed after running dnf upgrade.
For example:
~]# dnf check-update Using metadata from Mon Apr 20 16:34:10 2015 (2:42:10 hours old) python.x86_64 2.7.9-6.fc22 updates python-cryptography.x86_64 0.8.2-1.fc22 updates python-libs.x86_64 2.7.9-6.fc22 updates
The packages in the above output are listed as having updated versions. The line in the example output tells us:
-
python— the name of the package, -
x86_64— the CPU architecture the package was built for, -
2.7.9— the version of the updated package, -
6.fc22— the release of the updated package, -
updates-testing— the repository in which the updated package is located.
Updating Packages
You can choose to update a single package, multiple packages, or all packages at once. If any dependencies of the package, or packages, you update have updates available themselves, then they are updated too.
To update a single package, run the following command as root:
dnf upgrade package_name
For example, to update the python package, type:
~]# dnf upgrade python Using metadata from Mon Apr 20 16:38:16 2015 (2:42:14 hours old) Dependencies resolved. ================================================================== Package Arch Version Repository Size ================================================================== Upgrading: python x86_64 2.7.9-6.fc22 updates 92 k python-libs x86_64 2.7.9-6.fc22 updates 5.8 M Transaction Summary ================================================================== Upgrade 2 Packages Total download size: 5.9 M Is this ok [y/N]:
This output contains:
-
python.x86_64— you can download and install new python package. -
python-libs.x86_64— DNF has resolved that the python-libs-2.7.9-6.fc22.x86_64 package is a required dependency of the python package. -
DNF presents the update information and then prompts you as to whether you want it to perform the update; DNF runs interactively by default. If you already know which transactions DNF plans to perform, you can use the
-yoption to automatically answer yes to any questions DNF may ask (in which case it runs non-interactively). However, you should always examine which changes DNF plans to make to the system so that you can easily troubleshoot any problems that might arise.If a transaction does go awry, you can view DNF’s transaction history by using the dnf history command as described in Working with Transaction History.
|
Updating and installing kernels with DNF
DNF always installs a new kernel in the same sense that RPM installs a new kernel when you use the command rpm -i kernel. Therefore, you do not need to worry about the distinction between installing and upgrading a kernel package when you use the dnf command: it will do the right thing, regardless of whether you are using the dnf upgrade or dnf install command. When using RPM, on the other hand, it is important to use the rpm -i kernel command (which installs a new kernel) instead of rpm -u kernel (which replaces the current kernel). See Installing and Upgrading Packages for more information on installing and updating kernels with RPM. |
To update all packages and their dependencies, enter dnf upgrade without any arguments:
dnf upgrade
Preserving Configuration File Changes
You will inevitably make changes to the configuration files installed by packages as you use your Fedora system. RPM, which DNF uses to perform changes to the system, provides a mechanism for ensuring their integrity. See Installing and Upgrading Packages for details on how to manage changes to configuration files across package upgrades.
Packages and Package Groups
Searching Packages
You can search all RPM package names and summaries by using the following command:
dnf search term…
Add the all to match against descriptions and URLs.
dnf search all term…
This command displays the list of matches for each term. For example, to list all packages that match "meld" or "kompare", type:
~]# dnf search meld kompare Loaded plugins: langpacks, presto, refresh-packagekit ============================== N/S Matched: meld =============================== meld.noarch : Visual diff and merge tool python-meld3.x86_64 : HTML/XML templating system for Python ============================= N/S Matched: kompare ============================= komparator.x86_64 : Kompare and merge two folders Name and summary matches only, use "search all" for everything.
Listing Packages
dnf list and related commands provide information about packages, package groups, and repositories.
All of DNF’s list commands allow you to filter the results by appending one or more glob expressions as arguments. Glob expressions are normal strings of characters which contain one or more of the wildcard characters * (which expands to match any character multiple times) and ? (which expands to match any one character).
|
Filtering results with glob expressions
Be careful to escape the glob expressions when passing them as arguments to a dnf command, otherwise the Bash shell will interpret these expressions as pathname expansions, and potentially pass all files in the current directory that match the globs to DNF. To make sure the glob expressions are passed to DNF as intended, either:
DNF searches only package names when using glob expressions. To search for a version of a package, include a dash and part of the version number as follows: ~]# dnf search kernel*-4* Last metadata expiration check performed 2:46:09 ago on Thu May 14 23:23:51 2015. Installed Packages kernel.x86_64 4.0.0-1.fc22 @System kernel.x86_64 4.0.2-300.fc22 @System kernel-core.x86_64 4.0.0-1.fc22 @System kernel-core.x86_64 4.0.2-300.fc22 @System [output truncated] See Listing all ABRT addons and plug-ins using glob expressions and Listing available packages using a single glob expression with escaped wildcard characters for an example usage of both these methods. |
- dnf list glob_expression…
-
Lists information on installed and available packages matching all glob expressions.
Exemplo 1. Listing all ABRT addons and plug-ins using glob expressionsPackages with various ABRT addons and plug-ins either begin with "abrt-addon-", or "abrt-plugin-". To list these packages, type the following at a shell prompt:
~]# dnf list abrt-addon\* abrt-plugin\* Last metadata expiration check performed 0:14:36 ago on Mon May 25 23:38:13 2015. Installed Packages abrt-addon-ccpp.x86_64 2.5.1-2.fc22 @System abrt-addon-coredump-helper.x86_64 2.5.1-2.fc22 @System abrt-addon-kerneloops.x86_64 2.5.1-2.fc22 @System abrt-addon-pstoreoops.x86_64 2.5.1-2.fc22 @System abrt-addon-python.x86_64 2.5.1-2.fc22 @System abrt-addon-python3.x86_64 2.5.1-2.fc22 @System abrt-addon-vmcore.x86_64 2.5.1-2.fc22 @System abrt-addon-xorg.x86_64 2.5.1-2.fc22 @System abrt-plugin-bodhi.x86_64 2.5.1-2.fc22 @System Available Packages abrt-addon-upload-watch.x86_64 2.5.1-2.fc22 fedora
- dnf list all
-
Lists all installed and available packages.
Exemplo 2. Listing all installed and available packages~]# dnf list all Last metadata expiration check performed 0:21:11 ago on Mon May 25 23:38:13 2015. Installed Packages NetworkManager.x86_64 1:1.0.2-1.fc22 @System NetworkManager-libnm.x86_64 1:1.0.2-1.fc22 @System PackageKit.x86_64 1.0.6-4.fc22 @System PackageKit-glib.x86_64 1.0.6-4.fc22 @System aajohan-comfortaa-fonts.noarch 2.004-4.fc22 @System abrt.x86_64 2.5.1-2.fc22 @System [output truncated]
- dnf list installed
-
Lists all packages installed on your system. The rightmost column in the output lists the repository from which the package was retrieved.
Exemplo 3. Listing installed packages using a double-quoted glob expressionTo list all installed packages that begin with "krb" followed by exactly one character and a hyphen, type:
~]# dnf list installed "krb?-*" Last metadata expiration check performed 0:34:45 ago on Mon May 25 23:38:13 2015. Installed Packages krb5-libs.x86_64 1.13.1-3.fc22 @System krb5-workstation.x86_64 1.13.1-3.fc22 @System
- dnf list available
-
Lists all available packages in all enabled repositories.
Exemplo 4. Listing available packages using a single glob expression with escaped wildcard charactersTo list all available packages with names that contain "gstreamer" and then "plugin", run the following command:
~]# dnf list available gstreamer\*plugin\* Last metadata expiration check performed 0:42:15 ago on Mon May 25 23:38:13 2015. Available Packages gstreamer-plugin-crystalhd.i686 3.10.0-8.fc22 fedora gstreamer-plugin-crystalhd.x86_64 3.10.0-8.fc22 fedora gstreamer-plugins-bad-free.i686 0.10.23-24.fc22 fedora gstreamer-plugins-bad-free.x86_64 0.10.23-24.fc22 fedora gstreamer-plugins-bad-free-devel.i686 0.10.23-24.fc22 fedora gstreamer-plugins-bad-free-devel.x86_64 0.10.23-24.fc22 fedora [output truncated]
- dnf group list
-
Lists all package groups.
Exemplo 5. Listing all package groups~]# dnf group list Loaded plugins: langpacks, presto, refresh-packagekit Setting up Group Process Installed Groups: Administration Tools Design Suite Dial-up Networking Support Fonts GNOME Desktop Environment [output truncated]
- dnf repolist
-
Lists the repository ID, name, and number of packages it provides for each enabled repository.
Exemplo 6. Listing enabled repositories~]# dnf repolist Last metadata expiration check performed 0:48:29 ago on Mon May 25 23:38:13 2015. repo id repo name status *fedora Fedora 22 - x86_64 44,762 *updates Fedora 22 - x86_64 - Updates 0
- dnf repository-packages repo_id list
-
Lists the packages from the specified repository.
Exemplo 7. Listing packages from a single repository~]# dnf repository-packages fedora list [option] Last metadata expiration check performed 1:38:25 ago on Wed May 20 22:16:16 2015. Installed Packages PackageKit.x86_64 1.0.6-3.fc22 @System PackageKit-glib.x86_64 1.0.6-3.fc22 @System aajohan-comfortaa-fonts.noarch 2.004-4.fc22 @System [output truncated]
The default action is to list all packages available and installed from the repository specified. Add the
availableorinstalledoption to list only those packages available or installed from the specified repository.
Displaying Package Information
To display information about one or more packages, use a command as follows:
dnf info package_name…
For example, to display information about the abrt package, type:
~]# dnf info abrt
Last metadata expiration check: 1:09:44 ago on Tue May 31 06:51:51 2016.
Installed Packages
Name : abrt
Arch : x86_64
Epoch : 0
Version : 2.8.1
Release : 1.fc24
Size : 2.2 M
Repo : @System
From repo : updates-testing
Summary : Automatic bug detection and reporting tool
URL : https://abrt.readthedocs.org/
License : GPLv2+
Description : abrt is a tool to help users to detect defects in applications and
: to create a bug report with all information needed by maintainer to fix it.
: It uses plugin system to extend its functionality.
The dnf info package_name command is similar to the rpm -q --info package_name command, but provides as additional information the name of the DNF repository the RPM package was installed from (look for the From repo: line in the output). The dnf info command shows only the newest available package if there is a newer version available than the one installed. The dnf repoquery command can show all installed and available packages.
To display information about all available packages, both installed and available from a repository, use a command as follows:
dnf repoquery package_name --info
For example, to display information about the abrt package, type:
~]# dnf repoquery abrt --info Last metadata expiration check: 1:01:44 ago on Tue May 31 06:51:51 2016. Name : abrt Version : 2.8.1 Release : 1.fc24 Architecture: x86_64 Size : 2318452 License : GPLv2+ Source RPM : abrt-2.8.1-1.fc24.src.rpm Build Date : 2016-05-25 08:54 Packager : Fedora Project URL : https://abrt.readthedocs.org/ Summary : Automatic bug detection and reporting tool Description : abrt is a tool to help users to detect defects in applications and to create a bug report with all information needed by maintainer to fix it. It uses plugin system to extend its functionality.
See the dnf repoquery usage statement for more options:
~]$ dnf repoquery -h
usage: dnf [options] COMMAND
output truncated
Installing Packages
DNF allows you to install both a single package and multiple packages, as well as a package group of your choice.
To install a single package and all of its non-installed dependencies, enter a command in the following form:
dnf install package_name
You can also install multiple packages simultaneously by appending their names as arguments:
dnf install package_name package_name…
If you are installing packages on a multilib system, such as an AMD64 or Intel64 machine, you can specify the architecture of the package, as long as it is available in an enabled repository, by appending .arch to the package name. For example, to install the sqlite2 package for i586, type:
~]# dnf install sqlite2.i586
You can use glob expressions to quickly install multiple similarly-named packages:
~]# dnf install audacious-plugins-\*
In addition to package names and glob expressions, you can also provide file names to dnf install. If you know the name of the binary you want to install, but not its package name, you can give dnf install the path name:
~]# dnf install /usr/sbin/named
dnf then searches through its package lists, finds the package which provides /usr/sbin/named, if any, and prompts you as to whether you want to install it.
|
Finding which package owns a file
If you know you want to install the package that contains the ~]# dnf provides "*bin/named" Using metadata from Thu Apr 16 13:41:45 2015 (4:23:50 hours old) bind-32:9.10.2-1.fc22.x86_64 : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server Repo : @System dnf provides "*/file_name" will find all the packages that contain file_name. |
A package group is similar to a package: it is not useful by itself, but installing one pulls a group of dependent packages that serve a common purpose. A package group has a name and a groupid (GID). The dnf group list -v command lists the names of all package groups, and, next to each of them, their groupid in parentheses. The groupid is always the term in the last pair of parentheses, such as kde-desktop-environment in the following example:
~]# dnf -v group list kde\* cachedir: /var/cache/dnf/x86_64/22 Loaded plugins: builddep, config-manager, copr, playground, debuginfo-install, download, generate_completion_cache, kickstart, needs-restarting, noroot, protected_packages, Query, reposync, langpacks initialized Langpacks plugin DNF version: 0.6.5 repo: using cache for: fedora not found deltainfo for: Fedora 22 - x86_64 not found updateinfo for: Fedora 22 - x86_64 repo: using cache for: updates-testing repo: using cache for: updates not found updateinfo for: Fedora 22 - x86_64 - Updates Using metadata from Thu Apr 16 13:41:45 2015 (4:37:51 hours old) Available environment groups: KDE Plasma Workspaces (kde-desktop-environment)
You can install a package group by passing its full group name (without the groupid part) to group install:
dnf group install group_name
Multi-word names must be quoted.
You can also install by groupid:
dnf group install groupid
You can even pass the groupid, or quoted name, to the install command if you prepend it with an @-symbol (which tells dnf that you want to perform a group install):
dnf install @group
For example, the following are alternative but equivalent ways of installing the KDE Plasma Workspaces group:
~]# dnf group install "KDE Plasma Workspaces" ~]# dnf group install kde-desktop-environment ~]# dnf install @kde-desktop-environment
Removing Packages
Similarly to package installation, DNF allows you to uninstall (remove in RPM and DNF terminology) both individual packages and a package group.
To uninstall a particular package, as well as any packages that depend on it, run the following command as root:
dnf remove package_name…
As when you install multiple packages, you can remove several at once by adding more package names to the command. For example, to remove totem, rhythmbox, and sound-juicer, type the following at a shell prompt:
~]# dnf remove totem rhythmbox sound-juicer
Similar to install, remove can take these arguments:
-
package names
-
glob expressions
-
file lists
-
package provides
|
Removing a package when other packages depend on it
DNF is not able to remove a package without also removing packages which depend on it. This type of operation can only be performed by RPM, is not advised, and can potentially leave your system in a non-functioning state or cause applications to misbehave and terminate unexpectedly. For further information, refer to Uninstalling Packages in the RPM chapter. |
You can remove a package group using syntax congruent with the install syntax:
dnf group remove group
dnf remove @group
The following are alternative but equivalent ways of removing the KDE Plasma Workspaces group:
~]# dnf group remove "KDE Plasma Workspaces" ~]# dnf group remove kde-desktop-environment ~]# dnf remove @kde-desktop-environment
Working with Transaction History
The dnf history command allows users to review information about a timeline of DNF transactions, the dates and times on when they occurred, the number of packages affected, whether transactions succeeded or were aborted, and if the RPM database was changed between transactions. Additionally, this command can be used to undo or redo certain transactions.
To display a list of all transactions, as root, either run dnf history with no additional arguments, or enter the following command:
dnfhistorylist
To display only transactions in a given range, use the command in the following form:
dnf history list start_id..end_id
You can also list only transactions regarding a particular package or packages. To do so, use the command with a package name or a glob expression:
dnf history list glob_expression…
For example, the list of first five transactions may look as follows:
~]# dnf history list 1..4
Using metadata from Thu Apr 16 13:41:45 2015 (5:47:31 hours old)
ID | Login user | Date a | Action | Altere
-------------------------------------------------------------------------------
4 | root <root> | 2015-04-16 18:35 | Erase | 1
3 | root <root> | 2015-04-16 18:34 | Install | 1
2 | root <root> | 2015-04-16 17:53 | Install | 1
1 | System <unset> | 2015-04-16 14:14 | Install | 668 E
The dnf history list command produces tabular output with each row consisting of the following columns:
-
ID— an integer value that identifies a particular transaction. -
Login user— the name of the user whose login session was used to initiate a transaction. This information is typically presented in theFull Name <username>form, however sometimes the command used to perform the transaction is displayed. For transactions that were not issued by a user (such as an automatic system update),System <unset>is used instead. -
Date and time— the date and time when a transaction was issued. -
Action(s)— a list of actions that were performed during a transaction as described in Possible values of the Action(s) field. -
Altered— the number of packages that were affected by a transaction, possibly followed by additional information.
| Action | Abbreviation | Description |
|---|---|---|
|
|
At least one package has been downgraded to an older version. |
|
|
At least one package has been removed. |
|