How to Uninstall or Remove Packages from CentOS

Introduction

If you are using CentOS, you may need to uninstall or remove packages from time to time. Uninstalling packages can help you free up disk space, remove unnecessary applications, and keep your system up to date. In this guide, we will show you how to uninstall or remove packages from CentOS. We will cover both the command line and graphical user interface (GUI) methods for uninstalling packages. We will also discuss how to remove packages that are no longer needed.

How to Uninstall or Remove Packages from CentOS

1. Use the yum command to remove a package:

sudo yum remove

2. Use the rpm command to remove a package:

sudo rpm -e

3. Use the dnf command to remove a package:

sudo dnf remove

4. Use the rpm command to remove a package and its dependencies:

sudo rpm -e –nodeps

Introduction

Uncesscerary packages slow down system performance and take up storage space. If specific software isn’t being used, then it’s best to remove it, and doing so is easy.

In this tutorial, learn how to remove packages and uninstall dependencies from CentOS 7.

Tutorial on how to uninstall packages from CentOS.

Prerequisites

  • Access to a user account with sudo or root privileges
  • A terminal window or command line (Ctrl+Alt+F2)
  • The YUM and RPM package managers, included by default

Uninstall Package from CentOS with Yum

CentOS is an RHEL (Red Hat Enterprise Linux) distribution. Users rely on the RPM (Red-hat Package Manager) and YUM (The Yellowdog Updater, Modified) package manager.

To remove a package from CentOS, use the following yum commands:

yum remove [package_name]

OR

yum erase [package_name]

In the following example, we deleted the Apache web server package, filed under the name httpd.x86_64, using the yum command.

Before removing, the command prompt asks for the root (or sudo user) password, and confirmation that you want the software deleted.

Type in y (for yes) and press Enter. If you have changed your mind, press n (for no) and then Enter.

Finally, the output informs you that the process is complete and shows you which package has been deleted.

software removed from centos with yum remove command

Note: Only root users and users added to the sudousers group have permission to install and remove packages in CentOS.

How to Remove Packages with Dependencies Using Yum

Package dependencies are binaries, libraries, and modules on which software rely on. When installing software, it will automatically download and store the required dependencies.

In most cases, deleting software from the local package manager will also erase its dependencies (unless other programs require them).

Still, there are instances in which these dependencies have to be removed manually.

To remove a package and erase all the unneeded dependencies use the following command:

yum autoremove [package_name]

Note: When a user installs a package, YUM downloads and stores it in /var/cache/yum. However, packages remain in cache even after they’ve been installed and removed. In time, the stored cache may take up too much disk space or cause issues due to corrupt metadata. To reclaim disk space, be sure to clean the YUM cache.

Alternatively, you can alter the yum configuration file  to automatically remove package dependencies when deleting a package with the yum remove or yum erase commands.

Start by opening the yum.conf file with a text editor of your choice:

vi /etc/yum.conf

Then, add the following line to the file:

directive clean_requirements_on_remove=1
edit yum confi file for autoremove

Save and exit the file.

How to Find Specific File in CentOS

In case you need to delete a package but are unsure of its exact file name, you can use one of the following two commands:

yum list- | grep [package_name]

OR

rpm -qa | grep [package_name]

The output will list all installed packages with the specified phrase found in the file name.

As you can see in the image below, httpd appears in the following packages (and dependencies):

find package name in centos

After you have the exact name of the package you want to erase, you can uninstall it from your CentOS system.

For more options on listing packages on CentOS read our detailed tutorial.

Conclusion

After reading this tutorial, you should now know how to remove packages and dependencies to free up space taken up by redundant programs.

You also know how quickly find specific packages or files you want to delete.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?