Each Linux distribution is a collection of various packages. So, all packages must keep in a suitable package manager. Different types of package managers are available on every Linux distribution. When we talk about CentOS then, using RPM is a package, and YUM is used as Package Manager. YUM is available on almost all kinds of RPM-based environments like CentOS, Fedora, OpenSUSE, and RHEL. However, it is used on RHEL and CentOS distributions mostly.
So, we will guide you in this article about how you can uninstall a program or package using the yum package manager. We have implemented all commands on the latest available CentOS 8 Linux distribution. But, these below mentioned commands can also be used on an older CentOS environment. It is important to note that you can uninstall rpm packages using the yum package manager.
To make any system-level change in the Linux distribution, you must have sudo command or root privileges. In the CentOS environment, you need to login from a root account or any user who can execute sudo commands.
All commands we need to run on a command-line tool. Therefore, open the terminal. To do that, click on ‘Activities’ on top left corner and from the sidebar click on the terminal application icon as follows:
Now, let’s start the demonstration about how to uninstall a package using yum on CentOS 8.
List the installed Package Using Yum Package Manager
Before uninstalling any program from your system, you need to know either this package is installed on this system or not. You must have the package name that you want to uninstall from your CentOS 8 system. For this purpose, you need to list all installed packages. Therefore, by executing the following command you can list all installed packages on your system:
$ yum list installed
For your convenience, you can use less with the above-mentioned command.
$ yum list installed | less
You can filtered the displaying output with the help of following ‘grep’ command:
$ yum list installed | grep <search_term>
For example, you want to search the gcc package. Just type gcc in the search term as follows:
$ yum list installed | grep gcc
Uninstall a Package Using Yum
Now, we are assuming that you know about the package name that you want to uninstall. So, using the following command you can uninstall the required package:
# yum remove <package>
For example, you want to remove a package with the name gcc.x86_64. Then, you can remove it by using the following command:
# yum remove gcc.x86_64
Uninstall Multiple Packages
By executing the same above command using the following structure, you can uninstall multiple packages:
# yum remove <package_1> <package_2>
For example, we want to remove two packages gcc.x86_64 and Firefox. Then, use the command as follows:
# yum remove gcc.x86_64 firefox
Uninstall a packages group
Many similar kinds of packages you can install using the group package installation. So, if you don’t want to use it further then, you can also uninstall this group.
# yum remove @"<group_name>"
Let’s give you an example, you can install a group ‘Development tools’ in which different packages related to development like gcc compiler, cmake, git and automake, etc are included. So, by using just a single command you can uninstall the packages group.
# yum remove @"Development Tools"
Alternatively, you can use the below command that will perform the same operation that we have done in the above command.
# yum group remove "<group_name>"
Automate package removal confirmation prompt
When you uninstall a package, it will show you a confirmation prompt. So, if you don’t want to view the prompt during the installation then, use the option ‘-y’ with your command.
# yum remove <package_name> -y
However, yum isn’t the only one that offers this feature. Using this powerful manager you can perform more tasks. So, execute the following command to explore more features of Yum package manager:
$ yum --help
We have a simple way to uninstall a package using Yum. You need to just type the package name with root privileges. Moreover, we have also seen how to remove a single package, multiple, and group by using the Yum package manager. Send us your feedback through comments.
Samreena Aslam holds a master’s degree in Software Engineering. She’s a technical writer and has written various articles on different Linux flavours including Ubuntu, Debian, CentOS and Mint.