Removing unnecessary packages in Redhat 5

Posted on 2011-03-03
Last Modified: 2012-05-11
I have many servers where the admin used the default Redhat install. About 3000 packages were installed as a just in case we need them way of thinking. Is there anyway via scripting that I can uninstall selected packages while leaving the necessary package files in place? Also how would I deal with dependency issues?
Question by:drei22
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
LVL 79

Expert Comment

ID: 35027757
rpm -e <list of packagenames to be removed>

Packages will not be removed if there is another package that relies on it.

Are the extra packages besides taking space affect the performance of the system?

You probably can remove all the graphical/X11, Gnome, etc. packages but I found that their existance on the system helps at times when a graphical tool can be exported via an SSH tunnel back to an X-Server or a graphical workstation.

Author Comment

ID: 35027792
What happened is that we have two sites. Site A are the production the baseline servers which are fine.  Site B is where the backup servers are but they have a ton of unnecessary packages installed. I would like to get the Site B servers to match site A servers without having to rebuild the servers in site B. Actually management is insisting that we don't rebuild but but fix as rebuilding only makes sense to us Admins.
LVL 31

Accepted Solution

farzanj earned 500 total points
ID: 35027795
If you have enabled RedHat satellite server, you can do it very easily.

In any case, you need to know the packages you need and the ones you don't.  I would suggest that you should first test on a test box as to the number of packages you need.  If you want to start uninstalling on a production machine, well, it is risky.

Once you have accomplished that, you need to write a trivial script, that does

rpm -e  --nodeps << EOF

Note that there are no version numbers or release etc.
This way you will not have to reboot the machines.  However, rebooting would be a good idea because you would know whether it still runs after the uninstall.

Extreme caution is required.  Planning part is most important.
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?


Author Comment

ID: 35027922
Wow. Now that really sucks as I'll have to basically manually go through 3000+ packages and decide what needs to be removed.
LVL 31

Expert Comment

ID: 35027999
Unfortunately yes.  Planning deployment itself is a big thing.  The other solution is to reinstall with the correct packages, which would not be possible on production systems.  I have been doing deployments for a long time now and you have to very carefully plan the functionality you want and then packages are chosen, kickstart is created and deployment is automated.  Once you are using the systems, you would not like everything to break just because of one minor package.

Author Comment

ID: 35028053
Thanks Farzanj! You're information has been very helpful indeed to a new admin.

Author Closing Comment

ID: 35028079
I'm new to Linux administration and this was very helpful.
LVL 31

Expert Comment

ID: 35028082
You are most welcome
LVL 79

Expert Comment

ID: 35029074
run rpm -qa on the baseline servers. and store the data in a file.

then run rpm -qa on the other servers.
use comm or anyother mechanism to get the listing of the extra packages and then remove them.

Featured Post

Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question