# 8.2 Install and Update Software
Dandified yum, better known as DNF, is a software package manager for RPM-based Linux distributions that installs, updates, and removes packages. It was first introduced in Fedora 18 in a testable state (i.e., tech preview), but it's been Fedora's default package manager since Fedora 22.
Since it is the next-generation version of the traditional yum package manager, it has more advanced and robust features than you'll find in yum. Some of the features that distinguish DNF from yum are:
- Dependency calculation based on modern dependency-solving technology
- Optimized memory-intensive operations
- The ability to run in Python 2 and Python 3
- Complete documentation available for Python APIs
DNF uses hawkey libraries, which resolve RPM dependencies for running queries on client machines. These are built on top of libsolv, a package-dependency solver that uses a satisfiability algorithm. You can find more details on the algorithm in libsolv's GitHub repository.
[Source Article](https://opensource.com/article/18/8/guide-yum-dnf)
[Libsolv Gitlab](https://github.com/openSUSE/libsolv)
### Activating DNF Autocomplete
To activate DNF autocompletion in RHEL and Centos8 we need a sepperate package:
```bash
dnf install dnf-automatic.noarch -y
```
This will install a package that will allow you to TAB autocomplete the dnf command.
### Searching for a Package
Attempt to run the command gnuplot. You should find that it is not installed:
```bash
[root@rhcsa ~]# gnuplot
-bash: gnuplot: command not found
```
Search for plotting packages
```bash
[root@rhcsa ~]# dnf search plot
```
```bash
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.ams1.nl.leaseweb.net
* extras: mirrors.supportex.net
* updates: mirrors.supportex.net
================================================================= N/S matched: plot ==================================================================
emacs-gnuplot.noarch : Emacs bindings for the gnuplot main application
emacs-gnuplot-el.noarch : Emacs bindings for the gnuplot main application
gnuplot.x86_64 : A program for plotting mathematical expressions and data
gnuplot-common.x86_64 : The common gnuplot parts
gnuplot-doc.noarch : Documentation fo bindings for the gnuplot main application
gnuplot-latex.noarch : Configuration for LaTeX typesetting using gnuplot
gnuplot-minimal.x86_64 : Minimal version of program for plotting mathematical expressions and data
python-matplotlib.x86_64 : Python 2D plotting library
python-matplotlib-doc.x86_64 : Documentation files for python-matplotlib
python-matplotlib-qt4.x86_64 : Qt4 backend for python-matplotlib
python-matplotlib-tk.x86_64 : Tk backend for python-matplotlib
texlive-pst-plot.noarch : Plot data using PSTricks
texlive-pst-plot-doc.noarch : Documentation for pst-plot
oscilloscope.noarch : Generic graphical signal plotting tool
```
### Getting Information about packages
If you want more information about a package, you can run the ```dnf info``` command: this provides you with a lot of details about packages.
```bash
[root@rhcsa ~]# dnf info gnuplot
Last metadata expiration check: 0:28:59 ago on Sun 19 Jul 2020 08:38:53 AM EDT.
Available Packages
Name : gnuplot
Version : 5.2.4
Release : 1.el8
Arch : x86_64
Size : 893 k
Source : gnuplot-5.2.4-1.el8.src.rpm
Repo : AppStream
Summary : A program for plotting mathematical expressions and data
URL : http://www.gnuplot.info/
License : gnuplot and MIT
Description : Gnuplot is a command-line driven, interactive function plotting
: program especially suited for scientific data representation. Gnuplot
: can be used to plot functions and data points in both two and three
: dimensions and in many different formats.
:
: Install gnuplot if you need a graphics package for scientific data
: representation.
:
: This package provides a Qt based terminal version of gnuplot.
```
### Install a Package
Now that we know a little more about the package, we want to install the package.
We install the gnuplot package with the ```dnf install``` command. You can add the option ```-y``` to the command to provide the system with confirmation on installation (otherwise it will ask you for it).
```bash
[root@rhcsa ~]# dnf install -y gnuplot
```
It should tell you when the package installation is complete:
```bash
Installed:
gnuplot-5.2.4-1.el8.x86_64 gnuplot-common-5.2.4-1.el8.x86_64 qt5-qtbase-5.12.5-4.el8.x86_64
qt5-qtbase-common-5.12.5-4.el8.noarch qt5-qtbase-gui-5.12.5-4.el8.x86_64 qt5-qtsvg-5.12.5-1.el8.x86_64
xcb-util-image-0.4.0-9.el8.x86_64 xcb-util-keysyms-0.4.0-7.el8.x86_64 xcb-util-renderutil-0.3.9-10.el8.x86_64
xcb-util-wm-0.4.1-12.el8.x86_64 pcre2-utf16-10.32-1.el8.x86_64
Complete!
```
This tells you that the installation was a success and what packages are installed. As you can see, to install ```gnuplot```, it also had to install several dependencies. The ```dnf``` command finds these dependencies automatically and installs them together with the requested package.
### Removing a Package
Now let's pretend we want to remove the package.
Attempt to remove the gnuplot package (do not add ```-y```), but answer the request with **no**. How many packages would be removed?
```bash
[root@rhcsa ~]# dnf remove gnuplot
```
```bash
[root@rhcsa ~]# dnf remove gnuplot
Dependencies resolved.
=======================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================
Removing:
gnuplot x86_64 5.2.4-1.el8 @AppStream 2.1 M
Removing unused dependencies:
gnuplot-common x86_64 5.2.4-1.el8 @AppStream 1.7 M
pcre2-utf16 x86_64 10.32-1.el8 @BaseOS 596 k
qt5-qtbase x86_64 5.12.5-4.el8 @AppStream 10 M
qt5-qtbase-common noarch 5.12.5-4.el8 @AppStream 75
qt5-qtbase-gui x86_64 5.12.5-4.el8 @AppStream 20 M
qt5-qtsvg x86_64 5.12.5-1.el8 @AppStream 665 k
xcb-util-image x86_64 0.4.0-9.el8 @AppStream 22 k
xcb-util-keysyms x86_64 0.4.0-7.el8 @AppStream 13 k
xcb-util-renderutil x86_64 0.3.9-10.el8 @AppStream 21 k
xcb-util-wm x86_64 0.4.1-12.el8 @AppStream 78 k
Transaction Summary
=======================================================================================================================
Remove 11 Packages
Freed space: 35 M
Is this ok [y/N]:
```
So you can see that Linux is tracking what dependencies are used by other packages; it knows these dependencies are unused if we remove ```gnuplot```, so it will clean the unused dependencies as well.
Attempt to remove the gnuplot -common package, but say **no**. How many packages would be removed?
```bash
[root@rhcsa ~]# dnf remove gnuplot-common
```
```bash
[root@rhcsa ~]# dnf remove gnuplot-common
Dependencies resolved.
=======================================================================================================================
Package Arch Version Repository Size
=======================================================================================================================
Removing:
gnuplot-common x86_64 5.2.4-1.el8 @AppStream 1.7 M
Removing dependent packages:
gnuplot x86_64 5.2.4-1.el8 @AppStream 2.1 M
Removing unused dependencies:
pcre2-utf16 x86_64 10.32-1.el8 @BaseOS 596 k
qt5-qtbase x86_64 5.12.5-4.el8 @AppStream 10 M
qt5-qtbase-common noarch 5.12.5-4.el8 @AppStream 75
qt5-qtbase-gui x86_64 5.12.5-4.el8 @AppStream 20 M
qt5-qtsvg x86_64 5.12.5-1.el8 @AppStream 665 k
xcb-util-image x86_64 0.4.0-9.el8 @AppStream 22 k
xcb-util-keysyms x86_64 0.4.0-7.el8 @AppStream 13 k
xcb-util-renderutil x86_64 0.3.9-10.el8 @AppStream 21 k
xcb-util-wm x86_64 0.4.1-12.el8 @AppStream 78 k
Transaction Summary
=======================================================================================================================
Remove 11 Packages
Freed space: 35 M
Is this ok [y/N]:
```
Now it would also remove the packages that need the dependent items.
### Group Packages
There are also grouped packages, for example, if you want to make a Network sever. We can easily install a DNF group like ```Network Server```; this would install all packages and setup our server in such a way that we could start making a networking server. This automates the server delivery process quite a bit.
List all available component groups
```bash
[root@rhcsa ~]# dnf grouplist
```
Result:
```bash
[root@rhcsa ~]# dnf group list
Last metadata expiration check: 0:36:05 ago on Sun 19 Jul 2020 08:38:53 AM EDT.
Available Environment Groups:
Server
Minimal Install
Workstation
Virtualization Host
Custom Operating System
Installed Environment Groups:
Server with GUI
Installed Groups:
Container Management
Headless Management
Available Groups:
.NET Core Development
RPM Development Tools
Development Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Network Servers
Scientific Support
Security Tools
Smart Card Support
System Tools
```
Find out more information about the ```Security Tools``` component group, including a list of included packages.
```bash
[root@rhcsa ~]# dnf group info "Security Tools"
```
```bash
[root@rhcsa ~]# dnf group info "Security Tools"
Last metadata expiration check: 0:40:13 ago on Sun 19 Jul 2020 08:38:53 AM EDT.
Group: Security Tools
Description: Security tools for integrity and trust verification.
Default Packages:
scap-security-guide
Optional Packages:
aide
hmaccalc
openscap
openscap-engine-sce
openscap-utils
scap-security-guide-doc
scap-workbench
tpm-quote-tools
tpm-tools
tpm2-tools
trousers
udica
```
Install the ```Security Tools``` component group.
```bash
dnf group install -y "Security Tools"
```
This should install the entire ```Security Tools``` group.
### Installation History and Undo changes
Sometimes you want to investigate previous installations and/or removals of software on the server; you can do this with the ```dnf history``` command:
```bash
[root@rhcsa ~]# dnf history
```
```bash
[root@rhcsa ~]# dnf history
ID | Command line | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
10 | group install -y Securit | 2020-07-19 09:20 | Install | 4
9 | install gnuplot | 2020-07-19 09:10 | Install | 11
8 | update kernel | 2020-07-19 08:16 | I, U | 18
7 | | 2020-07-07 12:53 | Install | 9
6 | | 2020-07-07 12:53 | I, U | 61 EE
5 | | 2020-07-07 12:52 | Upgrade | 1
4 | | 2020-07-07 12:52 | Upgrade | 2
3 | install qemu-guest-agent | 2020-07-03 11:10 | Upgrade | 1
2 | install cloud-init | 2020-07-03 10:32 | Install | 11
1 | | 2020-07-03 10:14 | Install | 1320 EE
```
As you can see, for me, item ```10``` is the group install. Let's get more information about it.
**Check what number your own install history is.**
Confirm that the last transaction is the group installation.
```bash
[root@rhcsa ~]# dnf history info 10
```
```bash
[root@rhcsa ~]# dnf history info 10
Transaction ID : 10
Begin time : Sun 19 Jul 2020 09:20:36 AM EDT
Begin rpmdb : 1366:995a6cc266bc073b8da434ca73d820e582940442
End time : Sun 19 Jul 2020 09:20:43 AM EDT (7 seconds)
End rpmdb : 1369:f7bb98480bc8a53c09887587d5690b0249ac884f
User : fons drost
Return-Code : Success
Releasever : 8
Command Line : group install -y Security Tools
Packages Altered:
Install openscap-1.3.2-6.el8.x86_64 @AppStream
Install openscap-scanner-1.3.2-6.el8.x86_64 @AppStream
Install scap-security-guide-0.1.48-7.el8.noarch @AppStream
Install @security-tools
```
Let's use the undo options to remove the intallation of ```gnuplot```
```bash
[root@rhcsa ~]# dnf history undo 9
```
```bash
Removed:
gnuplot-5.2.4-1.el8.x86_64 gnuplot-common-5.2.4-1.el8.x86_64 pcre2-utf16-10.32-1.el8.x86_64
qt5-qtbase-5.12.5-4.el8.x86_64 qt5-qtbase-common-5.12.5-4.el8.noarch qt5-qtbase-gui-5.12.5-4.el8.x86_64
qt5-qtsvg-5.12.5-1.el8.x86_64 xcb-util-image-0.4.0-9.el8.x86_64 xcb-util-keysyms-0.4.0-7.el8.x86_64
xcb-util-renderutil-0.3.9-10.el8.x86_64 xcb-util-wm-0.4.1-12.el8.x86_64
Complete!
```