Ask Your Question

Erase all packages except a given list of packages/groups

asked 2013-01-16 16:13:26 -0500

nori gravatar image

I want to restore Fedora to the set of packages that were installed by the default install. I know now, what they are.

The yum history is already long and convoluted, so redoing every action yum ever made is not really an option for me.

Looking further, I found no yum/rpm command equivalent to "erase everything except these groups". Is there one? Is this somehow achievable by a script?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-01-17 03:49:19 -0500

ztank1013 gravatar image

updated 2013-01-17 03:58:09 -0500

Firstly install the yum-utils package if not already in your distro:

sudo yum install yum-utils

Then, to get the full list of the installed rpm packages in your fresh installed Fedora 18 distro use the following command and redirect the output to a file. Before doing that we will clean up a little bit the output to avoid duplicate packages listing (using sort and uniq commands):

sudo repoquery -g -l "Administration Tools" "Cloud Infrastructure" "Critical Path (Applications)" "Critical Path (GNOME)" "Design Suite" "Dial-up Networking Support" "Fonts" "Graphical Internet" "Graphics" "Hardware Support" "Input Methods" "Java" "Legacy Fonts" "LibreOffice" "Mail Server" "Multimedia" "Network Servers" "Office/Productivity" "Printing Support" "Robotics" "Server Configuration Tools" "Sound and Video" "System Tools" "Text-based Internet" | sort | uniq > /tmp/default-rpms-installed.txt

The following command can give the list of currently installed rpm packages (again let's clean up the output with sort and uniq commands at the end):

sudo rpm -qa --qf "%{NAME}\n" | sort | uniq

Now let's get the list of all rpm packages contained in the current installation which are not present in a default fedora 18 install. The list will be later on used to remove all those exceeding packages and to roll back your fedora install to a default set of packages. As root you may run:

for i in `rpm -qa --qf "%{NAME}\n"` ; do grep -w $i /tmp/default-rpms-installed.txt  ; done |sort | uniq | xargs > /tmp/rpm-to-delete.txt

To remove all the listed packages just (carefully) run as root:

rpm -e `cat /tmp/rpm-to-delete.txt`

CAUTION: Be extra careful because the above command is not going to ask you for confirmation... a good idea would be to use it in conjunction with the -t and -vv options to test it before actually running it:

rpm -e -t -vv `cat /tmp/rpm-to-delete.txt`
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-01-16 16:13:26 -0500

Seen: 1,458 times

Last updated: Jan 17 '13