Product SiteDocumentation Site

3.3. Removing Software

The rpm command is good for more than just installing and upgrading software packages. Many times, you will need to remove packages as well.
To remove a package, use the -e option to the rpm command, short for erase. The basic syntax follows:
rpm -e package_name

Use Package Names, Not File Names

When erasing or removing packages, use the package name, not the RPM file name. If you think about this, it makes sense. You don't always have the original RPM files when the time comes to remove a package.
For example:
rpm -e jikes-1.16-1
This example removes the jikes-1.16-1 package used in previous examples.

root Access is Required

You will need to use the root account, or super user, to remove most packages. This is because the package files themselves are protected. In addition, the RPM database is protected.
This is only natural, since most RPMs are used to install system-level commands and applications.
When removing a package, the rpm command first checks that no other packages depend on the package you intend to remove. This is very important, since you otherwise can damage your Linux system by inadvertently removing packages needed by the rest of the system.
The rpm command supports the --test option for removing packages as well as when installing. As with installing, the --test option tells the rpm command to test to see whether it can remove the given package but not to force the removal.
For example, if you try to remove the very important-looking syslinux-1.75-3 package, you can use the --test option to see if this works.
For example:
rpm -e --test syslinux-1.75-3
This command will issue an error such as the following:
error: Failed dependencies: syslinux is needed by (installed) mkbootdisk-1.4.8-1

Alternative Option Name

When removing packages, you can use the long option name, --erase, in place of –e.

3.3.1. Checking that the package has been removed

As before, you can use the rpm –q command to query whether a package is installed. After running the rpm –e command, you can run the rpm –q command to check whether the package has been removed. If the rpm –q command shows that the package is not installed, that tells you the erase operation has worked.
For example:
# rpm -q jikes
jikes-1.16-1
# rpm -e jikes-1.16-1 # rpm -q jikes
package jikes is not installed