Yum

----

Update yum cache index:

yum makecache fast

yum update --security

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

yum -y install epel-release

yum install yum-utils && yum install yum-priorities

Removing a package without dependencies

# rpm -e vsftpd-2.2.2-11.el6_4.1.i686 --nodeps

# yum info package-name | grep -i repo

yum Update All Packages Except the Linux Kernel

# yum -y update --exclude=kernel

# yum -y --exclude=kernel\* update

# yum update --exclude=kernel* --exclude=php*

# yum -y update -x 'kernel'

# yum -y update -x 'kernel' 'python'

# yum -y -x 'kernel*' update

# yum -x 'kernel*' -x 'php*' update

PREVENT YUM FROM UPDATING THE KERNEL PERMANENTLY

# yum -y update --exclude=python*

# yum -y update --exclude=kernel* --exclude=php*

Edit # vi /etc/yum.conf

[main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 exclude=kernel* redhat-release* php* mysql* httpd*

----------         XXXXXXXXXX--------------------------------------------------

How to Exclude Packages in YUM

To exclude (disable) specific package updates, Open file called /etc/yum.conf with your choice of editor.

# vi /etc/yum.conf

Add the following line at the bottom of the file with exclude keyword as shown below.

[main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release  # This is the default, if you make this bigger yum won't see if the metadata  # is newer on the remote and so you'll "gain" the bandwidth of not having to # download the new metadata and "pay" for it by yum not having correct # information. #  It is esp. important, to have correct metadata, for distributions like # Fedora which don't keep old packages around. If you don't like this checking # interupting your command line usage, it's much better to have something # manually check the metadata once an hour (yum-updatesd will do this). # metadata_expire=90m  # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d  ## Exclude following Packages Updates ##exclude=httpd php mysql

In the above example, the line exclude will disable updates for “httpd” “php” and “mysql” packages. Let’s try installing or updating one of them using YUM command as shown below.

# yum update httpd

Sample Output

Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile  * base: centos.01link.hk  * extras: centos.01link.hk  * updates: mirrors.hns.net.in base                                                   | 3.7 kB     00:00 extras                                                 | 3.0 kB     00:00 updates                                                | 3.5 kB     00:00 updates/primary_db                                     | 2.7 MB     00:16 Setting up Update Process No Packages marked for Update

How to Exclude Packages from EPEL Repo

To exclude packages installs or updates from EPEL repository, then open the file called /etc/yum.repos.d/epel.repo.

# vi /etc/yum.repos.d/epel.repo

Add the exclude line by specifying packages to be exclude from the updates.

[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 ## Exclude following Packages Updates ##exclude=perl php python

Now try to update above specified files from the EPEL repository using YUM command.

# yum --enablerepo=epel update perl php python

Sample Output

Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile  * base: mirrors.hns.net.in  * epel: ftp.kddilabs.jp  * extras: mirrors.hns.net.in  * updates: mirrors.hns.net.in Setting up Update Process No Packages marked for Update

You can also use yum command line option to exclude package without adding to the repository files.

# yum --exclude=httpd update

To exclude list of packages, use the command as follows.

# yum --exclude=mysql\* --exclude=httpd\* update

This way 

---