When you install a package on Ubuntu, the package manager installs the binary packages with all the other dependencies. In the future, when the package is no longer needed, you should uninstall it because loading the server with unneeded packages will slow down the server. Here is an easy guide to uninstall or remove packages from Ubuntu.
We will be using the command line (cli) method to uninstall or remove the packages
Prerequisite
- Ubuntu OS installed with Initial configuration done
- Root or a sudo user ready
Application management tools installed in Ubuntu are APT, DPKG, and Snap. We will see methods to uninstall or remove packages using these three.
Method 1 – Uninstall Packages with APT
Uninstalling packages using apt is simple. You have to follow the “apt remove” syntax to remove any package.
$ sudo apt remove {Package-name}
For Example
If you want to remove curl using apt, then you can use it as
$ sudo apt remove curl
Always keep in mind, that “apt remove” just removes the packages from the system but keeps the configuration file. In case you want to remove the package along with the configuration file, then you can use “apt purge” syntax
$ sudo apt purge {package-name}
For Example
If you want to completely remove curl with all its configuration files using apt purge, then you can use
$ sudo apt purge curl
You can even clear the package cache using the “apt clean” syntax
$ sudo apt clean
Method 2 – Uninstall Ubuntu Package with DPKG
To remove installed packages using DPKG you can use “dpkg -r” syntax
$ sudo dpkg -r {Package-name}
For Example
If you want to remove curl using DPKG, you can use
$ sudo dpkg -r curl
If you want to remove curl along all its dependencies using DPKG, then you can use
$ sudo dpkg -P {Package-name}
For Example
You want to remove curl along with all its dependencies using DPKG
$ sudo dpkg -P curl
Method 3 – Uninstall Ubuntu Packages with Snap
Snap is the most popular package management tool used in Debian-based Linux distros like Ubuntu. Since Snap contains all the dependencies on its own, you have to remove the package only.
To remove any package using Snap, you can use the syntax “snap remove”
$ sudo snap remove {Package-name}
For Example
If you want to remove curl using snap, then you can use
$ sudo snap remove curl
You can even see the list of installed packages using snap
$ sudo snap list
That’s all for now.