The following examples can be used to demonstrate the normal usage for the DNF in the normal Linux working environment.
In this example, we will install .rpm file that we just downloaded with the dnf download the plugin. While we could have just installed this package from the repository directly with ‘dnf install’. Sometimes you may be provided with .rpm files directly for installation so it’s worth knowing how to install them.While .rpm files can be installed with the ‘rpm’ command, using dnf has the advantage of automatically detecting and installing any other package dependencies that may also be required.
Note that in order to remove a package, all other packages which depend on it will also be removed. For that reason, it is recommended not to use the -y option to ‘assume yes’ when removing a package so that you get a chance to read what will be removed before proceeding as it may be more than you expect.In the above example, the httpd-manual package that we installed previously requires the httpd package. Therefore when we remove the httpd package, httpd-manual must go too.
We simply provide a known repository URL in the –add-repo option and this creates a .repo file based on the name of the repository URL specified. In this case, etc/yum.repos.d/mirror.aarnet.edu.au_pub_centos_7.repo has been created with the contents specified above in the output of the command. We can now install or update packages from this newly specified mirror.There are many more commands that can be done using DNF, we shall create another article detailing more command examples that can be used with DNF if deemed necessary but in the mean time please feel free to experiment with the commands listed in the inbuilt help.