This article was reviewed by Stan Kats and by wikiHow staff writer, Nicole Levine, MFA. Stan Kats is a Professional Technologist and the COO and Chief Technologist for The STG IT Consulting Group in West Hollywood, California. Stan provides comprehensive technology solutions to businesses through managed IT services, and for individuals through his consumer service business, Stan's Tech Garage. Stan holds a BA in International Relations from The University of Southern California. He began his career working in the Fortune 500 IT world. Stan founded his companies to offer an enterprise-level of expertise for small businesses and individuals.
This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.
This article has been viewed 8,455 times.
If you installed a software package on CentOS, Red Hat, or Fedora Linux using the yum package manager, uninstalling the package is easy. You'll just need to know the package's name and use an account with root or sudo privileges. This quick guide will show you how to uninstall a package using yum, with or without dependencies, and help you troubleshoot common errors.
Quick Steps
- Run "yum list installed" to see installed packages.
- Run "yum remove <packagename>" to uninstall a package.
- To also uninstall dependencies, use "yum autoremove <packagename>".
Steps
Uninstall a Package
-
Get the package name. If you're not sure what the exact name of the package is that you want to uninstall, there's an easy way to find it:
- To see a list of all installed packages, run yum list installed. However, this can be a lengthy list if you've installed a lot of packages.[1]
- To search for a package that contains a certain keyword, run the command yum list installed | grep keyword.
- Replace keyword with anything that describes the package you're looking for.
- For example, if you're looking for a package related to BIND, you'd use yum list installed | grep bind to display all installed packages with "bind" in the name.
-
Run yum remove packagename to uninstall the package. For example, to uninstall BIND, run yum remove bind. Enter your password when prompted, press y, and then press Enter to uninstall the package with yum.
- You can also use yum erase packagename, as erase works the same as remove.
- If you're not logged in as root, you'll need to preface the yum command with sudo.
Uninstall a Package and Dependencies
-
Use yum autoremove packagename to uninstall a package and its dependencies. This command not only uninstalls the package, but also deletes any dependencies you'll no longer need once the package is removed.
-
Remove dependencies automatically (optional). If you want to automatically remove dependencies when you run the yum remove command instead of running yum autoremove every time, just make a quick change to /etc/yum.conf:
- Open /etc/yum.conf in any text editor, such as nano or vi.
- Add the line clean_requirements_on_remove=1.[2]
- Save the file.
Uninstall a Group
-
Decide whether to remove all packages in a group, or just those not in use. When you uninstall a group with yum, you'll be uninstalling all packages in that group, even if a package is part of another installed group or a dependency of another installed package. If you only want to uninstall packages from a group that aren't required by other packages or groups, you'll need to edit /etc/yum.conf first:
- Use any text editor to open /etc/yum.conf for editing.
- Add groupremove_leaf_only=1 to the "[main]" section of the config file.[3]
- Save the file.
-
Use the command yum grouplist to view all installed groups. To uninstall a package group with yum, you'll need the group's name. This displays all package groups you've installed.
- For example, if you want to uninstall the KDE Plasma Workspaces group, the group name you're looking for is "KDE Plasma Workspaces".
- If you don't see the group you're looking for, use yum grouplist hidden to include hidden package groups.[4]
- To see which packages will be removed when you uninstall the group, use the command yum groupinfo groupname.[5]
-
Use yum groupremove groupname to remove the group. This uninstalls all packages that were installed with that group.
- If the group name contains spaces, surround it in quotes. For example, yum groupremove "KDE Plasma Workspaces".
Expert Q&A
Tips
References
- ↑ https://access.redhat.com/sites/default/files/attachments/rh_yum_cheatsheet_1214_jcs_print-1.pdf
- ↑ https://linux.die.net/man/5/yum.conf
- ↑ https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-configuring_yum_and_yum_repositories
- ↑ https://access.redhat.com/solutions/15815
- ↑ https://docs.oracle.com/en/operating-systems/oracle-linux/7/yum/yum-YumGroups.html
- ↑ https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s2-rpm-uninstalling