A quick and easy guide to removing RPM packages using yum
If you've added software to CentOS, Red Hat, or Fedora Linux via the yum package manager, uninstalling it is straightforward. Just find the package name and ensure you have root or sudo access. This guide walks you through removing a package with yum, optionally clearing dependencies, and fixing typical issues.
Fast Instructions
- Use "yum list installed" to view all installed packages.
- Execute "yum remove <packagename>" to delete a package.
- To remove a package along with its dependencies, run "yum autoremove <packagename>".
Detailed Steps
Remove a Package

Identify the package name. If you’re unsure of the exact package you want to remove, here’s how to find it:
- Run yum list installed to view all installed packages. Be aware, the list could be extensive if many packages are installed.
- To search by keyword, use yum list installed | grep keyword.
- Swap out keyword for a word related to the package you're seeking.
- Example: To locate a BIND-related package, enter yum list installed | grep bind to show packages with "bind" in their names.

Execute yum remove packagename to delete the package. For instance, to remove BIND, you would run yum remove bind. Provide your password when requested, hit y, then press Enter to confirm.
- You can alternatively use yum erase packagename, as erase works identically to remove.
- If you are not root, prepend the yum command with sudo.
Remove a Package Along with Dependencies

Run yum autoremove packagename to uninstall a package and its unused dependencies. This method removes the target package and any leftover dependencies you no longer need.

Automatically remove dependencies (optional). To make yum remove unnecessary dependencies automatically without needing to run yum autoremove each time, update your /etc/yum.conf file:
- Open /etc/yum.conf using any text editor like nano or vi.
- Insert the line clean_requirements_on_remove=1.
- Save the changes and exit.
Remove Multiple Packages

Use the command yum remove package1 package2 package3 to uninstall several packages at once. Just list each package name after "yum remove," separated by spaces.
Remove a Group

Choose whether to uninstall all packages in a group or only the unused ones. When removing a group with yum, it deletes all group packages, even if they're dependencies for others. To only uninstall packages that aren't needed elsewhere, first edit /etc/yum.conf:
- Open /etc/yum.conf with a text editor.
- Add the line groupremove_leaf_only=1 under the "[main]" section.
- Save and close the file.

Run yum grouplist to display installed groups. To remove a package group using yum, you need the group's exact name. This command lists all installed groups.
- For instance, to uninstall the KDE Plasma Workspaces group, look for "KDE Plasma Workspaces".
- If you can't find your group, try yum grouplist hidden to show hidden groups.
- To preview the packages that will be deleted, run yum groupinfo groupname.

Execute yum groupremove groupname to delete a group. This removes all packages installed with the group.
- If the group's name includes spaces, wrap it in quotes. Example: yum groupremove "KDE Plasma Workspaces".
Troubleshooting

Error: Trying to remove "yum", which is protected. This error appears if you attempt to uninstall a critical package that yum needs, like python or gawk, or something essential for systemd, like binutils.
- Although you could technically remove it with rpm -e --nodeps packagename, doing so would likely break your system and require a yum reinstallation. It's strongly discouraged.

Error: No match for argument. This error suggests the package name is wrong or that it wasn't installed with yum—perhaps it was compiled from source instead.

Yum uninstalls may leave remnants behind. When you remove a package using yum, it only deletes the installed software—any directories or configuration files created separately by the software will remain unless you manually remove them.

Yum broke after uninstalling the system's python version. Since yum depends on python, removing python from your system will cause yum to fail. Sadly, there's no simple fix—because yum relies on the system’s default python version, your best option is to back up your files and reinstall the OS. See how uninstalling python affects your system.