[id='the-most-useful-dnf-commands']
= The most useful DNF commands

This sections lists the most useful commands provided by the *dnf* utility. For a complete list of commands, options, and their syntax, see the *dnf*(8) man page.

*dnf help _command_*:: Displays detailed information about a command.
+
[literal,subs="+quotes,attributes"]
----
$ *dnf help _upgrade_*
upgrade [PACKAGE...]

upgrade a package or packages on your system
alias: update
----

*dnf upgrade*:: Upgrades all packages on the system to the latest version available.
+
[literal,subs="+quotes,attributes"]
----
# *dnf upgrade*
Last metadata expiration check: 1:09:32 ago on Thu Dec 14 09:20:48 2017.
Dependencies resolved.
Nothing to do.
Complete!
----

*dnf upgrade _package_name_*:: Upgrades a package to the latest version available.
+
[literal,subs="+quotes,attributes"]
----
# *dnf upgrade _dia_*
Last metadata expiration check: 1:11:26 ago on Thu Dec 14 09:20:48 2017.
Dependencies resolved.
Nothing to do.
Complete!
----

*dnf install _package_name_*:: Installs a package.

[literal,subs="+quotes,attributes"]
----
# *dnf install _dia_*
Last metadata expiration check: 1:07:19 ago on Thu Dec 14 09:20:48 2017.
Dependencies resolved.
=============================================================================
 Package          Arch           Version           Repository           Size
=============================================================================
Installing:
 dia              x86_64         1:0.97.3-5.fc24   fedora               4.2 M
 libart_lgpl      x86_64         2.3.21-15.fc25    fedora               71 k

Transaction Summary
=============================================================================
Install  2 Packages

Total download size: 4.2 M
Installed size: 18 M
Is this ok [y/N]: *y*
[... output truncated ...]
Installed:
  dia.x86_64 1:0.97.3-5.fc24          libart_lgpl.x86_64 2.3.21-15.fc25

Complete!
----

*dnf remove _package_name_*:: Uninstalls a package.
+
[literal,subs="+quotes,attributes"]
----
# *dnf remove _dia_*
Dependencies resolved.
=============================================================================
 Package          Arch           Version           Repository           Size
=============================================================================
Removing:
 dia              x86_64         1:0.97.3-5.fc24   @fedora              18 M
 libart_lgpl      x86_64         2.3.21-15.fc25    @fedora              126 k

Transaction Summary
=============================================================================
Remove  2 Packages

Installed size: 18 M
Is this ok [y/N]: *y*
[... output truncated ...]
Removed:
  dia.x86_64 1:0.97.3-5.fc24           libart_lgpl.x86_64 2.3.21-15.fc25

Complete!
----

*dnf check-update*:: Checks if any updates are available for all packages in the enabled repositories.
+
[literal,subs="+quotes,attributes"]
----
389-ds-base.x86_64                    1.3.7.5-11.el7           @updates
389-ds-base-libs.x86_64               1.3.7.5-11.el7           @updates
NetworkManager.x86_64                 1:1.10.2-3.el7           @updates
NetworkManager-config-server.noarch   1:1.10.2-3.el7           @updates
[... output truncated ...]
----

*dnf search _keyword_*:: Search package metadata in the enabled repositories for the specified keyword. By default, the commands searches only in package names and summaries.
+
[literal,subs="+quotes,attributes"]
----
# *dnf search _freeipa_*
Last metadata expiration check: 1:12:31 ago on Thu Dec 14 09:20:48 2017.
========================================================================
freeipa-client.x86_64 : IPA authentication for use on clients
freeipa-common.noarch : Common files used by IPA
freeipa-server.x86_64 : The IPA authentication server
freeipa-server-dns.noarch : IPA integrated DNS server with support for automatic DNSSEC signing
freeipa-client-common.noarch : Common files used by IPA client
freeipa-python-compat.noarch : Compatiblity package for Python libraries used by IPA
freeipa-server-common.noarch : Common files used by IPA server
freeipa-server-trust-ad.x86_64 : Virtual package to install packages required for Active Directory trusts
libsss_idmap.x86_64 : FreeIPA Idmap library
[... output truncated ...]
----

*dnf info _package_name_*:: Shows details for a package.
+
[literal,subs="+quotes,attributes"]
----
[root@localhost ~]# *dnf info _freeipa-server_*
Last metadata expiration check: 1:13:14 ago on Thu Dec 14 09:20:48 2017.
Available Packages
Name        : freeipa-server
Arch        : x86_64
Epoch       : 0
Version     : 4.4.4
Release     : 1.fc25
Size        : 380 k
Repo        : updates
Summary     : The IPA authentication server
URL         : https://www.freeipa.org/
License     : GPLv3+
Description : IPA is an integrated solution to provide centrally managed Identity (users,
            : hosts, services), Authentication (SSO, 2FA), and Authorization
            : (host access control, SELinux user roles, services). The solution provides
            : features for further integration with Linux based clients (SUDO, automount)
            : and integration with Active Directory based infrastructures (Trusts).
            : If you are installing an IPA server, you need to install this package.
----


*dnf provides _command_or_file_*:: Shows which package provides the specified command or file.
+
To specify a command:
+
[literal,subs="+quotes,attributes"]
----
# *dnf provides */_ipa-server-install_*
Last metadata expiration check: 1:14:12 ago on Thu Dec 14 09:20:48 2017.
freeipa-server-4.4.1-1.fc25.x86_64 : The IPA authentication server
Repo        : fedora

freeipa-server-4.4.4-1.fc25.x86_64 : The IPA authentication server
Repo        : updates
----
+
To specify a file:
+
[literal,subs="+quotes,attributes"]
----
# *dnf provides _/etc/sssd/sssd.conf_*
Last metadata expiration check: 1:14:58 ago on Thu Dec 14 09:20:48 2017.
sssd-common-1.16.0-4.fc25.x86_64 : Common files for the SSSD
Repo        : @System

sssd-common-1.16.0-4.fc25.x86_64 : Common files for the SSSD
Repo        : updates

sssd-common-1.14.2-1.fc25.i686 : Common files for the SSSD
Repo        : fedora

sssd-common-1.14.2-1.fc25.x86_64 : Common files for the SSSD
Repo        : fedora
----

*dnf history*:: Displays a report of the past *yum* transactions.
+
[literal,subs="+quotes,attributes"]
----
# *dnf history*
ID     | Command line             | Date and time    | Action(s)      | Altered
 -------------------------------------------------------------------------------
     9 | update -y                | 2017-10-17 12:35 | I, U           |   17 EE
     8 | install midori           | 2017-10-13 10:44 | Install        |    3 >
     7 | update -y                | 2017-10-12 15:59 | Update         |    7
     6 | install keepass          | 2017-10-11 13:40 | Install        |   13  <
     5 | install thunderbird      | 2017-10-10 16:33 | Install        |    1 >
     4 | install sssd krb5-workst | 2017-10-10 15:30 | Install        |    3 >
     3 | install xchat            | 2017-10-10 15:19 | Install        |    4
     2 | update                   | 2017-10-10 13:44 | I, O, U        |  752 EE
     1 |                          | 2017-10-10 13:34 | Install        | 1373 EE
----

*dnf list installed*:: Lists all packages installed on the system.
+
[literal,subs="+quotes,attributes"]
----
# *dnf list installed*
Last metadata expiration check: 1:17:33 ago on Thu Dec 14 09:20:48 2017.
Installed Packages
GConf2.x86_64                                                                                         3.2.6-16.fc24                                                                             @anaconda
GeoIP.x86_64                                                                                          1.6.11-1.fc25                                                                             @updates
GeoIP-GeoLite-data.noarch                                                                             2017.10-1.fc25                                                                            @updates
ImageMagick.x86_64                                                                                    6.9.9.19-1.fc25                                                                           @updates
ImageMagick-libs.x86_64                                                                               6.9.9.19-1.fc25                                                                           @updates
LibRaw.x86_64                                                                                         0.17.2-2.fc25                                                                             @updates
ModemManager.x86_64                                                                                   1.6.4-1.fc25                                                                              @updates
ModemManager-glib.x86_64                                                                              1.6.4-1.fc25                                                                              @updates
NetworkManager.x86_64                                                                                 1:1.4.6-1.fc25                                                                            @updates
[... output truncated ...]
----
