Beginner’s guide to using DNF command in Linux — The Linux GURUS
DNF is the package manager that was earlier used in Fedora as a default package manager but with the start of RHEL 8, it is now available a package manager choice along with YUM. In the future, it might be completely removed from RHEL versions. Yum has some problems associated with it, The problems like poor performance, high memory usage, slowness for dependency resolution, etc. All these problems have been resolved with DNF.
Recommended Read: Examples on how to use YUM command in Linux
Also Read: Examples on how to use RPM command in Linux
In this tutorial, we will learn to use DNF command in Linux,
Examples of DNF command in Linux
1- Install package and dependencies
To install a package & its related dependencies, the command is,
# dnf install package_name
If required, we can install local package (rpm package) and all its dependencies with the following command,
# dnf install /path/to/local/rpm
To reinstall a package, command is
# dnf reinstall package_name
2- Install a package for which we only have a file
If we don’t know the package name & want to install the package for which we only have file (maybe config file), then we can use the following command to install it,
# dnf install /path/to/file
3- Upgrade packages
The command to upgrade all system packages is,
To update packages to major patchset and security
# dnf upgrade-minimal
To check if updates are available for packages,
4- Downgrade packages
To downgrade the installed packages to older versions, the command is
# dnf downgrade package_name
5- Uninstall or remove a package
The command to remove or uninstall a package from the system is,
# dnf remove package_name
& if we have some orphaned packages (like some replaces packages that are not required anymore, ex old kernels etc) on our system that we want to remove, we can use the following command,
# dnf autoremove 6- Overview of how many groups are installed and available
To get the list of how many group packages are installed & how many are available, we can use
# dnf group summary group
To get the list of all packages for a group, we can use the command,
To only check a particular group,
# dnf group list group_name
7- Install group
Command to install the group is,
# dnf group install -with-optional group_name
8- Remove a group
To remove an installed group of packages, use
# dnf group remove group_name
9- Upgrade a single group
To upgrade the packages from the group and upgrades the group itself
# dnf group upgrade group
10- Update all packages
To update packages to the latest version, execute the following command,
11- Check information a package
To show info of package_name, run
# dnf info package_name
12- Check which package provides a file
To show which package provides /path/to/file
# dnf provides path/to/file
13- Perform a search term for a package
To search for term in package name and summary
14- Get dnf history
To get list of all dnf transaction’s history
History shows transaction id, to get information for a particular transaction,
# dnf history info transaction_id
To redo particular transaction from history, run,
# dnf history redo transaction_id
To rollback a particular transaction,
# dnf history rollback transaction_id
To undo a transaction,
# dnf history undo transaction_id
15- Show user-installed packages outside dnf
To only show all install only packages, packages installed outside of DNF and packages not installed as a dependency,
# dnf history userinstalled
16- List repositories
To show enabled repolist,
To show disabled repolist,
# dnf repolist -disabled
To list all repos, enabled, disabled & all known repos
# dnf repolist -enabled|-disabled|--all
17- Search repo for selected packages
To search the available DNF repositories for selected packages,
18- Add a remote repository
To add a remote repository to the system,
# dnf config-manager -add-repo=URL add remote repository
19- Download a package
To only download a package & not install it on the system, run
# dnf download package_name
20- List packages
To list installed packages on the system,
List available packages,
List recent packages,
List all packages,
We now end our tutorial on how to use DNF command in Linux. Please do let us know your suggestions, questions or queries using the comment box below.
If you think we have helped you or just want to support us, please consider these:-
Linux TechLab is thankful for your continued support.
Originally published at https://thelinuxgurus.com on January 4, 2020.