Remove unused rpm packages

Cite from: http://heuristically.wordpress.com/2009/09/03/cleaning-unused-rpm-packages/

 

On a Fedora, Red Hat, CentOS, Mandriva, or RPM-based similar system, you may have installed some RPM software you don’t use. There are some easy ways to check.

First, look through the biggest packages. This command displays the packages in order from smallest to largest.


view source  

print ?

1

rpm -qa --queryformat=
"%{NAME} %{SIZE}\n"
| 
sort
-k 2 -n

On my Fedora 11 system, the end looks like this:

gnome-user-docs 48174253  jre 48824854  kernel 49087730  kernel 49247033  kernel 49264829  libgcj 49666075  wine-core 57989940  thunderbird 70502350  libgweather 79809273  java-1.6.0-openjdk 88175735  gutenprint-foomatic 89742590  ooobasis3.1-core04 91459112  VirtualBox 95813539  glibc-common 97556081  git 100008386  VMware-Player 101075736  texlive-texmf-fonts 112425640  AdobeReader_enu 150806101

What is texlive-texmf-fonts It eats 107MB! This command prints the RPM package description:


view source  

print ?

1

[z@a scripts]$ rpm -qi texlive-texmf-fonts

Name        : texlive-texmf-fonts          Relocations: (not relocatable)  Version     : 2007                              Vendor: Fedora Project  Release     : 28.fc11                       Build Date: Wed 25 Feb 2009 03:35:16 PM MST  Install Date: Fri 24 Jul 2009 03:16:31 PM MDT      Build Host: x86-1.fedora.phx.redhat.com  Group       : Applications/Publishing       Source RPM: texlive-texmf-2007-28.fc11.src.rpm  Size        : 112425640                        License: Artistic 2.0 and GPLv2 and GPLv2+ and LGPLv2+ and LPPL and MIT and Public Domain and UCD and Utopia  Signature   : RSA/8, Mon 16 Mar 2009 04:23:06 PM MDT, Key ID 1dc5c758d22e77f2  Packager    : Fedora Project  URL         : http://tug.org/texlive/  Summary     : Font files needed for TeXLive  Description :  This package contains the components of the TEXMF tree needed for the  texlive-fonts package.  

I don’t use that directly, so let’s try removing it to see if other software uses it. Using yum remove is better than calling rpm -e because yum checks the dependencies.


view source  

print ?

1

[z@a ~]$ 
sudo
yum remove texlive-texmf-fonts

Now pay attention! With dependencies, this will remove 11 packages. I know I don’t need these particular packages, so I approve the change and save about 140MB.

Next, you noticed I had three kernels installed? Since I last rebooted a month ago, and I’ve installed two kernel updates. That means I’m using the oldest kernel, and when I reboot, I will use the newest kernel, so I can remove the middle kernel.


view source  

print ?

1

[z@a ~]$ rpm -q kernel

kernel-2.6.29.6-213.fc11.i586  kernel-2.6.29.6-217.2.8.fc11.i586  kernel-2.6.29.6-217.2.16.fc11.i586

This command shows which I am using:


view source  

print ?

1

[z@a ~]$ 
uname
-a

Linux a.z 2.6.29.6-213.fc11.i586 #1 SMP Tue Jul 7 20:45:17 EDT 2009 i686 athlon i386 GNU/Linux

So I will remove the middle kernel package and save about 50MB.


view source  

print ?

1

[z@a ~]$ 
sudo
rpm -e kernel-2.6.29.6-217.2.8.fc11.i586

To save more disk space, look for orphaned packages. These are old dependencies that aren’t needed any more. Install rpmorphan:


view source  

print ?

1

[z@a ~]
# sudo yum -y install rpmorphan

Ironically this little 55KB package requires 5MB of dependencies itself. Let’s hope it’s worth it!

While rpmorphan has some command line options, I run it plain:


view source  

print ?

1

[z@a ~]
# rpmorphan

libXevie  libXmu-devel  libXv-devel  libass  libdv-devel  liberation-fonts-compat  libgdiplus-devel  libgxim  libjpeg-devel  libmikmod  libpaper  libsepol-devel  libtextcat  libtiff-devel  libtirpc

Generally orphaned packages starting with lib are safe to delete. The following command deletes the orphans (and uses triple safety):


view source  

print ?

1

rpmorphan | 
grep
^lib | 
xargs
sudo
rpm -e

Another way to save disk space is to remove part of installed packages by using the localization (locale) cleaning feature in BleachBit. This saves disk space by removing languages you don’t use.

Finally, I remind you: don’t remove packages you don’t understand! You could destroy your system, though Linux is easy to repair advanced users) if you can boot in to recovery mode, identify the missing packages, and reinstall the missing packages. This repair takes some skills, but it’s simpler than fixing Windows.

 

Refer:

http://forums.opensuse.org/get-help-here/applications/405306-how-find-unused-packages-2.html


你可能感兴趣的:(Linux,Manage)