RHEL / CentOS Yum Command: Blacklist Packages [ Disable Certain Packages ]

To blacklist packages using the yum package manager on Red Hat Enterprise Linux (RHEL) or CentOS, you can create a file in the /etc/yum.repos.d/ directory that excludes the packages you want to blacklist. The file should have the extension .repo, and the content should specify the packages you want to exclude, using the exclude option.

For example, let’s say you want to blacklist the httpd and php packages, so that yum does not install or update these packages. You can create a file named blacklist.repo in the /etc/yum.repos.d/ directory, with the following content:

[blacklist]
name=Blacklisted packages
baseurl=file:///dev/null
enabled=0
gpgcheck=0
exclude=httpd php

This file specifies a dummy repository with a baseurl of file:///dev/null, which means it won’t actually install anything. The enabled option is set to 0, which disables the repository, and the gpgcheck option is set to 0, which disables GPG signature verification. The exclude option lists the packages that should be blacklisted.

Once you have created the blacklist.repo file, the yum package manager will exclude the specified packages from all its operations, including install, update, and upgrade.

Note that blacklisting packages in this way only affects the yum package manager. If you need to completely disable a package, you may need to use other methods, such as uninstalling the package or disabling its service. Also, it is important to keep in mind that blacklisted packages will not receive security updates or bug fixes, and this may result in security or stability issues.

Leave a Comment