How to Remove and Purge a Package Using “apt-get” [4 Methods]

A Complete Guide for Beginners Enroll Course Now

apt-get is basically an advanced package tool, mostly used in Debian-based Linux distributions such as Ubuntu, Kali Linux, Linux Mint, and so on. This front-end package management tool can install, remove, and purge any packages. While removing any package from the Linux system, the apt-get remove command only removes packages without unused dependencies and config files that may hamper the performance of your computer. In that case, apt-get purge is the savior. It not only removes packages but also their associated configuration files. I’ll walk you through the entire process to remove and purge with apt-get.

Process flow chart to remove and purge a package using “apt-get”:

Flowchart of the removing and purging procedure

[Distro Used Throughout the Tutorial: Ubuntu 22.04.1 LTS]

4 Easy Ways to Remove and Purge a Package Using “apt-get”

Deleting unnecessary files is essential as it can save a lot of storage space and therefore perform better. If you are working with Debian-based distros, you can use the apt-get package management tool to remove and purge a package. Here, I will show you 4 methods to remove and purge the vlc package using apt-get in Ubuntu.

You can read our Comparative Analysis of Methods to distinguish between these two methods and pick the best one for your needs.

Method 01: Removing a Package With “apt-get remove” Command

When you use the apt-get package manager to remove a package, it will just remove the package, not any dependencies and configuration files. In this section, I will explain to you how to remove a package using apt-get. Check the instructions carefully:

  1. Open the Ubuntu terminal.
  2. Write the following command to remove the vlc package:
    sudo apt-get remove vlc
    • sudo: Permits administrative privileges.
    • apt-get: Package management tool for Debian-based distributions to update, uninstall, and install packages.
    • remove: Removes software package.
    • vlc: Package name.

    Remooving vlc package alone using apt-get command

    A prompt that looks like the next picture will appear after you run this command asking you if you wish to proceed or stop.

    Type y to remove the vlc package alone using apt get

    Type ‘y’ there and press ENTER. Finally, the vlc package has been removed from your Linux system.

  3. Now you can check whether all the dependencies and configuration files still remain or not. In order to do that, run this command:
    sudo apt show vlc
    • apt: Advanced package tool to install, uninstall, and manage packages in Debian-based distros.
    • show: Shows dependencies and config files of a requested package.

    Showing dependencies, recommendations and suggestions of the vlc package after removing it

    In this image, you can see the dependencies of the vlc package. You can also check the recommendations, suggestions, and plug-ins after running this command.

Method 02: Removing a Package With “apt-get purge” Command

If you want to remove a package with its configuration files, you can get help from the apt-get purge command. This command is enough to remove your desired package with all the config files but dependencies will still remain. Follow the below command to purge the vlc package:

NOTE: Be careful when using the purge option as you are unsure of the configuration files you are eliminating, it may result in the loss of vital information.
sudo apt-get purge vlc
  • purge: Removes a package with affiliated configuration files.

removing vlc with config files using apt-get purge command

To confirm that the config files have been successfully removed after purging the vlc package, use Step 03 of Method 01 to examine the config files.

Method 03: Removing a Package With “apt-get –purge autoremove” Command

This command actually cleans up your system by removing all the installed packages that are no longer required. Additionally, it will remove the config files of the unused packages. Hence, to free up the computer space and run smoothly, use this command. Now, to know about the full process, read this section:

  1. Open the Ubuntu terminal.
  2. Run this command to remove all the unused dependencies and config files:
    sudo apt-get --purge autoremove
    • autoremove: Removes the unnecessary package automatically.

    purging and autoremoving all the unnecessary packages

    After executing the command if there are any unnecessary dependencies and config files, will be removed.

  3. Now run this code to update the packages:
    sudo apt-get update
    • update: Updates the installed packages.

    updating all the packages in the system using apt get

    Type the Ubuntu password to complete the updating procedure.

Method 04: Removing a Package With “apt-get remove –purge” Command

When you wish to remove a package with its libraries, binaries, and config files, you can use this command. And it is an irreversible procedure. So be careful before running it. Now, run this command to purge the vlc package with its libraries, binaries, and config files:

sudo apt-get remove --purge vlc
  • purge: Removes a package with affiliated configuration files.

removing and purging vlc package with config files, libraries, and binaries using apt get

Then type ‘y’ to complete the removal procedure using the ‘apt-get remove –purge’ Command.

typing y to give the permission to complete the process

Lastly, the vlc package along with all unneeded config files, libraries, and binaries has been deleted from your Linux system.

To confirm that the config files, libraries, and binaries have been successfully removed after purging the vlc package, use Step 03 of Method 01 to examine the config files.

Comparative Analysis of Methods to Remove and Purge a Package Using “apt-get”

In this section, I will show you the merits and demerits of each method to help you find the best possible method according to your preferences:

Methods Pros Cons
Method 1
  • Quick and easy uninstallation process.
  • Reduces the chance of data loss.
  • Incomplete uninstallation.
  • Wastes disk space.
Method 2
  • Offers complete and proper uninstallation.
  • Saves disk space.
  • Time-consuming.
  • Risk of potential data loss.
Method 3
  • Time saver.
  • Cleans up the whole system thoroughly.
  • Dependency might change.
  • Increased risk of essential package removal.
Method 4
  • Provides complete removal of a package.
  • Cleans config files, libraries, and binaries.
  • Irreversible action.
  • Having the risk of data loss.

I think this table helps to pick your ultimate method. Hear me out if you are still confused. Pick method 1 if you wish to remove just a package. However, if you want to remove a package with config files, choose method 2 or method 4. Moreover, to clean up your whole system, pick method 3.


I have explored 4 methods to remove a package using the apt-get package manager. You can select the apt-get remove command if the package doesn’t include configuration files; otherwise, use the apt-get purge command. Though it is not recommended to purge packages, it may cause some necessary data loss. So be aware before using this command and adhere to this article strictly.

People Also Ask

What's the difference between apt-get remove and apt-get purge?
Basically the apt-get remove command removes only the package file keeping the config files intact. On the other hand, the apt-get purge command deletes the package along with config files.
Can you undo purge?
No, you can’t undo purge once you run the command as it is an irreversible method.
What is apt-get update Linux?
In order to get details about the packages from all authorized sources, execute the ‘sudo apt-get update’ command.

Related Articles

<< Go Back to Uninstall Packages in Linux | Package Management in Linux | Learn Linux Basics

Rate this post
Mitu Akter Mou

Hello, This is Mitu Akter Mou, currently working as a Linux Content Developer Executive at SOFTEKO for the Linuxsimply project. I hold a bachelor's degree in Biomedical Engineering from Khulna University of Engineering & Technology (KUET). Experiencing new stuff and gathering insights from them seems very happening to me. My goal here is to simplify the life of Linux users by making creative articles, blogs, and video content for all of them. Read Full Bio

Leave a Comment