Here in this tutorial, we will discuss the ways we can use to uninstall Debian packages from Ubuntu Linux using the DPKG or APT.
If you want to remove a program on Linux Ubuntu, there are two different approaches – one is using its graphical Software Center and the other with the help of a command terminal. However, we cannot uninstall all the packages via Software Center such as the Apache web server. Nevertheless, in this guide, we will show you how to use both methods.
How to Remove or Uninstall packages in Ubuntu
To remove packages we should have system administrator right or in simple language a user with sudo access in Linux.
#1st Method using GUI Software center
Uninstall Program in Ubuntu via Software Center
Click the Software Center icon on the left to open it. Then go to the “Installed” tab and select the program you want to remove.
Click the “Bin icon” to confirm the uninstallation.
![Uninstall Program in Ubuntu via Software Center Uninstall Program in Ubuntu via Software Center](https://www.how2shout.com/linux/wp-content/uploads/2022/08/Uninstall-Program-in-Ubuntu-via-Software-Center.png)
Now click on the Uninstall when a pop appears for it. After that enter your password and click on “Authenticate“. The uninstallation of the program will begin. Soon it will be completed.
![Root password to uninstall Linux app Root password to uninstall Linux app](https://www.how2shout.com/linux/wp-content/uploads/2022/08/Root-password-to-uninstall-Linux-app.png)
#2nd Method: Delete Program in Ubuntu via Terminal
There are two command line tools we can use to remove a package in Ubuntu one is the systems default package manager called APT and the other is a command tool DPKG.
Well while removing a package we can also remove the associated libraries or packages called dependencies, if not used by any other program and not required anymore.
Use APT to remove packages on Ubuntu
Most of the time to install packages using the repository on Ubuntu we use an APT package manager. But we can use the same to remove the installed packages as well.
Remove only package
So, if you just want to remove an installed package using the APT, the command syntax will be:
sudo apt remove package-name
For example, let’s say you want to uninstall the VLC media player if installed. The command will be:
sudo apt remove vlc
Uninstall package plus dependencies
Well, those who also want to remove both the package and unused dependencies required by it, can go for the below APT command syntax:
sudo apt auto-remove package-name
But the above command will not remove the global configuration files and directories used by that particular package you are uninstalling.
Note: For Uninstalling only the unused dependencies, the users can use:
sudo apt autoremove
Remove the package Completely
Some of us might want to remove the install software package completely along with its configuration files and directories so that we cannot only free some of our hard drive space but also stop the misbehaving with certain programs. The command syntax for that will be:
sudo apt autoremove --purge package-name
In the above command syntax, autoremove
will uninstall dependencies and package while --purge
option will clear the residual configuration files and directories.
Use the DPKG tool to uninstall packages
The next method is using of DPKG tool to remove packages on Ubuntu Linux systems. DPKG is an alternative tool on Debian and Ubuntu along with the Linux distros based on them to install and uninstall packages.
If you want to use the DPKG tool instead the APT, the command syntax for that is:
dpkg -r package-name
Of course, replace the “package-name” with the actual package you want to remove. For example, if you have installed VLC and want to remove it using DPKG then the command will be:
sudo dpkg -r vlc
In the same, if you want to use the DPKG to completely remove the tool, its unused dependencies, and configuration files + directories then use the purge command of it.
dpkg -P package-name
Command line options for dpkg
Short option | Long option | Description |
-i | --install |
Installs the .deb package passed as an argument (filename or with folder name option). -R |
--configure |
Attempts to finish installing packages that have not yet been configured. Either the package names can be passed as arguments or the option to process all packages is still to be configured. If a package that has already been installed correctly is to be reconfigured, dpkg-reconfigure must be used. -a --pending |
|
-r | --remove |
Removes the named package passed as an argument. Important: The name of the package, not the file name, must be specified. Any configuration files created by the program are retained. |
-l | --list |
Calls dpkg-query and outputs a list of status, version, and a brief description of the package. Instead of the name, a regular expression can also be specified. If no argument is passed, all installed packages are listed. This option is also available for unprivileged users. (From 20.04 a pager is used; leave with Q .) |
-P | --purge |
Removes the mentioned package including the configuration files. |
-R | –-recursive |
Instead of a path to a .deb, a directory can also be specified, the selected operation is then applied to all packages in the directory. -R |
-L | --listfiles |
Calls dpkg-query and outputs a list of files contained in the package. |
-S | --search |
Calls dpkg-query to output which packages contain files that match the specified search pattern. |