How can you completely remove a package?
Solution 1
This is a very general answer to the question about the effects of purging packages. For advice specific to your situation, you'll have to edit your question to include additional information--in particular, the complete and exact text of the error message you are getting.
Removing packages with sudo apt purge ...
or sudo apt --purge remove ...
will remove them and all their global (i.e., systemwide) configuration files. This is usually what people mean when they talk about completely removing a package.
But that doesn't mean your system is the same as it was before the package was installed. In particular:
This does not remove packages that were installed as dependencies, when you installed the package you're now removing. Assuming those packages aren't dependencies of any other packages, and that you haven't marked them as manually installed, you can remove the dependencies with
sudo apt autoremove
or (if you want to delete their systemwide configuration files too)sudo apt --purge autoremove
.-
This does not remove non-systemwide configuration files. Specifically, it does not remove user-specific configuration:
-
It does not remove the configuration files and directories located in users' home directories (or in the
.config
subdirectory of their home directories), created by the software the package provides.- If these files/folders are not stored in
.config
, they usually start with a.
themselves. Either way, you can see them withls
by using the-a
or-A
flag, and you can see them in Nautilus and most other file browsers/managers by pressing Ctrl+H or going to View > Show Hidden Files.
- If these files/folders are not stored in
It does not reverse changes made to existing user-specific configuration files.
It does not remove new
gconf
ordconf
keys, or reverse anygconf
ordconf
configuration changes.
-
Using
purge
or--purge remove
instead ofremove
does not reverse changes to existing systemwide configuration files provided by other packages or created manually by the user. However, sometimes such changes are undone by uninstalling the package (whether or not it's apurge
rather than aremove
).
Solution 2
Use the command:
sudo apt-get purge --auto-remove packagename
It will purge required packages along with dependencies that are installed with those packages. The --auto-remove
option works similar to sudo apt-get autoremove
.
Solution 3
You first check out for the name of the package you want to remove:
dpkg --list
Then remove the given package
sudo apt-get remove package_name
Purge any related code
sudo apt-get purge package_name
Then Autoremove
sudo apt-get autoremove
Finally, do a clean so you check everything is correctly removed
sudo apt-get clean
You would like to check at the packages list whether the one you wanted to remove is not listed anymore, but it is optional.
Have a nice day,
Solution 4
1. Remove a package:
Get the package complete name:
dpkg --list | grep partial_package_name*
Remove the package:
sudo apt-get remove package_name
Remove all the dependencies:
sudo apt-get purge package_name
Remove the unneeded packages that were once installed as a dependency:
sudo apt-get autoremove
Remove the retrieved packages from the local cache:
sudo apt-get autoclean
Check that it was completely removed:
dpkg --list | grep partial_package_name*
2. Remove a Snap:
Using remove command:
sudo snap remove package_name
Solution 5
Better keep track of extra dependency packages installed while you are installing one.
The following extra packages will be installed:
libgssglue1 libnfsidmap2 libtirpc1 nfs-common rpcbind
If you remove original package only, the dependency package may remain.
So you have to manually remove each one using
apt-get purge package_name
Related videos on Youtube
user1012451
Updated on September 18, 2022Comments
-
user1012451 almost 2 years
I am trying to do a clean install of the
octave3.2
package.To do this, I removed it, then tried to reinstall it.
When I reinstalled, an error occurred. It could be a bug in the package, but I want to make sure I have everything removed so that I can do a clean install.
Is it enough to do this?
sudo apt-get --purge remove octave3.2
-
Luke Taylor over 8 yearsHow can I get a list of these packages if my console doesn't scroll up far enough
-
Harikrishnan over 8 years@LukeTaylor
apt-get install package_name > output
Thenless output
to see all output with scrolling. -
Kerem Ersoy almost 7 yearsMay be it would be safer to run the command as : dpkg --get-selections | grep PACKAGE_NAME | awk '{ print $1}' First and then run it with xargs is a better practice so that the user would see what would be deleted as a result of the command.
-
T.Todua about 5 yearsthis solved my problem, especially with certbot
-
starriet almost 3 yearswhat's the difference between this and @pl_rock 's answer?
-
Muhammad Tariq over 2 yearsThis answer is more clear and stepwise.
-
Admin about 2 yearsLife saver... I was having trouble installing mariadb after removing mysql.. the purge worked like a charm