Removing a package without its dependencies in CentOS or RHEL

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, February 24, 2012

Follow me on Twitter as @mattiasgeniar

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.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.