initCommon(); $template->displayHeader(); ?>

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

Note

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.

Note

You will need to be logged in as the root user, 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

Note

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

3.3.2. Removing multiple packages at a time

You can remove multiple packages at once by listing each package consecutively on the command line. For example:

rpm -e aspell-en-ca-0.33.7.1-16 aspell-en-gb-0.33.7.1-16

This command removes the aspell-en-ca-0.33.7.1-16 and aspell-en-gb-0.33.7.1-16 packages.

3.3.3. Options when removing packages

The --allmatches option tells the rpm command to remove all packages with names that match the names you pass on the command line. If you do not use the --allmatches option, the rpm command will issue an error if more than one package matches the name or names you pass on the command line.

The --nodeps option tells the rpm command to skip the test of dependencies. Use this option when you really, really, want to uninstall a package.

Warning

Using any option that does not perform the full removal of the package, or skips some of the checks built into the rpm command, can result in damage to your Linux system. Use these options with care.

The --repackage option, described previously, tells the rpm command to create a package, an RPM file, from any packages it would erase. These packages will appear in the default repackage directory, which is normally /var/spool/repackage. Check your RPM settings to be sure of the directory configured on your system.

Note

Packages created with the --repackage option are not full packages. You cannot install these packages.

Similar to the options when installing or upgrading packages, you can use the --noscripts and --notriggers options when removing packages. The --noscripts option tells the rpm command not to run any uninstallation scripts. You can refine this by using either --nopreun or --nopostun in place of the --noscripts option.

The --nopreun option tells the rpm command not to run the pre-uninstallation scripts. The --nopostun option tells the rpm command not to run the post-uninstallation scripts.

The --notriggers option works in a similar fashion. The --notriggers option tells the rpm command not to execute any triggers. For a finer grain of control, use --notriggerun to prevent any uninstallation triggers and --notriggerpostun to prevent any post-uninstallation triggers.

displayFooter('$Date: 2005/11/02 19:30:06 $'); ?>