To reinstall a package using the dnf
command on CentOS or RHEL (Red Hat Enterprise Linux), use the reinstall
option followed by the name of the package:
dnf reinstall package_name
For example, to reinstall the nano
text editor, you would run:
dnf reinstall nano
Note that this will only reinstall the package if it is already installed on your system. If the package is not installed, dnf
will display an error message.
If you want to force the installation of a package even if it is already installed, you can use the --force
option:
dnf reinstall --force package_name
This can be useful if you want to overwrite any local changes that you may have made to the package's files.
If you want to reinstall multiple packages at once, you can specify a list of package names separated by spaces:
dnf reinstall package_name1 package_name2 package_name3
You can also use the -y
option to answer "yes" to all prompts, allowing the reinstallation to proceed without requiring confirmation:
dnf reinstall -y package_name