Linux Basics: 15 DNF Command Examples – New Package Manager in Fedora

0

I hope you may know that DNF package manager is replaced the yum package manager in Fedora 22. Here are some examples on how to use DNF package manager.

It maintains CLI compatibility with yum, you would find no difference in using DNF.

You can still use YUM command, but all the commands will be redirected to respective DNF command. You will get similar output when you issue yum command.

Yum command has been deprecated, redirecting to '/usr/bin/dnf install httpd'

Packages can be installed using the following command.

# dnf install vsftpd

Last metadata expiration check performed 0:09:43 ago on Wed May 27 08:47:24 2015.
Dependencies resolved.
========================================================================================================================================================================
Package                               Arch                                  Version                                        Repository                             Size
========================================================================================================================================================================
Installing:
vsftpd                                x86_64                                3.0.2-13.fc22                                  fedora                                172 k

Transaction Summary
========================================================================================================================================================================
Install  1 Package

Total download size: 172 k
Installed size: 348 k
Is this ok [y/N]: y
Downloading Packages:
vsftpd-3.0.2-13.fc22.x86_64.rpm                                                                                                         107 kB/s | 172 kB     00:01
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                    48 kB/s | 172 kB     00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Installing  : vsftpd-3.0.2-13.fc22.x86_64                                                                                                                         1/1
Verifying   : vsftpd-3.0.2-13.fc22.x86_64                                                                                                                         1/1

Installed:
vsftpd.x86_64 3.0.2-13.fc22

Complete!

List the available packages. For example, we will list apache package.

# dnf list bind

Last metadata expiration check performed 0:11:38 ago on Wed May 27 08:47:24 2015.
Available Packages
bind.x86_64                                                                   32:9.10.2-1.fc22                                                                    fedora

To reinstall rpm package.

# dnf reinstall httpd

Last metadata expiration check performed 0:14:17 ago on Wed May 27 08:47:24 2015.
No match for argument: httpd
Error: Nothing to do.
[root@localhost ~]# dnf reinstall vsftpd
Last metadata expiration check performed 0:14:32 ago on Wed May 27 08:47:24 2015.
Dependencies resolved.
========================================================================================================================================================================
Package                               Arch                                  Version                                        Repository                             Size
========================================================================================================================================================================
Reinstalling:
vsftpd                                x86_64                                3.0.2-13.fc22                                  fedora                                172 k

Transaction Summary
========================================================================================================================================================================

Total download size: 172 k
Is this ok [y/N]: y
Downloading Packages:
vsftpd-3.0.2-13.fc22.x86_64.rpm                                                                                                         118 kB/s | 172 kB     00:01
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                    53 kB/s | 172 kB     00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Reinstalling: vsftpd-3.0.2-13.fc22.x86_64                                                                                                                         1/2
Erasing     : vsftpd-3.0.2-13.fc22.x86_64                                                                                                                         2/2
Verifying   : vsftpd-3.0.2-13.fc22.x86_64                                                                                                                         1/2
Verifying   : vsftpd-3.0.2-13.fc22.x86_64                                                                                                                         2/2

Reinstalled:
vsftpd.x86_64 3.0.2-13.fc22

Complete!

To remove any packages that you want, issue the following command.

# dnf remove vsftpd

Dependencies resolved.
========================================================================================================================================================================
Package                               Arch                                  Version                                       Repository                              Size
========================================================================================================================================================================
Removing:
vsftpd                                x86_64                                3.0.2-13.fc22                                 @System                                348 k

Transaction Summary
========================================================================================================================================================================
Remove  1 Package

Installed size: 348 k
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Erasing     : vsftpd-3.0.2-13.fc22.x86_64                                                                                                                         1/1
Verifying   : vsftpd-3.0.2-13.fc22.x86_64                                                                                                                         1/1

Removed:
vsftpd.x86_64 3.0.2-13.fc22

Complete!

To check the history of package installation.

# dnf history

Last metadata expiration check performed 0:15:57 ago on Wed May 27 08:47:24 2015.
ID     | Login user               | Date a | Action | Altere
-------------------------------------------------------------------------------
10 | root               | 2015-05-27 09:02 | Reinstall      |    1
9 | root               | 2015-05-27 09:01 | Install        |    1
8 | root               | 2015-05-27 08:59 | Erase          |    1
7 | root               | 2015-05-27 08:59 | Erase          |    6
6 | root               | 2015-05-27 08:57 | Install        |    1
5 | root               | 2015-05-27 08:56 | Install        |    6
4 | root               | 2015-05-27 08:47 | Install        |    5
3 | System            | 2015-05-26 21:30 | Install        |  658 EE

Downgrade your packages. This command won’t work unless you have a lower version of the mentioned package.

# dnf downgrade vsftpd

To search a particular package.

# dnf search telnet

To exclude a package from the installation. For example, the fedora-logos-httpd package will be excluded while installing apache.

# dnf install httpd --exclude fedora-logos-httpd

To enable / Disable repo while installing packages.

# dnf install httpd --enablerepo fedora

# dnf install httpd --disablerepo fedora

Lists available environment / package groups.

# dnf grouplist

Install any group of packages.

# dnf groupinstall "MATE Desktop"

Download the selected package with its dependencies to any directory.

# dnf download httpd --resolve --destdir /tmp/

To cache/clean the metadata.

# dnf makecache

# dnf clean all

You can get more information from the below commands.

# dnf --help

# man dnf

That’s All.

You might also like