Yum (CentOS 6.4) - Remove all Installed Packages [closed]

I need to clean my system and redo it all. Is there any easy way to get rid of every single package I've installed (to a point where it's CentOS minimal)? I can't remember all of the packages and

yum list installed

pulls up a list of 1,000s of packages.

Thanks!

Edit: I cannot reinstall CentOS.


Solution 1:

You should simply reinstall your system. Removing packages to get to minimal takes far more time than the reinstallation of a minimal setup. If you can't reinstall, why not just leave it as-is. Are you trying to save space?

Either way, here's the CentOS Minimal RPM package list. Run a diff against your existing list and determine what to remove:

MAKEDEV.x86_64
acl.x86_64
aic94xx-firmware.noarch
atmel-firmware.noarch
attr.x86_64
audit.x86_64
audit-libs.x86_64
authconfig.x86_64
b43-openfwwf.noarch
basesystem.noarch
bash.x86_64
bfa-firmware.noarch
binutils.x86_64
bzip2.x86_64
bzip2-libs.x86_64
ca-certificates.noarch
centos-release.x86_64
checkpolicy.x86_64
chkconfig.x86_64
coreutils.x86_64
coreutils-libs.x86_64
cpio.x86_64
cracklib.x86_64
cracklib-dicts.x86_64
cronie.x86_64
cronie-anacron.x86_64
crontabs.noarch
curl.x86_64
cyrus-sasl.x86_64
cyrus-sasl-lib.x86_64
dash.x86_64
db4.x86_64
db4-utils.x86_64
dbus-glib.x86_64
dbus-libs.x86_64
device-mapper.x86_64
device-mapper-event.x86_64
device-mapper-event-libs.x86_64
device-mapper-libs.x86_64
dhclient.x86_64
diffutils.x86_64
dracut.noarch
dracut-kernel.noarch
e2fsprogs.x86_64
e2fsprogs-libs.x86_64
efibootmgr.x86_64
elfutils-libelf.x86_64
ethtool.x86_64
expat.x86_64
file-libs.x86_64
filesystem.x86_64
findutils.x86_64
fipscheck.x86_64
fipscheck-lib.x86_64
gamin.x86_64
gawk.x86_64
gdbm.x86_64
glib2.x86_64
glibc.x86_64
glibc-common.x86_64
gmp.x86_64
gnupg2.x86_64
gpgme.x86_64
grep.x86_64
grub.x86_64
grubby.x86_64
gzip.x86_64
hwdata.noarch
info.x86_64
initscripts.x86_64
iproute.x86_64
iptables.x86_64
iptables-ipv6.x86_64
iputils.x86_64
ipw2100-firmware.noarch
ipw2200-firmware.noarch
ivtv-firmware.noarch
iwl1000-firmware.noarch
iwl3945-firmware.noarch
iwl4965-firmware.noarch
iwl5000-firmware.noarch
iwl5150-firmware.noarch
iwl6000-firmware.noarch
iwl6050-firmware.noarch
kbd.x86_64
kbd-misc.noarch
kernel.x86_64
kernel-firmware.noarch
keyutils-libs.x86_64
krb5-libs.x86_64
less.x86_64
libacl.x86_64
libattr.x86_64
libblkid.x86_64
libcap.x86_64
libcap-ng.x86_64
libcgroup.x86_64
libcom_err.x86_64
libcurl.x86_64
libdrm.x86_64
libertas-usb8388-firmware.noarch
libffi.x86_64
libgcc.x86_64
libgcrypt.x86_64
libgpg-error.x86_64
libidn.x86_64
libnih.x86_64
libselinux.x86_64
libselinux-utils.x86_64
libsemanage.x86_64
libsepol.x86_64
libss.x86_64
libssh2.x86_64
libstdc++.x86_64
libudev.x86_64
libusb.x86_64
libuser.x86_64
libutempter.x86_64
libuuid.x86_64
libxml2.x86_64
logrotate.x86_64
lua.x86_64
lvm2.x86_64
lvm2-libs.x86_64
m4.x86_64
mingetty.x86_64
module-init-tools.x86_64
mysql-libs.x86_64
ncurses.x86_64
ncurses-base.x86_64
ncurses-libs.x86_64
net-tools.x86_64
newt.x86_64
newt-python.x86_64
nspr.x86_64
nss.x86_64
nss-softokn.x86_64
nss-softokn-freebl.x86_64
nss-sysinit.x86_64
nss-util.x86_64
openldap.x86_64
openssh.x86_64
openssh-server.x86_64
openssl.x86_64
pam.x86_64
passwd.x86_64
pciutils-libs.x86_64
pcre.x86_64
pinentry.x86_64
plymouth.x86_64
plymouth-core-libs.x86_64
plymouth-scripts.x86_64
policycoreutils.x86_64
popt.x86_64
postfix.x86_64
procps.x86_64
psmisc.x86_64
pth.x86_64
pygpgme.x86_64
python.x86_64
python-iniparse.noarch
python-libs.x86_64
python-pycurl.x86_64
python-urlgrabber.noarch
ql2100-firmware.noarch
ql2200-firmware.noarch
ql23xx-firmware.noarch
ql2400-firmware.noarch
ql2500-firmware.noarch
readline.x86_64
redhat-logos.noarch
rootfiles.noarch
rpm.x86_64
rpm-libs.x86_64
rpm-python.x86_64
rsyslog.x86_64
rt61pci-firmware.noarch
rt73usb-firmware.noarch
sed.x86_64
selinux-policy.noarch
selinux-policy-targeted.noarch
setup.noarch
shadow-utils.x86_64
slang.x86_64
sqlite.x86_64
sudo.x86_64
system-config-firewall-base.noarch
sysvinit-tools.x86_64
tar.x86_64
tcp_wrappers-libs.x86_64
tzdata.noarch
udev.x86_64
upstart.x86_64
ustr.x86_64
util-linux-ng.x86_64
vim-minimal.x86_64
which.x86_64
xorg-x11-drv-ati-firmware.noarch
xz-libs.x86_64
yum.noarch
yum-metadata-parser.x86_64
yum-plugin-fastestmirror.noarch
zd1211-firmware.noarch
zlib.x86_64

Solution 2:

It does not seem like a simple case of iterating over the package list and removing that package as some will be system packages which are vital to basic operation (unless you specifically want to brick the system, then you might as well reinstall).

If you want to see what packages are on the system but don't seem to be depended on for anything, you could run package-cleanup --quiet --leaves from yum-utils ( or package-cleanup --quiet --leaves --exclude-bin to exclude binaries ).

To remove all oprhaned packages automatically try:

package-cleanup --quiet --leaves --exclude-bin | xargs yum remove -y

Solution 3:

You could try doing a minimal install in a VM, and diff the package lists, removing any that aren't in the list from the VM. Perhaps combined with @jamza's answer