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

by on December 28, 2011 · 3 comments· LAST UPDATED December 31, 2011

in

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:

 
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
### Blacklist nginx package ###
exclude=nginx*
 
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1
 
[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1
 

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
OR
# yum -x nginx -x lighttpd update
OR
# yum -x 'nginx*' -x 'lighttpd*' update

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 3 comments… read them below or add one }

1 Adam Ziaja December 31, 2011 at 1:35 am

wrong title “Blakclist’

Reply

2 nixCraft December 31, 2011 at 7:52 am

Thanks for the heads up!

Reply

3 Very Useful December 5, 2013 at 9:14 am

Very useful
Thanks

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: