RedHat Package Manager
RHEL
Install Software Using Package Managers
On RHEL, DNF is the default package manager, but you will also see RPM.
Install a package with dnf
To install a package, use the dnf install
command. Here's an example for installing nmap
:
You can verify the installation with the dnf list
command:
Updating a package
To list available updates, use the following command:
The list
subcommand is useful for finding out which packages have available updates on the system. Here's an example of the output:
Many packages on this system have updates available. Specifying a package name with dnf update
will constrain this operation to only look for that package.
dnf update
without any other arguments will apply updates for all packages on your system (including YUM itself)Using dnf history
to Roll Back a Transaction
The history
subcommand provides a summary of recent dnf
transactions.
The output contains transaction IDs in the first column, which are used to reference specific locations in the transaction history when executing rollbacks.
This subcommand is also useful for rolling back transactions if you erroneously install or update a package, as it cleans up all of the dependencies associated with the package.
For example, to roll back the state of your system to before you uninstalled httpd
, use the following command:
12
specifies that the rollback will return the system to the state it was in at transaction ID 12, or before you removed httpd
.Using RPM to Run Detailed Queries
-q
). This section will walk you through three examples of how to use this option.Listing Files Installed by a Package
You can combine the -q
option with the list option (-l
) to display all of the files installed by a specific package. This information is hidden by default to keep the package installation process simple, but it is often useful to know where specific files are located.
Example Output:
Now you can see that the Wireshark
application is located at /usr/bin/wireshark
.
Listing Installation Scripts
Some packages run scripts to finish their installation process. The --scripts
option can be used in combination with rpm -q
to return the contents of these post-installation scripts for a specific package. Wireshark
does not have post-install scripts, so let's try this with the httpd
package.
Example Output:
The output shows a script that creates a preset for the httpd
service behind the scenes when the package is installed.
Showing Changelog
You can use the --changelog
option with rpm -q
to display recent changes in a package.
Example Output:
This command shows the changelog for the specified package, listing what has recently changed in the package.
Validating Package Files Using rpm
If a program is suddenly misbehaving, it could be related to key files not being installed properly. rpm
has a validation option (-V
) that compares the local files with the expected files for the package.
Test Example: Missing File in Wireshark
Remove a file from the Wireshark
package to test out this validation functionality:
Use the -V
option with rpm
to check the file status of Wireshark
:
Example Output:
Now that you can see there is a missing file, reinstall the Wireshark
package to return it to its proper state:
Example Output:
Check that wireshark.png
has been restored:
Validating Changes in Package Files
The command rpm -V
is useful for more than just finding missing files. This command can also inform you if any files have changed since installation.
To test this out, run the validation command on the PAM
package:
Example Output: