Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

When you install software using yum Install, if the installation contains dependencies, it is installed together.

However, when you uninstall with Yum Remove, the software and dependencies are not unloaded together.

So, how do you use YUM to uninstall software and all of its dependencies? The answer isto use the yum history command.

Yum Remove does not uninstall dependencies

When installing mysql, Install mysql-community-client, mysql-community, mysql-community-libs, mysql-community-client-plugins And mysql – community – server

As follows:

# rpm -qa | grep mysqlMysql - community - the client - 8.0.26-1. El7. X86_64 mysql - community - common - 8.0.26-1. El7. X86_64 Mysql80 - community - release - el7-3. Noarch mysql - community - libs - 8.0.26-1. El7. X86_64 Mysql - community - the client - plugins - 8.0.26-1. El7. X86_64 mysql - community - server - 8.0.26-1. El7. X86_64Copy the code

Release -el7-3.noarch is the MySQL repository source package

Mysql > install mysql-community-server

# yum remove mysql-community-server -y
Copy the code

Its dependency remains:

# rpm -qa | grep mysqlMysql - community - the client - 8.0.26-1. El7. X86_64 mysql - community - common - 8.0.26-1. El7. X86_64 Mysql80 - community - release - el7-3. Noarch mysql - community - libs - 8.0.26-1. El7. X86_64 Mysql - community - the client - plugins - 8.0.26-1. El7. X86_64Copy the code

Yum History View history records

Use Yum History to view all installation histories.

# yum historyID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 30 | root <root> | 2021-09-03 21:13 | Erase | 1 29 | root <root> | 2021-09-03 17:02 | Install | 5 P< 28 | root <root> | 2021-09-03 16:58 | Install | 1 >< 27 |  root <root> | 2021-09-03 16:52 | Install | 1 >< 26 | root <root> | 2021-09-03 16:30 | Install | 1 >< 25 | root <root> |  2021-09-03 09:54 | Install | 1 > 24 | <root_test> | 2021-09-02 15:20 | Install | 1 P< 23 | <root_test> | 2021-09-02 15:17 | Install | 1 >< 22 | <root_test> | 2021-09-02 15:08 | Install | 1 >< 21 | <root_test> | 2021-09-02 13:28 | Install | 1 > 20 | <root_test> | 2021-09-02 13:22 | I, U | 5 19 | root <root> | 2019-09-19 10:19 | I, U | 8 18 | root <root> | 2019-09-18 17:11 | Install | 4 17 | root <root> | 2019-09-18 16:47 | Erase | 2 16 | root <root>  | 2019-06-21 16:04 | Install | 13 EE 15 | root <root> | 2019-06-21 09:39 | I, O, U | 1038 EE 14 | root <root> | 2019-06-14 16:41 | I, U | 6 EE 13 | root <root> | 2019-06-14 11:06 | Install | 1 12 | root <root> | 2019-03-28 18:01 | I, U | 23 11 | root <root> | 2019-03-28 15:13 | Install | 1history list
Copy the code

yum history undo IDUndo all installations at a time

Mysql > install mysql-community-server mysql > install mysql-community-server mysql > install mysql-community-server

Then undo all software (packages and their dependencies) for this installation

# yum history undo 29 -y
Copy the code

After executing, check again:

# rpm -qa | grep mysql
mysql80-community-release-el7-3.noarch
Copy the code

Redo the installation using redo

Use the redo ID to restore an installation.

# yum history redo 29 -y
Copy the code