Knowledgebase:
How to query RPMs by Architecture
Posted by rbTech Staff on 05 January 2012 12:36 PM
Have you ever needed to query your installed RPMs in a Linux system by architecture? In using CentOS, I keep running across 'mixed architecture' systems where yum has helpfully decided to install both 32 and 64 bit versions of many packages. I find this annoying and sloppy, so I prefer to clean it up so that (unless there's a compelling reason to do otherwise) I'm running a 'clean' 64 bit system.

In order to do this, it's helpful to be able to query your RPM database to find out what has gotten installed that is the wrong architecture, and the command to do that is below:

rpm -qa --qf "%{n}-%{v}-%{r}.%{arch}\n"

I often follow this up with the following command:

DO NOT RUN THIS ON A PRODUCTION SYSTEM UNLESS YOU KNOW WHAT YOU'RE DOING!!!

YOU CAN HOSE YOUR INSTALLATION!!!

rpm -e `rpm -qa --qf "%{n}-%{v}-%{r}.%{arch}\n" | grep i[3456]86$`

Good luck and may all your systems be single architecture from here on out!

(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).