How to Remove Packages from Old Version of CentOS

Abstract: Resolve leftover configuration files after yum remove on CentOS 7 by manually deleting residual data from system directories.

Created: 2026-08-02 by

Use the yum remove command followed by specific package names to uninstall software on CentOS 7. This action deletes the main files but leaves configuration data behind. To ensure a complete removal of associated settings and cached data, you must manually identify and delete residual configuration files from system directories after the initial package deletion.

Understanding Package Removal vs Purging

It is critical to understand that standard package managers like yum on CentOS 7 do not perform a "purge" operation in the same way Debian-based systems handle apt purge. When you execute a removal command, the package manager removes the binaries, libraries, and other files installed by the package. However, it intentionally preserves configuration files located in directories such as /etc. This design choice allows administrators to reinstall the software later without losing their custom settings. If your goal is to completely eliminate all traces of a package, including its configuration files, you cannot rely solely on the package manager. You must combine the automated removal with manual cleanup steps. This distinction is vital for server maintenance, disk space optimization, and ensuring no orphaned configuration files interfere with new installations or security audits. Many users confuse these two processes, leading to confusion when they expect a clean slate after running a simple removal script.

Executing the Removal Command

The primary tool for managing packages on CentOS 7 is yum. While newer versions of Linux distributions have moved toward dnf, CentOS 7 remains firmly rooted in the yum ecosystem. The command structure is straightforward and can be easily integrated into shell scripts for automation. To remove a single package, use the following syntax:
yum remove package_name
Replace package_name with the actual name of the software you wish to uninstall. For example, to remove the Apache web server, you would type:
yum remove httpd
When you run this command, yum will calculate the dependencies and display a list of packages that will be removed. It often includes the main package along with any dependent packages that are no longer required by other software. Review this list carefully. If there are critical dependencies you want to keep, you may need to adjust your approach or accept that those dependent packages will also be removed. After reviewing the list, confirm the action by typing y and pressing Enter. The system will then proceed to delete the specified files. If you prefer a non-interactive script, you can add the -y flag to automatically assume yes for all prompts:
yum -y remove package_name
This flag is essential for batch operations or cron jobs where user interaction is not possible. Always test this command in a staging environment first to ensure it does not remove critical system components unexpectedly.

Handling Dependencies and Residual Files

One common pitfall in package management is leaving behind orphaned dependencies. After removing a primary package, other packages that were installed as dependencies might remain on the system if they are still required by other software. To clean up these unused dependencies, you can use the autoremove feature.
yum autoremove
This command scans the system for packages that were installed as dependencies but are no longer needed by any currently installed software. It provides a safe way to reclaim disk space and reduce the attack surface of your server by eliminating unnecessary code. However, yum autoremove does not touch configuration files. As mentioned earlier, configuration files stored in /etc persist even after the binary files are gone. To find these residual files, you can search the /etc directory for directories or files named after the removed package. For example, if you removed httpd, you might look for:
  • /etc/httpd/
  • /var/log/httpd/
These directories contain logs and configuration settings. If you are certain you will never reinstall the software, you can manually delete these directories using the rm command. Be extremely cautious when deleting files in /etc, as incorrect deletions can break other applications that share similar naming conventions or rely on shared system configurations.

Scripting the Process

For system administrators managing multiple servers, automating this process is efficient. A simple bash script can iterate through a list of packages, remove them, and log the results. Below is an example of how such a script might look. Note that we avoid hardcoding paths like /usr/bin/yum to ensure compatibility across different system configurations where yum might be aliased or located differently in the path.
#!/bin/bash

PACKAGES=("pkg1" "pkg2" "pkg3")

for PKG in "${PACKAGES[@]}"; do
    echo "Removing $PKG..."
    yum -y remove "$PKG" &> /dev/null
    
    # Optional: Check if config files exist
    CONFIG_DIR="/etc/$PKG"
    if [ -d "$CONFIG_DIR" ]; then
        echo "Config directory found at $CONFIG_DIR. Manual review recommended."
    fi
done

echo "Removal process completed."
This script loops through an array of package names, executes the removal command silently, and checks for leftover configuration directories. It provides a basic framework that can be expanded with error handling and logging features for production environments.

Verifying Removal

After executing the removal commands, it is good practice to verify that the packages are indeed gone. You can use the yum list installed command to check if a package is still present.
yum list installed | grep package_name
If the package has been successfully removed, this command should return no results. If it still appears, the removal may have failed, or you might be looking at a metapackage that depends on other components. In such cases, investigate further to ensure the core functionality has been uninstalled. Additionally, check the system logs to ensure no errors occurred during the removal process. Logs are typically stored in /var/log/yum.log. Monitoring these logs helps in troubleshooting unexpected issues and maintaining a clear audit trail of system changes. For advanced setups, consider forwarding these logs to a remote server for centralized monitoring, as discussed in our guide on How to Forward /var/log/yum.log to Remote Logging Server using rsyslog.conf?. This ensures that even if local logs are rotated or deleted, you retain historical data for compliance and debugging purposes.

Frequently Asked Questions

Does yum remove delete configuration files?

No, the yum remove command only deletes the package files themselves. Configuration files located in /etc are preserved to allow for easy reinstallation. You must manually delete these files if you want a complete purge.

What happens to dependencies when I remove a package?

Dependencies that are still required by other installed packages will remain on the system. However, dependencies that are no longer needed can be removed using the yum autoremove command to free up disk space.

Can I automate the removal of residual config files?

While you can write scripts to delete known configuration directories, it is risky to automate this blindly. Different packages may store configs in various locations. It is safer to script the removal of binaries and manually verify or script the deletion of specific, well-known config paths.

Why does my yum command fail with 'Could not retrieve mirrorlist'?

This error usually indicates a network connectivity issue or a misconfigured repository source. Ensure your network interface is active and that your /etc/yum.repos.d/ files point to valid mirrors. Troubleshooting steps for this specific error are detailed in our guide on Troubleshooting Yum Installation Error: 'Could not retrieve mirrorlist' on CentOS 7.

Is yum erase different from yum remove?

No, yum erase and yum remove are synonymous commands. They perform the exact same function of uninstalling packages. You can use either interchangeably based on your preference or script consistency.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More