Finding package versions in CentOS

From V.S.V., Inc.
Jump to: navigation, search

Something that bugs me is when you do a stock install of CentOS on a 64-bit machine it also installs all the 386 versions. Sometimes this is necessary but, normally, you're just wasting resources having them there and never being used. In order find all of them, you can run this command:

rpm -qa --queryformat %-{name}-%{version}-%{release}.%{arch}"\n" |grep -v x86_64 |grep -v noarch|grep -v '(none)'

This returns all the packages that aren't 64-bit, or architecture independent, or without an architecture. The ones with an architecture of type none are the GPG keys and if those are removed, it causes issues later which is why we skip them.

This also formats the output in a yum friendly way so you can do something like:

yum -y remove `rpm -qa --queryformat %-{name}-%{version}-%{release}.%{arch}"\n" |grep -v x86_64 |grep -v noarch|grep -v '(none)'`

This will automatically remove all the packages with the architectures we don't want for a nice clean environment.