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”:
[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.
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:
- Open the Ubuntu terminal.
- Write the following command to remove the vlc package:
sudo apt-get remove vlc
EXPLANATIONA 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’ there and press ENTER. Finally, the vlc package has been removed from your Linux system.
- 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
EXPLANATION- apt: Advanced package tool to install, uninstall, and manage packages in Debian-based distros.
- show: Shows dependencies and config files of a requested package.
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:
sudo apt-get purge vlc
- purge: Removes a package with affiliated configuration 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:
- Open the Ubuntu terminal.
- Run this command to remove all the unused dependencies and config files:
sudo apt-get --purge autoremove
EXPLANATION- autoremove: Removes the unnecessary package automatically.
After executing the command if there are any unnecessary dependencies and config files, will be removed.
- Now run this code to update the packages:
sudo apt-get update
EXPLANATION- update: Updates the installed packages.
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.
Then type ‘y’ to complete the removal procedure using the ‘apt-get remove –purge’ Command.
Lastly, the vlc package along with all unneeded config files, libraries, and binaries has been deleted from your Linux system.
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 |
|
|
Method 2 |
|
|
Method 3 |
|
|
Method 4 |
|
|
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.
Conclusion
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
Related Articles
- How to Uninstall RPM in Linux [2 Simple Cases]
- How to Uninstall a YUM Package [2 User-Friendly Cases]
- How to Remove a Specific Version Using YUM [2 Easy Methods]
- How to Force Remove a Package Without Dependencies Using Yum [2 Methods]
- How to Remove Apt-key in Linux [3 Practical Methods]
- How to Remove Package and Dependencies Using dpkg [4 Cases]
<< Go Back to Uninstall Packages in Linux | Package Management in Linux | Learn Linux Basics
FUNDAMENTALS A Complete Guide for Beginners