Hi everyone, today we'll learn about DNF commands and how we can use it to manage RPM based Linux Distributions. Dandified YUM also known as DNF is the new version of YUM, a package manager for RPM based Linux Distribution. DNF is a fork of YUM and is the default package manager in Fedora 22 and later versions of Fedora. DNF 1.0 is the latest and stable version of DNF which uses dnf.repo.Repo.id as a default value for dnf.repo.Repo.name, has support of repositories which use basic HTTP authentication, enhanced repoquery and builddep plugins and many major bugfixes.
DNF uses RPM, libsolv and hawkey libraries for package management where as librepo handles metadata and download of packages from the repository. DNF utilizes libcomps for processing and effectively handling the comps data. It has been offered as an experimental package manager available since Fedora 18, but with the Fedora 22 release its the default package manager for the users choice.
Here are some changes made with DNF CLI in compared with Yum.
- The flag --skip-broken is not recognized by DNF.
- Update and Upgrade Commands are the same in DNF.
- The commands resolvedep,mirrorlist_expire, overwrite_groups, upgrade_requirements_on_install, dnf history rollback, group_package_types, --enableplugin switch and deplist has been dropped.
- It extends excludes during installs and upgrades to all operations, among others erasing and listing.
- Yum’s conf directive includepkgs is just include making it more logical.
- DNF has droped protected_packages configuration option but is supported via plugin.
- dnf remove kernel command deletes all packages named kernel.
- dnf provides /bin/<file> does not find any packages on Fedora.
- skip_if_unavailable is enabled by default.
- metalink is no longer recognized in the mirrorlist repo option.
- yum shell and yum swap has been replaced by --allowerasing switch for replacement of packages.
- Dependency processing details are not shown in the CLI.
- When multiple downloads run simultaneously the total downloading speed is throttled.
- DNF terminates early with an error if a command is executed requesting an installing operation on a local .srpm file.
- DNF does not replace a request for installing a package if the package is obsoleted by another package.
As DNF is the replacement of YUM, one cannot run YUM command by default in the latest version of Fedora ie 22 and later. So, its good to learn how to use DNF commands so that you can take a lot advantages of DNF than YUM to manage packages.
Installing DNF Package Manager
If you are running the previous versions of Fedora Distributions version 18 and above then we can simply install DNF from the Repository. And if you are running other RPM based Distributions of Linux, on can simply build the DNF rpm from the source code itself.
1. From the Repository
If you are running previous versions of Fedora Distribution of Linux, DNF and all its dependencies are available for Fedora 18 and later including the rawhide Fedora in the Repository with DNF Nightly Builds.
To do so, we'll need to add the repository configuration into /etc/yum.repos.d/dnf-nightly.repo by running the following commands.
$ sudo cat << 'EOF' > /etc/yum.repos.d/dnf-nightly.repo
[dnf-nightly]
name=DNF nightly $releasever - $basearch
baseurl=http://jenkins.cloud.fedoraproject.org/job/DNF/lastSuccessfulBuild/artifact/fedora-$releasever-$basearch-build
enabled=1
EOF
After that, we'll run yum manager to install dnf package manager.
$sudo yum install dnf
2. Building and Installing from Source Code
If you are running RPM based Linux Distributions other than Fedora then you want to compile from the source code and installing DNF from it. To do so, we'll need to clone the DNF source code from the Github and then get our hands dirty to compile it.
$ git clone https://github.com/rpm-software-management/dnf.git
$ cmake .
$ ./package/build-test-rpm
$ sudo rpm -i ~/rpmbuild/RPMS/noarch/dnf-<version>-<release>.noarch.rpm
We can give a test by running the following command.
$ mkdir build;
$ pushd build;
$ cmake .. && make ARGS="-V" test;
$ popd;
Now, as our package manager ie DNF is ready to go, we'll check some commands available of DNF verson 1.0 that will help us to manage packages in our Fedora 22 or any RPM based Linux Machine.
Commands Available for DNF Package Manager can be displayed by running dnf help in the terminal or shell.
$ dnf help
usage: dnf [options] COMMAND
List of Main Commands
autoremove
check-update Check for available package upgrades
clean Remove cached data
distro-sync Synchronize installed packages to the latest available versions
downgrade downgrade a package
group Display, or use, the groups information
help Display a helpful usage message
history Display, or use, the transaction history
info Display details about a package or group of packages
install Install a package or packages on your system
list List a package or groups of packages
makecache Generate the metadata cache
provides Find what package provides the given value
reinstall reinstall a package
remove Remove a package or packages from your system
repolist Display the configured software repositories
repository-packages Run commands on top of all packages in given repository
search Search package details for the given string
updateinfo Display advisories about packages
upgrade Upgrade a package or packages on your system
upgrade-to Upgrade a package on your system to the specified version
Here are some usages of Main Commands that we can run with DNF Package Manager with their possible examples. Please make sure that you run the commands in sudo or root permission.
1. Autoremove
Autoremove command removes all the packages those are unnecessary to the system which where installed as dependencies while installing previous packages. To run autoremove, we can execute dnf [option] autoremove in the command interface.
$ sudo dnf [option] autoremove
For Eg.
$ sudo dnf autoremove
Using metadata from Sat May 16 18:28:49 2015 (2:08:12 hours old)
Dependencies resolved.
Nothing to do.
Complete!
2. Check Update Command
Check Update command non-interactively checks if updates of the specified packages are available. DNF exit code will be 100 when there are updates available and a list of the updates will be printed, 0 if not and 1 if an error occurs. Please note that having a specific newer version available for an installed package (and reported by check-update) does not imply that subsequent dnf upgrade will install it. We can run check update using the command below.
$ sudo dnf [options] check-update [<package-specs>...]
For Eg.
$ sudo dnf check-update python
Using metadata from Sat May 16 18:28:49 2015 (2:22:59 hours old)python.x86_64 2.7.9-6.fc22 fedora
python.x86_64 2.7.9-6.fc22 updates-testing
3. Clean Command
Clean Command of DNF Package Manager cleans all the temporary files of the currently enabled repositories. Clean command requires an option as packages, metadata, dbcache, plugins, expire-cache, rpmdb, all .
$ sudo dnf clean dbcache
The above command removes cache files generated from the repository metadata which forces DNF to regenerate the cache files the next time it is run.
$ sudo dnf clean metadata
The above command removes repository metadata which are the files that DNF uses to determine the remote availability of packages. It will make DNF to download the metadata when it is run next time.
$ sudo dnf clean packages
The above command removes any cached packages in the system.
$ sudo dnf clean plugins
The above command removes cached data from the plugins.
$ sudo dnf clean expire-cache
The above command removes local cookie files saying when the metadata and mirrorlists were downloaded for each repo.
$ sudo dnf clean rpmdb
The above command cleans up database created by rpm and will regenerate when running next time.
4. Distro-sync command
Distro-sync upgrades, downgrades or keeps selected installed packages to match the latest version of the packages available in the enabled repositories. If no package is specified, all installed packages are considered for distro-sync.
$ sudo dnf distro-sync [<package-spec>...]
For Eg.
$ sudo dnf distro-sync python
Using metadata from Sat May 16 21:24:45 2015 (0:24:32 hours old)
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Upgrading:
python x86_64 2.7.9-6.fc22 fedora 92 k
python-libs x86_64 2.7.9-6.fc22 fedora 5.8 MTransaction Summary
========================================================================
Upgrade 2 PackagesTotal download size: 5.9 M
Is this ok [y/N]: y
5. Downgrade
Downgrade command downgrades the installed package to the highest of all the available lower versions of the package. We can even define a version to which we want to downgrade.
$ sudo dnf [options] downgrade <package-specs>
$ sudo dnf downgrade firefox
Using metadata from Sat May 16 21:24:45 2015 (16:06:06 hours old)
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Downgrading:
firefox x86_64 37.0.2-2.fc22 updates-testing 69 MTransaction Summary
========================================================================
Downgrade 1 PackageTotal download size: 69 M
Is this ok [y/N]:
6. Group
Groups are the collection of packages in the repository which are tracked by DNF that helps the user to install all the necessary packages and manipulate the packages just at a single simple command.
Note: Here, <group-spec> is [PACKAGE|all|available|installed|updates|extras|autoremove|obsoletes|recent] .
dnf [options] group summary <group-spec>
The above command displays overview of how many groups are installed and are available. Here, summary is the default groups subcommand.
dnf [options] group info <group-spec>
The above command displays package lists of a specified group which are installed or available from a repo when -v is used.
dnf [options] group install with-optional <group-spec>
Above command marks the specified group installed and install packages it contains. It also includes additional optional packages of the group if with-optional is specified in the command line.
dnf [options] group list <group-spec>
It lists all matching groups, either among installed or available groups. The records are ordered by display_order tag defined in comps.xml file.
dnf [options] group remove <group-spec>
Above command marks the group as removed then it removes those packages in the group from the system which are neither comprising another installed group and were installed unnecessarily as dependencies.
dnf [options] group upgrade <group-spec>
This command upgrades both the group and packages of the group.
Groups can be also be marked installed or removed without physically manipualting any packages:
dnf [options] group mark install <group-spec>
It marks the specified group as installed but no packages will be installed by this command but the group is then considered as installed.
dnf [options] group mark remove <group-spec>
It marks the specified group as removed but no packages will be removed by this command but the group is then considered as removed.
7. Help Command
Help command displays all the available commands, options and information on how we can run that and what the command does with the necessary syntax.
$ sudo dnf help <command>
For Eg.
$ sudo dnf help group
group [list|info|summary|install|upgrade|remove|mark] [GROUP]Display, or use, the groups information
aliases: groups, grouplist, groupinfo, groupinstall, groupupdate, groupremove, grouperase
8. History Command
The history command allows us to view the past transactions made by DNF.
$ sudo dnf history list
The above command lists history of all the transactions in a table.
$ sudo dnf history info [<spec>]
The above command displays the description of the specified transaction. Here, [<spec>] may be any transaction id or any transaction of a package. If no specification is mentioned, the latest transaction information will be displayed.
$ sudo dnf history redo <transaction-spec>
This command repeats a specified transaction. Here, <transaction-spec> is the transaction id that we want to redo.
$ sudo dnf history rollback <transaction-spec>
This command rollbacks all the transaction performed after specified transaction. Here, <transaction-spec> is the transaction id that we want to rollback.
$ sudo dnf history undo <transaction-spec>
It performances an opposite operation done by the specified transaction. Here, <transaction-spec> is the transaction id that we want to undo.
$ sudo dnf history userinstalled
It lists all the packages that were installed by a user. The output can be used as the %packages section in a kickstart file.
9. Info Command
Info is command with DNF is used to display the summary and description about the available packages. This command by default does not force a sync of expired metadata.
dnf [options] info [<package-spec>...]
For Eg.
$ sudo dnf info firefox
Using metadata from Sat May 16 21:24:45 2015 (1 day, 0:47:42 hours old)
Installed Packages
Name : firefox
Arch : x86_64
Epoch : 0
Version : 37.0.2
Release : 3.fc22
Size : 118 M
Repo : @System
From repo : fedora
Summary : Mozilla Firefox Web browser
URL : http://www.mozilla.org/projects/firefox/
License : MPLv1.1 or GPLv2+ or LGPLv2+
Description : Mozilla Firefox is an open-source web browser, designed for standards
: compliance, performance and portability.
10. Install Command
This command will install the specified package and its dependencies from the Repository or the local path for the RPM package or the specified group where the required package is tagged.
$ sudo dnf [options] install <spec>
For Eg.
Installing Package Specific
$ sudo dnf install lynx
Using metadata from Sat May 16 21:24:45 2015 (1 day, 9:24:06 hours old)
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Installing:
lynx x86_64 2.8.9-0.6.dev4.fc22 fedora 1.5 MTransaction Summary
========================================================================
Install 1 PackageTotal download size: 1.5 M
Installed size: 5.5 M
Is this ok [y/N]: Y
Group Installation
$ sufo dnf install @"Minimal Install"
Using metadata from Sat May 16 21:24:45 2015 (1 day, 9:40:26 hours old)
Dependencies resolved.
========================================================================
Group Packages
========================================================================
Marking installed:
Core openssh-clients less iputils
sudo parted kbd
iproute dhcp-client selinux-policy-targeted
..........................................................................
========================================================================
Package Arch Version Repository Size
========================================================================
Installing:
NetworkManager x86_64 1:1.0.2-1.fc22 fedora 1.9 M
NetworkManager-libnm x86_64 1:1.0.2-1.fc22 fedora 459 k
audit x86_64 2.4.2-1.fc22 fedora 240 k
authconfig x86_64 6.2.10-6.fc22 fedora 412 k
avahi-autoipd x86_64 0.6.31-30.fc22 fedora 29 k
bind99-libs x86_64 9.9.7-3.fc22 fedora 781 k
bind99-license noarch 9.9.7-3.fc22 fedora 12 k
cronie x86_64 1.4.12-5.fc22 fedora 102 k
cronie-anacron x86_64 1.4.12-5.fc22 fedora 38 k
crontabs noarch 1.11-9.20130830git.fc22 fedora 24 k
dbus-python x86_64 1.2.0-7.fc22 fedora 131 k
dhcp-client x86_64 12:4.3.2-2.fc22 fedora 295 k
dhcp-common noarch 12:4.3.2-2.fc22 fedora 189 k
dhcp-libs x86_64 12:4.3.2-2.fc22 fedora 135 k..........................................................................
Upgrading:
audit-libs x86_64 2.4.2-1.fc22 fedora 93 k
systemd x86_64 219-14.fc22 updates-testing 5.8 M
..........................................................................Transaction Summary
========================================================================
Install 78 Packages
Upgrade 6 PackagesTotal download size: 31 M
Is this ok [y/N]: Y
11. List Command
List Command displays the lists of packages depending on the package(s) relation to the system whether it is available in the repository or installed in the system. We can also specify package name so that the list command displays about the specified packages only.
dnf [options] list all [<package-name>]
Lists packages or specified package which are present in the RPMDB, in a repo or in both.
dnf [options] list installed [<package-name>]
Lists the installed packages or installed specified packages.
dnf [options] list available [<package-name>]
Lists the available packages or available specified packages.
dnf [options] list extras [<package-name>]
Lists the extra packages that are installed but are not available in any known repositories.
dnf [options] list obsoletes [<package-name>]
Lists the obsoletes packages which are installed but are not available in any known repositories.
dnf [options] list recent [<package-name>]
Lists the recently added packages in the repositories.
dnf [options] list upgrades [<package-name>]
Lists the upgrades available for all the packages or specified packages.
dnf [options] list autoremove
Lists all the packages that will be removed by dnf autoremove command.
12. Makecache Command
This command creates metadata cache for downloads and makes sure that it doesn't download the metadata if its available in the cache whenever its possible until the local metadata is expired or timestamp is changed.
dnf [options] makecache
For Eg.
$ sudo dnf makecache
Metadata cache created.
To instruct DNF to be more resource-aware and toterminate immediately if it’s too soon after the last successful makecache run we add timer to it.
dnf [options] makecache timer
For Eg.
$ sudo dnf makecache timer
Metadata cache refreshed recently.
13. Provides Command
Provide command finds the packages providing the given <provide-spec>. It is useful when one knows a filename and wants to find what package provides that file.
dnf [options] provides <provide-spec>
For Eg.
$ sudo dnf provides /usr/bin/cat
Using metadata from Sat May 16 21:24:45 2015 (1 day, 10:27:41 hours old)
coreutils-8.23-8.fc22.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo : @Systemcoreutils-8.23-9.fc22.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo : fedoracoreutils-8.23-10.fc22.x86_64 : A set of basic GNU tools commonly used in shell scripts
Repo : updates-testing
14. Reinstall Command
It reinstalls the specified packages and fails to install if its not installed or if its unavailable in the system.
dnf [options] reinstall <package-specs>
For Eg.
$ sudo dnf reinstall firefox
Using metadata from Sat May 16 21:24:45 2015 (1 day, 10:45:20 hours old)
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Reinstalling:
firefox x86_64 37.0.2-3.fc22 fedora 69 MTransaction Summary
========================================================================Total download size: 69 M
Is this ok [y/N]:
15. Remove Command
Remove command uninstalls the specified package which is installed in the system along with the packages depending on it. Here, <package-specs> can be either specified package name or group name. If clean_requirements_on_remove is enabled, it also removes any dependencies that are no longer needed.
dnf [options] remove <package-specs>
For Eg.
$sudo dnf remove lynx
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Removing:
lynx x86_64 2.8.9-0.6.dev4.fc22 @System 5.5 MTransaction Summary
========================================================================
Remove 1 PackageInstalled size: 5.5 M
Is this ok [y/N]:
16. Repolist Command
Repolist command lists all enabled repositories by default. We can list all the enabled, disabled and all repositories added in the system. For more information about those repositories, we can add -v flag into the command.
dnf [options] repolist [enabled|disabled|all]
For Eg.
Default Repolist
$ sudo dnf repolist
Using metadata from Sat May 16 21:24:45 2015 (1 day, 11:05:53 hours old)
repo id repo name status
*fedora Fedora 22 - x86_64 44764
*updates Fedora 22 - x86_64 - Updates 0
*updates-testing Fedora 22 - x86_64 - Test Updates 15973
Repolist with more informations
$ sudo dnf repolist -v
cachedir: /var/cache/dnf/x86_64/22
Loaded plugins: generate_completion_cache, Query, protected_packages, kickstart, debuginfo-install, builddep, noroot, copr, playground, reposync, needs-restarting, download, config-manager
DNF version: 0.6.5
repo: using cache for: fedora
not found deltainfo for: Fedora 22 - x86_64
not found updateinfo for: Fedora 22 - x86_64
repo: using cache for: updates-testing
repo: using cache for: updates
not found updateinfo for: Fedora 22 - x86_64 - Updates
Using metadata from Sat May 16 21:24:45 2015 (1 day, 11:05:20 hours old)
Repo-id : fedora
Repo-name : Fedora 22 - x86_64
Repo-revision: 1431684017
Repo-tags : binary-x86_64
Repo-distro-tags: [cpe:/o:fedoraproject:fedora:22]: , T, T, e, n, o, t, w, w, y
Repo-updated : Fri May 15 10:10:18 2015
Repo-pkgs : 44764
Repo-size : 45 G
Repo-metalink: https://mirrors.fedoraproject.org/metalink?repo=fedora-22&arch=x86_64
Updated : Sat May 16 21:24:45 2015
Repo-baseurl : http://mirror.ancl.hawaii.edu/linux/fedora/development/22/x86_64/os/ (65 more)
Repo-expire : 172800 second(s) (last: Sat May 16 21:24:45 2015)
Repo-filename: /etc/yum.repos.d/fedora.repoRepo-id : updates
Repo-name : Fedora 22 - x86_64 - Updates
Repo-revision: 1405014767
Repo-tags : binary-x86_64
Repo-updated : Thu Jul 10 17:52:48 2014
Repo-pkgs : 0
Repo-size : 0
Repo-metalink: https://mirrors.fedoraproject.org/metalink?repo=updates-released-f22&arch=x86_64
Updated : Mon May 18 06:48:22 2015
Repo-baseurl : rsync://repo.atlantic.net/fedora/linux/updates/22/x86_64/ (91 more)
Repo-expire : 21600 second(s) (last: Mon May 18 06:48:22 2015)
Repo-filename: /etc/yum.repos.d/fedora-updates.repo
17. Repository-Packages Command
The repository-packages command allows us to run commands on top of all packages in the repository named <repoid>.
Note: We can get the repoid from dnf repolist command.
dnf [options] repository-packages <repoid> check-update [<package-name-spec>]
It checks if updates of the specified packages in the repository are available or not.
dnf [options] repository-packages <repoid> info [all] [<package-name-spec>]
It lists all the related packages.
dnf [options] repository-packages <repoid> info installed [<package-name-spec>]
It lists all packages installed from the repository.
dnf [options] repository-packages <repoid> info available [<package-name-spec>]
It lists the specified packages that are available in the repository.
dnf [options] repository-packages <repoid> info extras [<package-name-specs>]
It lists packages installed from the repository that are not available in any repository.
dnf [options] repository-packages <repoid> info obsoletes [<package-name-spec>]
It lists obsolete packages that are installed on the system and is available in the repository.
dnf [options] repository-packages <repoid> info recent [<package-name-spec>]
It lists packages which are recently added into the repository.
dnf [options] repository-packages <repoid> info upgrades [<package-name-spec>]
It lists packages in the repository that upgrade packages installed on the system.
dnf [options] repository-packages <repoid> install [<package-spec>]
It installs all the packages or specified packages that are available in the repository.
dnf [options] repository-packages <repoid> list all [<package-name-spec>]
It lists all the related packages.
dnf [options] repository-packages <repoid> list installed [<package-name-spec>]
It list installed packages from the repository.
dnf [options] repository-packages <repoid> list available [<package-name-spec>]
It lists packages available in the repository.
dnf [options] repository-packages <repoid> list extras [<package-name-specs>]
It lists packages installed from the repository that are not available in any repository.
dnf [options] repository-packages <repoid> list obsoletes [<package-name-specs>]
It lists obsolete packages that are available in the repository and are installed on the system.
dnf [options] repository-packages <repoid> list recent [<package-name-spec>]
It lists recently added packages in the repository.
dnf [options] repository-packages <repoid> list upgrades [<package-name-spec>]
It list packages in the repository that upgrade packages installed on the system.
dnf [options] repository-packages <repoid> move-to [<package-name-spec>]
It reinstalls all those packages that are available in the repository.
dnf [options] repository-packages <repoid> reinstall [<package-name-spec>]
It runs reinstall-old subcommand but if it fails, it runs move-to subcommand.
dnf [options] repository-packages <repoid> reinstall-old [<package-name-spec>]
It reinstalls all those packages that were installed from the repository and are available in the repository.
dnf [options] repository-packages <repoid> remove [<package-name-spec>]
It removes all packages installed from the repository along with any packages depending on the packages being removed. If clean_requirements_on_remove is enabled, it also removes any dependencies that are no longer needed by the system.
dnf [options] repository-packages <repoid> remove-or-distro-sync [<package-name-spec>]
It selects all packages installed from the repository and upgrades, downgrades or keep those of them that are available in another repositories to match the latest version available there and remove the others along with any packages depending on the packages being removed.
dnf [options] repository-packages <repoid> remove-or-reinstall [<package-name-spec>]
It selects all packages or specified packages installed from the repository and reinstalls those of them that are available in another repositories and remove the others along with any packages depending on the packages being removed.
dnf [options] repository-packages <repoid> upgrade [<package-name-spec>]
It updates all packages to the highest resolvable version available in the repository.
dnf [options] repository-packages <repoid> upgrade-to [<package-version-specs>]
It updates packages to the specified versions that are available in the repository.
18. Search Command
Search Command is a very much useful command which helps us able to find a package name from the metadata. It searches the metadata for the keyword which is case-insensitive and then tries to find the keyword in the description, package names and URLs and displays in sorted form with the most relevant result at the top.
dnf [options] search all <keywords>
For Eg.
$ sudo dnf search all xchat
Using metadata from Sat May 16 21:24:45 2015 (1 day, 23:32:12 hours old)
========================================== Matched: xchat ==========================================
xchat.x86_64 : A popular and easy to use graphical IRC (chat) client
hexchat-devel.i686 : Development files for hexchat
hexchat-devel.x86_64 : Development files for hexchat
xchat-gnome.x86_64 : GNOME front-end to xchat
hexchat.i686 : A popular and easy to use graphical IRC (chat) client
hexchat.x86_64 : A popular and easy to use graphical IRC (chat) client
xchat-ruby.x86_64 : An X-Chat plugin providing scripting functionality with Ruby
xchat-tcl.x86_64 : Tcl script plugin for X-Chat
19. Updateinfo Command
The updateinfo command displays information about the update advisories. Here, <output> is either list or summary or info according to the needed information, we can even add -v to info for detailed information. <availability> specifies installed if the advisories is about equal and older versions of installed packages or specifies available if the advisories is about the newer version of installed packages or specifies update if the advisories is about a newer versions of those installed packages for which a newer version is available or specifies all if advisories is about any versions of installed packages. The <spec> consists of ID, type (bugfix, enhancement, security) or a package name of an advisory.
dnf [options] updateinfo [<output>] [<availability>] [<spec>]
For Eg.
Summary
$ sudo dnf updateinfo summary all firefox
Using metadata from Sat May 16 21:24:45 2015 (1 day, 23:36:30 hours old)
Updates Information Summary: all
1 Security notice(s)
List
$ sudo dnf updateinfo list all firefox
Using metadata from Sat May 16 21:24:45 2015 (1 day, 23:48:59 hours old)
i FEDORA-2015-6629 security firefox-37.0.2-2.fc22.x86_64
Information
$ sudo dnf updateinfo info all firefox
Using metadata from Sat May 16 21:24:45 2015 (1 day, 23:49:17 hours old)
========================================================================
xulrunner-37.0.2-1.fc22,firefox-37.0.2-2.fc22
========================================================================
Update ID : FEDORA-2015-6629
Type : security
Updated : 2015-04-22 16:55:48
Bugs : 1210474 - Update fedora-bookmarks for Fedora 22
Description : Update to new upstream - 37.0.2
: Bookmark rebuild - Bug 1210474
Installed : true
20. Upgrade Command
Upgrade command updates all the packages to the highest version that is both resolvable and installed in the system. If a specific package is specified, the upgrade command updates that package to the highest available version and updates dependencies if necessary.
Upgrading all the Packages
dnf upgrade
For Eg.
$ sudo dnf upgrade
Using metadata from Sat May 16 21:24:45 2015 (1 day, 23:57:32 hours old)
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Upgrading:
bash-completion noarch 1:2.1-7.20150513git1950590.fc22 updates-testing 255 k
ca-certificates noarch 2015.2.4-1.0.fc22 fedora 445 k
chkconfig x86_64 1.4-1.fc22 fedora 177 k
cryptsetup-libs x86_64 1.6.7-1.fc22 fedora 187 k
curl x86_64 7.40.0-3.fc22 fedora 279 k
dnf noarch 1.0.0-1.fc22 fedora 232 k
dnf-conf noarch 1.0.0-1.fc22 fedora 75 k
dnf-yum noarch 1.0.0-1.fc22 fedora 68 k
e2fsprogs x86_64 1.42.12-4.fc22 fedora 799 k
e2fsprogs-libs x86_64 1.42.12-4.fc22 fedora 170 k
fedora-logos x86_64 22.0.0-1.fc22 fedora 8.3 M
fedora-release noarch 22-0.17 fedora 23 k
file x86_64 5.22-3.fc22 fedora 65 k
file-libs x86_64 5.22-3.fc22 fedora 423 kTransaction Summary
========================================================================
Upgrade 56 PackagesTotal download size: 38 M
Is this ok [y/N]: y
Upgrading Specific Packages
dnf upgrade firefox
For Eg.
$ sudo dnf upgrade grub2
Using metadata from Mon May 18 21:00:38 2015 (0:28:00 hours old)
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Upgrading:
grub2 x86_64 1:2.02-0.16.fc22 fedora 3.8 M
grub2-tools x86_64 1:2.02-0.16.fc22 fedora 7.4 MTransaction Summary
========================================================================
Upgrade 2 PackagesTotal download size: 11 M
Is this ok [y/N]: Y
21. Upgrade-to Command
The upgrade-to command updates the packages to the specified version.
dnf [options] upgrade-to <package-nevr-specs>
For Eg.
$ sudo dnf upgrade-to grub2-1:2.02-0.16.fc22
Using metadata from Mon May 18 21:00:38 2015 (0:33:19 hours old)
Dependencies resolved.
========================================================================
Package Arch Version Repository Size
========================================================================
Upgrading:
grub2 x86_64 1:2.02-0.16.fc22 fedora 3.8 M
grub2-tools x86_64 1:2.02-0.16.fc22 fedora 7.4 MTransaction Summary
========================================================================
Upgrade 2 PackagesTotal download size: 11 M
Is this ok [y/N]: YDownloading Packages:
(1/2): grub2-2.02-0.16.fc22.x86_64.rpm 9.5 MB/s | 3.8 MB 00:00
(2/2): grub2-tools-2.02-0.16.fc22.x86_64.rpm 14 MB/s | 7.4 MB 00:00
----------------------------------------------------------------------------------------------------
Total 6.4 MB/s | 11 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Upgrading : grub2-tools-1:2.02-0.16.fc22.x86_64 1/4
warning: Unable to get systemd shutdown inhibition lock
Upgrading : grub2-1:2.02-0.16.fc22.x86_64 2/4
Cleanup : grub2-1:2.02-0.15.fc22.x86_64 3/4
Cleanup : grub2-tools-1:2.02-0.15.fc22.x86_64 4/4
Verifying : grub2-1:2.02-0.16.fc22.x86_64 1/4
Verifying : grub2-tools-1:2.02-0.16.fc22.x86_64 2/4
Verifying : grub2-1:2.02-0.15.fc22.x86_64 3/4
Verifying : grub2-tools-1:2.02-0.15.fc22.x86_64 4/4Upgraded:
grub2.x86_64 1:2.02-0.16.fc22 grub2-tools.x86_64 1:2.02-0.16.fc22Complete!
Options
There are many options we can set in the DNF commands. Here, in this article, we see [options] where we can add flags which is for better advanced performance. We can see all the options from http://dnf.readthedocs.org/en/latest/command_ref.html#options .
Enabling Automatic Package Updates
DNF has the option to automatic package update as there was in YUM named yum-updatesd. The Automatic Package Updates is handled by dnf-automatic in DNF. To get started, first of all we need to install dnf-automatic in our Linux System.
$ sudo dnf -y install dnf-automatic
So, there is one configuration file named /etc/dnf/automatic.conf that has pretty sensible default configurations. We can configure it according to our need. Here, I have enabled apply_updates = yes so that the updates will be installed when its available.
Now, we'll want to enable the timer of dnf-automatic and wanna start it so that it will run.
$ sudo systemctl enable dnf-automatic.timer
$ sudo systemctl start dnf-automatic.timer
We can check the job time and schedules of dnf-automatic by running the following command.
$ sudo systemctl list-timers *dnf*
Keeping Old Kernels with DNF
While upgrading kernels in DNF, the new kernel is installed as well as there is old kernel available in the system to choose incase there is corrupt or bug in the new installed kernel. And the old kernels are cleaned up when it reaches up to 3 old kernels by default. We can change the configuration on how many old kernels to keep by editing /etc/dnf/dnf.conf file using our favorite text editor.
$ sudo vi /etc/dnf/dnf.conf
Then, we'll need to find line with installonly_limit=3 . Here, we can change the value by replacing 3 with the number of old kernel we want to keep. If we want to keep all the kernels, we need to replace 3 with 0.
Conclusion
DNF aka Dandified YUM is really a stable and awesome fork of YUM. As YUM has been replaced by default since Fedora 22 by DNF, it is better to learn the commands on how things are done using DNF. Though YUM redirects its every command to DNF, the main commands and sub commands may differ accordingly. So, its time to familiarize everyone with DNF. DNF is pretty simple and much easy to understand and work with. It is always easy to manage packages with DNF. The commands are way too very easy to execute and works with ease. DNF is a good fork of YUM which will replace YUM from many RPM based distributions as its version 1.0 which is known as stable version has been released with preinstalled in Fedora 22. DNF package manager has many bug fixes and some good features has been added to it. So, if you have any questions, comments, feedback please do write on the comment box below and let us know what stuffs needs to be added or improved. Thank You! Enjoy DNF Package Manager :-)
The post 21 DNF Commands to Manage RPM Based Linux Distributions appeared first on LinOxide.