During the full update or automatic packages upgrade process, sometimes packages are upgraded which is not required. Sometimes this causes serious issues on the server. For example, You need to exclude kernel, PHP, MySQL and Apache packages from getting updated while updating system via yum. This tutorial will help you find the answer of how to exclude packages from yum update? How to use exclude option with yum? How to prevent packages from auto update via yum? How to exclude only 32-bit or 64-bit packages?
#1. Exclude Packages with Command
You can simply use –exclude command line parameter with yum to exclude specific packages from getting update. You can specify multiple packages as per your requirement. For example, below command will update all packages except kernel and php.
# yum update --exclude=kernel* --exclude=php*
#2. Exclude Packages from Auto Update
In addition, You can also add entries in /etc/yum.conf to disable packages updates permanently. Using this option, you don’t need to specify each time you run yum update command from prompt. This will also prevent packages from any accidental update.
Edit /etc/yum.conf in editor and add exclude line as showing in below example configuration file. The below will prevent updating packages name begin with the kernel, redhat-release, php, mysql, and httpd.
[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*
#3. Exclude 32-bit or 64-bit Packages
Also, you can ignore the specific package architecture. Like you need to exclude 32-bit or 64-bit packages from auto update. Specify them in /etc/yum.conf as below.
This tutorial helps you to exclude specific packages from yum update. You can easily exclude any packages or group of packages from yum update and prevents accidental rpm updates.