Must - Read for Beginners: Ubuntu Software Uninstallation (remove vs purge)

After installing software on an Ubuntu system, uninstallation is a common operation, but beginners often get confused by the differences between the remove and purge commands. Many people assume that uninstalling software means “completely removing” it, but these two commands behave very differently. Using the wrong one can lead to leftover configuration files or accidental deletion of important settings. Today, we’ll clarify their differences and usage scenarios in the simplest way possible.

First, Understand the Basics: How to Uninstall Software on Ubuntu?

Ubuntu uses the apt tool to manage software packages (similar to Windows’ “App Store”). Software installation is done with apt install, while uninstallation mainly uses two commands: apt remove and apt purge. Both commands require administrative privileges, so prefix them with sudo (e.g., sudo apt remove package-name).

1. apt remove: Removes Only the Software, Keeps Configuration Files

Purpose:

remove is the most commonly used uninstall command. It only removes the software package itself but retains the software’s configuration files (e.g., interface settings, account passwords you previously configured).
For example: If you installed the VLC video player with apt install vlc, running apt remove vlc will delete VLC, but your custom settings like “auto-playlists” and “keyboard shortcuts” will remain. These settings will automatically restore if you reinstall VLC later.

Usage:

Command format: sudo apt remove package-name
Example: Uninstall VLC: sudo apt remove vlc
(Note: Ensure the package name is correct. For Chinese software, the package name may differ. If unsure, use apt search keyword to check the package name first.)

2. apt purge: Thorough Uninstallation, Removes All Configuration Files

Purpose:

purge is more aggressive than remove. It removes the software package AND ALL related configuration files and dependency files.
Using VLC as an example again: After running apt purge vlc, the VLC program, interface settings, playlists, and all related files will be deleted—effectively “resetting” it to the state when it was first installed.

Usage:

Command format: sudo apt purge package-name
Example: Completely uninstall VLC: sudo apt purge vlc
(If you want to restore settings later, you’ll need to reinstall VLC and manually reconfigure it.)

3. What Problems Can Leftover Configuration Files Cause?

If you use remove without cleaning up leftover configuration files, issues may arise:
- When reinstalling, the software may automatically restore previous settings (sometimes beneficial, e.g., your preferred interface layout).
- However, if the software is upgraded, old configurations may conflict with the new version, causing errors like crashes or lag.

Using purge deletes all residual configurations, ensuring a “clean uninstall,” but you’ll need to reconfigure the software after reinstallation.

4. How to Check If Uninstallation Was Thorough?

To confirm if software was completely removed, use these commands:
- Check if the package exists: dpkg -l | grep package-name (e.g., dpkg -l | grep vlc; no output means it’s uninstalled).
- Check detailed package status: dpkg -s package-name (if it shows “Status: uninstalled,” the package is completely removed).

5. When to Use remove vs. purge?

  • Use remove: When you want to quickly uninstall software but retain configurations (e.g., if you plan to reinstall it later and want to keep previous settings).
  • Use purge: When you want a complete cleanup (e.g., after uninstalling software you no longer use, to avoid leftover configurations taking up space or interfering with new installations).

6. Extra Reminder: Do Not Delete System Software!

Always verify the package name before uninstalling to avoid mistakes. For example, avoid accidentally deleting python or kernel (system dependencies), as this may cause system failures. If unsure, use apt search to confirm the package name before uninstalling.

Summary

  • remove: “Lightweight uninstallation”—removes the software but retains configuration files.
  • purge: “Thorough uninstallation”—removes the software, configuration files, and dependencies.
  • If unsure, start with remove; if leftover configurations are detected, use purge to clean them up.

Now you should understand the difference! Practice uninstalling a test package to become more comfortable with these commands.

Xiaoye