Removing a package without its dependencies in CentOS or RHEL

At times, usually when your repositories decide to mess with your package dependencies, you may want to remove a specific package without the dependencies that would be removed alongside it. Please note: you do this at your own risk. You usually just make the dependency problem bigger. Please contact a seasoned Linux Sysadmin to help you with this..

The easiest way is to use rpm and remove it. For instance, if you want to remove the package called “php-sqlite2”, you could do the following.

# rpm -qa | grep "php-sqlite2"
php-sqlite2-5.1.6-200705230937
# rpm -e --nodeps "php-sqlite2-5.1.6-200705230937"

The first “rpm -qa” lists all RPM packages and the grep finds the package you want to remove. Then you copy the entire name and run the “rpm -e –nodeps” command on that package. It will, without prompting for confirmation, remove that package but none of its dependencies.