Yum remove does the reverse. It will remove a requested package.
What some users don’t know:
Yum remove also removes any packages that depend on the package you removed. This is true whether running Yum manually or via the ACS open source package manager.
For example, removing Python3 also removes packages that depend on it. The Yum command to remove Python3 is:
yum remove python3
In addition to removing Python3, the command above would attempt to remove nodejs14 and other dependent packages. Yum knows that those packages could not function without Python3.
Read the warnings before hitting “y”
Yum does warn of all changes before making them. For example, here is a portion of the output from
yum remove python3, naming the dependent packages that would also be “erased” when removing Python3.
Loaded plugins: changelog
Setting up Remove Process
---> Package python3.ppc64 0:3.6.15-1 will be erased
---> Package nodejs14.ppc64 0:14.19.1-1 will be erased
---> Package nodejs16.ppc64 0:16.14.2-1 will be erased
---> Package php-ibm_db2.ppc64 0:2.1.5-0seiden8.1 will be erased
---> Package php-pdo_ibm.ppc64 0:1.5.0-0seiden8.1 will be erased
--> Finished Dependency Resolution
Remove 40 Packages
Installed size: 808 M
Is this ok [y/N]: n
Users who did not scrutinize the warnings, quickly typing “y” (yes) at
Is this ok, could unintentionally lose nodejs14, nodejs16, and two PHP extensions.
Review before you remove
--whatrequires rpm option can tell you which packages depend directly on the package you are removing. The command for our Python3 example would be:
rpm -q --whatrequires python3
This will give you a partial list of dependent packages, but might not be complete, because those packages may be dependencies of yet other packages. At least you’d know to pay attention to the “will be erased” messages.
The safest approach is to scrutinize any “will be erased” messages when doing a removal. Make sure you can live with the erasures before you type “y.”
How to undo a Yum command
If you accidentally remove packages using Yum, you can go back using the
Yum history commands:
Yum history info: See the list of packages affected by your last command
Yum history undo last: Undo your last Yum command (you’ll get a confirmation prompt first)