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

How do I force yum command to disable certain packages from being installed using certain repos such as EPEL under RHEL or CentOS Linux 6.x server?

The exclude option can be set in any .repo configuration file. The syntax is as follows:

exclude=package1 package2  
exclude=package1* package?

Package1 Package2 is a list of packages to exclude from updates or installs. This should be a space separated list. Shell globs using wildcards (eg. * and ?) are allowed. In this example, blakclist nginx package from epel repo. Edit /etc/yum.repos.d/epel.repo, enter:
# vi /etc/yum.repos.d/epel.repo
Update the file as follows using the exclude keyword:

name=Extra Packages for Enterprise Linux 6 - $basearch
### Blacklist nginx package ###
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
name=Extra Packages for Enterprise Linux 6 - $basearch - Source

Save and close the file. You can search the repo:
# yum search nginx
Sample outputs:

Loaded plugins: product-id, rhnplugin, subscription-manager
Updating certificate-based repositories.
============================== N/S Matched: nginx ==============================
collectd-nginx.x86_64 : Nginx plugin for collectd
nginx.x86_64 : Robust, small and high performance HTTP and reverse proxy server

  Name and summary matches only, use "search all" for everything.

But, you can not install the same:
# yum install nginx
Sample outputs:

Loaded plugins: product-id, rhnplugin, subscription-manager
Updating certificate-based repositories.
Setting up Install Process
Nothing to do

You can also use the yum command line option as follows without editing the repo file:
# yum --exclude=nginx* update
You can list the packages as follows:
# yum --exclude=nginx\* --exclude=lighttpd\* update
# yum -x nginx -x lighttpd update
# yum -x 'nginx*' -x 'lighttpd*' update

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one

CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • Adam Ziaja Dec 31, 2011 @ 1:35

    wrong title “Blakclist’

  • Very Useful Dec 5, 2013 @ 9:14

    Very useful

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @ webmaster@cyberciti.biz