uninstall packages in centos

How to Uninstall Package in CentOS

Sometimes you may need to remove a package in CentOS. You can do it easily using yum command. But there are different aspects to removing package in CentOS. In this article, we will learn how to uninstall package in CentOS. You can also perform these steps for RHEL/CentOS/Fedora/SUSE Linux.


How to Uninstall Package in CentOS

Here are the steps to uninstall package in CentOS.


1. Uninstall package with yum

RHEL/CentOS/Fedora/SUSE Linux have yum package manager for installing & uninstalling packages. Here is the command to remove package.

# yum remove [package_name]
OR
# yum erase [package_name]

Here is an example to remove apache2 package.

# yum remove apache2

Before yum removes a package, it will prompt you for root password, and y/n confirmation. Once you enter both inputs, it will start the uninstallation and keep showing progress till it completes. Finally, it will display message saying your package has been deleted.


2. Remove Dependencies using yum

Package dependencies are those software, libraries, binaries & modules that a said package depends upon. When you delete a package, in most cases, yum also deletes its dependencies. But if you find that this has not happened, then you can explicitly instruct yum to remove the package as well as its dependencies, with the following command.

# yum autoremove [package_name]

Here is an example to remove apache2 as well as its dependencies.

# yum autoremove apache2

Alternatively, you can edit yum configuration file so that it always deletes a package’s dependencies when it deletes the package. For this purpose, open yum configuration file in a text editor.

# vi /etc/yum.conf

Add the following line to it.

directive clean_requirements_on_remove=1

Save and close the file. Now, whenever you delete a package, its dependencies will also be deleted. But please be sure you actually want to do this, before you make the above change.


3. Find Specific Package

You need to know the actual name of package in order to be able to delete it. Otherwise, yum command will return an error saying package not found. Sometimes, the package name is slightly different from what we expect and this can result in errors. For example, the package name of Apache web server is apache2. In some cases, you may have different packages (e.g. python2.7, python3, etc.) for the same software (e.g. python). Therefore, it is important to know the exact name of the package to be deleted from your system.

You can find the exact name of your package using the following commands, along with its files.

yum list- | grep [package_name]
OR
rpm -qa | grep [package_name]

For example, the following command will list all files for Apache package. It will also list all packages with given name.

# yum list- | grep apache

In this short article, we have learnt how to get the exact name of a given package, and how to uninstall from our system.

Also read:

Limit Bandwidth & Connection in Apache Server
How to Remove Local Untracked Files from Git
How to Create Menu with Submenu in Shell Script
How to Delete File from Git Repository
What Does __file__ mean in Python

Leave a Reply

Your email address will not be published. Required fields are marked *