Uninstall RPM package under CentOS

Source: Internet
Author: User

Rpm-qa|grep Sphinx

Rpm-e sphinx .....

Safely unloaded

RPM Uninstalls the package, does not simply remove the original installed files one by one, if you do so, there may be problems such as this or that. For example, a package relies on the B package for some work, and if the B package is unloaded, the a package will not function properly. RPM for user security, will do some checks, as far as possible to eliminate the error situation.

RPM When uninstalling a package, step through the following steps:

1. Check Dependencies (denpendency)

The purpose of checking dependencies is to ensure that no packages are currently dependent on the packages currently being uninstalled.

2. Trigger script before uninstalling (Triggerun)

3. Execute the Pre-uninstallation script (Preuninstall)

This program is set by the software package creator, to complete some of the work before uninstallation, such as, to uninstall a package in a

When the program is currently running, the script must kill it or it will not unload correctly.

4. Check the configuration file (Configfiles)

RPM will check if the configuration file in the package has been modified before uninstalling the package, and if so, RPM will be saved with a different name.

This file, the filename is generally "original file name +.rpmsave". (This is one of the features of RPM package management)

5. Real Uninstall

That is, the files are deleted individually according to the list of files in the package. Note that if one of the files belongs to another

Package (that is, two packages have a file with the same name), the RPM is not deleted.

6. Execute the Post-uninstall script (Postuninstall)

This program is mainly to complete the uninstall of the aftermath, such as the system configuration file inetd.conf modification, remove the installation

When adding something and so on.

7. Updating the RPM database

After uninstalling, RPM removes all information from the package in the database.

8. Trigger script after uninstall (Triggerpostun)

Command format

<ccid_nobr>

<ccid_code>rpm-e [Uninstall option 1 Uninstall Option 2 ...] [Package ID 1 package ID 2 ...]

Note: You can also use--erase instead of-e for the same effect.

Package identification

For installed packages, RPM uniquely identifies it using the following format:

<ccid_nobr>

<ccid_code>name[-subname]-version-release Where: Name: Refers to the software name; SubName: This item is optional, refers to the software bun package name; Version: refers to the software revision number. Note: it cannot contain a minus sign (-) character; Release: Refers to software release delineated.

For example, after the package file file-3.26-6.i386.rpm is installed, its package is identified as file-3.26-6. You can use this identity to uninstall, query, and verify the package. When you enter the package ID on the command line, you can write it all, or you can use the shorthand method. such as file-3.26-6, you can enter only file, or file-3.26, or lose the whole. Another example: Package identification xfree86-devel-3.3.6-6 with a child package, can enter only Xfree86-devel, or xfree86-devel-3.3.6, and can be fully entered.

Note: Package identifiers are case-sensitive, meaning that uppercase and lowercase letters represent different meanings. such as BASH-2.03-10 logo can not be lost as bash-2.03-10, also can not lose bash-2.03-10 and so on.

List of options

For an explanation of the general options, please refer to the installation section of the <<rpm application >>

Here are some explanations for the specified options:

1.--test: Unload test

What does the rpm unload test do? The main thing is to check the dependencies and make sure that no packages in the system depend on the packages to be uninstalled. If there are packages that are dependent on the package being uninstalled, RPM will prompt for errors that the dependency will break, for example:

<ccid_nobr>

<ccid_code># rpm-e--test mktemperror:removing These packages would break dependencies:mktemp was needed by Autocon F-2.13-5mktemp are needed by dev-2.7.7-4bpmktemp are needed by groff-1.11a-10bpmktemp are needed by Gzip-1.2.4-15bpmktemp are Needed by Initscripts-4.16-3bpmktemp are needed by metamail-2.7-21bpmktemp are needed by rpm-3.0.3-4bpmktemp are needed by AU Tofs-3.1.3-2/bin/mktemp is needed by apache-1.3.12-5bp/bin/mktemp are needed by linuxconf-1.16r1.3-4bp#

Of course, we know better when we browse the debug information that was output when we unloaded the test.

<ccid_nobr>

<ccid_code># rpm-e--test-vv File | NL1 d:opening Database mode 0x0 in//VAR/LIB/RPM/2 d:getting list of mounted FILESYSTEMS3 + echo TRIGGERUNINSTALL4 Trigg  ERUNINSTALL5 d:will Remove Files test = d:file:/usr/share/magic action:remove7 d:file:/usr/man/man4/magic.4 action:  Remove8 d:file:/usr/man/man1/file.1 action:remove9 d:file:/usr/bin/file Action:remove10 + echo triggerpostuninstall11 TRIGGERPOSTUNINSTALL12 d:removing Database entry

Note: This example carries out the unload test of the file package, and the output information is sent to the NL to list the line number, which is now interpreted by line. (line number after the start of the D: line output for debugging information)

Line 1th: Open the RPM database under the/var/lib/rpm directory;

Line 2nd: Take the list of installed file systems;

Line 3rd: Trigger the script before uninstalling;

Line 4th: This line is the execution result of triggering the script program before unloading;

Line 5th: rpm prompts to delete the file, where test=1 indicates that the unload test is not really deleted;

第6-9: Show the execution of each file-delete;

Line 10th: Trigger the script after performing the uninstallation;

Line 11th: The bank is the execution result that triggers the script program after unloading;

Line 12th: Delete the package information in the database.

2.--nodeps: Do not check dependencies

The RPM management software package not only manages all the files in the package, but also manages dependencies between packages. If a depends on the B operation, if B does not exist, then a will not run. RPM maintains this relationship and avoids any disruption to ensure the proper operation of the software. In the previous example of an unload test for a mktemp package, RPM prompts for an error that interrupts the dependency. If you use this option and do not check for dependencies, the uninstall test completes successfully.

<ccid_nobr>

<ccid_code># rpm-e--test--nodeps mktemp#

It should be noted that unless the user has sufficient knowledge of the package, do not use this option, it is best to let rpm automatically maintain the dependencies between the software to ensure that it works properly.

3.--noscripts: Do not execute the script program

An RPM package can contain five scripts, i.e. pre-installation scripts, post-installation scripts, pre-uninstallation scripts, post-uninstallation scripts, and verification scripts. Use the--noscripts option when uninstalling to suppress the execution of the script before and after uninstallation.

Note: Do not use this option for general users. This option is primarily for use by package creators. By prohibiting the execution of scripts, you can prevent the entire system from being shut down by installing packages with bugs. This option does not have to be used when a bug is removed from the package.

4.--notriggers: Do not execute trigger program

For inter-package interaction control, RPM designed three triggers: trigger on installation, trigger before uninstall and trigger after uninstall. You can use the--notriggers option to prevent the uninstallation of a package from triggering the execution of a program before and after uninstalling. By comparing the output of the example shown in the next example with the 1th option, you can see that after the--notriggers option is selected, both pre-and post-uninstallation triggers are not triggered.

<ccid_nobr>

<ccid_code># rpm-e--test-vv--notriggers File |  NL1 d:opening Database mode 0x0 in//VAR/LIB/RPM/2 d:getting list of mounted filesystems3 d:will Remove files test = 14 D:file:/usr/share/magic action:remove5 d:file:/usr/man/man4/magic.4 action:remove6 D:file:/usr/man/man1/file.1 acti On:remove7 d:file:/usr/bin/file action:remove8 d:removing database Entry5. --allmatches: Uninstall all matching Packages

RPM can install different versions of the same software into the system, so if you want to uninstall all, then simply lose the software name is not possible, there will be an error, such as:

<ccid_nobr>

<ccid_code># rpm-q foofoo-6.0-1foo-7.0-1# rpm-e fooerror: "foo" specifies multiple packages#

Note: In this example, query Foo package first, found that there are 6.0 and 7.0 version two versions, and then unload the Foo package, error: There are multiple packages with the name Foo.

How can I uninstall it all?

One of the answers is one uninstall, enter the package identity when uninstalling, because the software name is the same, so at least another version number, this situation applies to the software version of the time.

<ccid_nobr>

<ccid_code># rpm-e--allmatches foo# rpm-q foopackage foo is not installed#

No error occurred during uninstallation, then query Foo package, RPM prompts package not installed.

6.--justdb: Modify Database only

With this option, RPM will only update its database and the file system is not updated, meaning that if the package has files installed, the files are still saved after uninstallation <ccid_nobr>

<ccid_code># rpm-ql file/usr/bin/file/usr/man/man1/file.1/usr/man/man4/magic.4/usr/share/magic# ls-l/usr/ Bin/file-rwxr-xr-x 1 root root23948 Mar 1999/usr/bin/file# rpm-e--justdb file# ls-l/usr/bin/file-rwxr-xr-x 1 root root23948 Mar 1999/usr/bin/file#

Note: This example first use RPM-QL query to get file list, and then use the LS command package in a file/usr/bin/file, can list information, so the file exists. Then use RPM-E--justdb to unload the file package but only update the database, and then use the LS command column/usr/bin/file, you can see that the files still exist.

Uninstall RPM package under CentOS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.