Share your love
Completely Remove a Package From Ubuntu / Debian – 2 Easy Methods
In this guide, you will learn to Completely Uninstall and Remove a Package From Ubuntu / Debian from the Command Line Terminal. You may want to completely remove packages from your Ubuntu and Debian distros for several reasons. The common reasons for removing a package include:
- Free up Disk Space: Once you completely remove a package, it will remove all the associated files. This will help you to free up disk space on your server.
- Remove Unused Dependencies: Sometimes, when you remove a package, its dependencies might no longer be needed by any other installed software. Removing the package completely allows you to clean up these unnecessary dependencies.
- Security and Maintenance: Removing unused packages reduces the attack and potential vulnerabilities on your server. Additionally, it makes system maintenance easier by keeping only the necessary software installed.
Now you can follow the steps below provided by the Orcacore website to remove packages from your Debian-based distros completely by using the terminal command line interface.
Table of Contents
Learn To Completely Remove a Package From Ubuntu / Debian
To Completely Remove a Package From Ubuntu / Debian, you must log in to your Debian-based distro such as Ubuntu 22.04 and Debian 12 as a non-root user with sudo privileges. Then, follow the steps below to complete this guide.
Method 1 – Uninstall a Package by Using APT on Ubuntu and Debian
As you must know, APT is the default package manager in Ubuntu and Debian. You can simply use the APT command to remove a package. To do this, you can run the command below:
sudo apt remove package-name
This will uninstall the package itself and won’t remove the related files. To Completely Remove a Package From Ubuntu / Debian, you can use the following command:
sudo apt purge package-name
Also, you need to free up the unused dependencies by using the following command:
sudo apt autoremove -y
Finally, you can clear the cache in your Ubuntu and Debian servers with the command below:
sudo apt clean
Method 2 – Uninstall a Package by Using dpkg on Ubuntu and Debian
As you may know, another package manager in Debian and Ubuntu is dpkg. It is used for installing, removing, and providing information about .deb packages.
If you have a deb package on your server, you can simply remove it by using the command below:
sudo dpkg -r package-name
This will not remove all the related files and dependencies. To completely remove the deb package, you can use the following command:
sudo dpkg -P package-name
With this command, you can remove all files and dependencies and free up the disk space.
That’s you are done.
Conclusion
At this point, you have learned to Completely Remove a Package From Ubuntu / Debian Terminal by using APT and dpkg. This is useful for freeing up disk space on your server and getting rid of unused files and dependencies. Hope you enjoy it.
Also, you may like to read the following articles:
Install RPM Packages on Ubuntu 22.04
Install a Package on Ubuntu without Internet – APT Offline
Fix Issue: Can’t Upgrade Packages on Ubuntu
List Installed Packages on Ubuntu
Install XFCE or XUbuntu Desktop on Ubuntu 20.04
FAQs
What’s the difference between remove and purge commands in Ubuntu / Debian?
As you saw in the above guide on Completely Remove a Package From Ubuntu / Debian, the remove command deletes the package but keeps its configuration files, so if you reinstall, your settings will remain. The purge command deletes both the package and its configuration files, resetting it to its default state if reinstalled.
How do I know if a package is completely removed From Ubuntu / Debian?
After running the following commands:sudo apt purge && sudo apt autoremove
You can check if files are left by running:dpkg -l | grep [package-name]