Be Careful When Using Yum Remove

Open SourceThe Yum install command installs open source packages. It also installs any sub-packages upon which the desired package relies.

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.

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

Running the --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)

For more information on Yum history options, including rolling back Yum transactions, see How to view Yum transaction history and How to undo or roll back Yum transactions.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.