1080*80 ad

Exclude Packages Automatically with DNF

Managing package installations and updates on your system is crucial for stability and control. While DNF (or yum) is powerful, there are times you need to prevent specific packages from being installed, updated, or even considered during a transaction. Fortunately, there’s a straightforward way to set up automatic exclusions, ensuring these packages are consistently ignored.

The primary method for configuring these permanent exclusions involves editing configuration files. You can apply exclusions globally for all repositories, or specifically per repository.

To apply exclusions system-wide, you will modify the main DNF configuration file, typically located at /etc/dnf/dnf.conf. Open this file with root privileges using your preferred text editor. Within the [main] section, add or modify the exclude directive. List the packages you wish to exclude, separated by spaces. For example, exclude=package1 package2*. Using wildcards like package2* allows you to exclude all packages starting with package2. Save the file after making your changes.

Alternatively, you might want to exclude a package only when interacting with a specific repository. This is useful if a particular repo offers a version of a package you want to avoid, while other repos provide acceptable versions. To do this, navigate to the repository configuration directory, usually /etc/yum.repos.d/. Find the .repo file for the repository you want to modify. Edit this file and locate the specific repository section (indicated by [repository_name]). Within this section, add or modify the exclude directive just as you would in the main configuration file. For instance, add exclude=package-to-avoid under the relevant [repository_name] header. Save the individual .repo file.

Once these changes are saved, DNF will automatically honor these exclusion lists whenever you run commands like dnf update, dnf install, or dnf upgrade. The specified packages will be bypassed, preventing accidental installation or unwanted updates.

Remember that excluding packages can sometimes impact dependency resolution. If a package you need depends on a package you’ve excluded, DNF may report dependency issues or be unable to complete the transaction. Always be mindful of potential dependencies when setting up exclusions.

Implementing automatic package exclusions provides finer control over your system’s software landscape. By making these simple edits to configuration files, you can ensure stability and prevent unwanted software changes effortlessly.

Source: https://infotechys.com/automatically-exclude-packages-using-dnf/

900*80 ad

      1080*80 ad