How to manage software with DNF
Among the changes in OM Lx 4.0 is switching from urpmi/rpm5.org to dnf/rpm.org. For most of us users we do not need to be concerned about the rpm part. That is just different versions of rpm and maintained by different people, this will affect developers but users likely won’t notice anything different. The change from urpmi to dnf will be noticed by users as the commands will be different.
The not so secret about package management in Linux is the Package Management GUI's can take longer to learn and get used to than the command line interface (cli). User certainly has more control managing packages from command line than with a GUI. The simplest thing is to open Konsole and type:
$ dnf --help
$ man dnf
The help menu takes about a minute to a minute and a half to read. The man page takes about 3-5 minutes. Both are meant to be available for users to refer to as they use their system and need to find quickly how to do something. There are also wiki pages and docs about dnf. Using the DNF software package manager, Fedora wiki page, and DNF Command Reference. Most users don't really need to read these maybe just scan while you are getting used to dnf and know the links are available when you need to look something up. Same applies to --help menu and man pages, just scan them and know they are there if you need them.
Some basics for using dnf in OpenMandriva Lx
To install a package:
$ sudo dnf install packagename
To remove a package:
$ sudo dnf remove packagename
To search repositories for a package:
$ sudo dnf search packagename
Note: I find that 'dnf search' will work with partial names as well which should make it lots easier to find stuff.
To cleanup any files and packages left in cache and to remove repository metadata:
$ sudo dnf clean all
To update your system:
$ sudo dnf upgrade
Some other common dnf commands
(For more commands see DNF Command Reference):
autoremove - removes packages installed as dependencies that are no longer required by currently installed programs.
check-update - checks for updates, but does not download or install the packages.
downgrade - reverts to the previous version of a package.
info - provides basic information about the package including name, version, release, and description.
reinstall - reinstalls the currently installed package.
repolist - simply list enabled repositories.
Some common dnf options
(For more options see DNF Command Reference):
--allowerasing - Allow erasing of installed packages to resolve dependencies. This option could be used as an alternative to the yum swap command where packages to remove are not explicitly defined. (Use carefully, know what you are doing or you can break your system.)
-b, --best - Try the best available package versions in transactions. Specifically during dnf upgrade, which by default skips over updates that can not be installed for dependency reasons, the switch forces DNF to only consider the latest packages. When running into packages with broken dependencies, DNF will fail giving a reason why the latest version can not be installed.
--disable, --set-disabled - Disable specified repositories (automatically saves). The option has to be used together with the config-manager command (dnf-plugins-core)
--disablerepo=<repoid> - Disable specific repositories by an id or a glob. This option is mutually exclusive with --repo.
--downloadonly - Download the resolved package set without performing any rpm transaction (install/upgrade/erase).
--enable, --set-enabled - Enable specified repositories (automatically saves). The option has to be used together with the config-manager command (dnf-plugins-core).
--enablerepo=<repoid> - Enable additional repositories by an id or a glob.
--exclude=<package_name> - Exclude certain packages from transaction
--nobest - Set best option to False, so that transactions are not limited to best candidates only.
-y, --assumeyes - Automatically answer yes for all questions.
Some helpful explanations
Users need to be very careful using this option. One needs to really, for sure, know what you are doing when you use this option as it can remove packages that will break things in your system. Please pay attention to the packages this will remove and if you are even a tiny bit unsure stop, don't do it, and ask for advice on our forum or Chat with Openmandriva Team
sudo dnf autoremove
is similar to:
sudo urpme --auto-orphans
Be careful and pay attention when using 'dnf autoremove'. It is absolutely possible that this may remove something you don't want to remove. It is a good idea to keep a list of packages that were autoremoved so you know what to re-install if this happens. Note: (You can find autoremoved packages in /var/log/dnf.log.)
There is an option to download packages only and then user can install them at a later time:
sudo dnf --downloadonly upgrade
This is very helpful for users with troublesome or slow internet connection. You download all packages first and then install. Or you can download them and install some other time.