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.
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.
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]
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
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):
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.
原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/224096.html