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
  • Could one reinstall the package and pay attention to the package OR dependencies list.. ?
    – user309924
    Commented Jul 28, 2014 at 11:36
  • 1
    Recommended to visit this
    – Pandya
    Commented Oct 3, 2014 at 16:03
  • Maybe this post about manually deleting MS Teams provides some inspiration.
    – Mat D.
    Commented Feb 4, 2022 at 9:48

10 Answers 10


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 with ls 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.
    • It does not reverse changes made to existing user-specific configuration files.

    • It does not remove new gconf or dconf keys, or reverse any gconf or dconf configuration changes.

  • Using purge or --purge remove instead of remove 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 a purge rather than a remove).

  • After all the operations, I can still see large number of images in the 'un' status after executing the dpkg -l linux-image* command, here is one example line "un linux-image-5.11.0-27-generic <none> <none> (no description available)". my /boot is running out of space; not sure these listing are still taking up space. Trying to free up some space did not make much progress.
    – Kemin Zhou
    Commented May 22, 2023 at 16:35

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.

  • 1
    this solved my problem, especially with certbot
    – T.Todua
    Commented May 11, 2019 at 14:25
  • Life saver... I was having trouble installing mariadb after removing mysql.. the purge worked like a charm Commented Apr 25, 2022 at 10:25
  • You Burned me! This uninstalled removed everything!!!
    – Spar
    Commented Mar 30, 2023 at 9:51
  • @Spar is that a good thing or are you saying it caused a problem? Commented Jul 13, 2023 at 19:07

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,

  • what's the difference between this and @pl_rock 's answer? Commented Sep 18, 2021 at 1:29
  • 2
    This answer is more clear and stepwise. Commented Dec 21, 2021 at 9:12

Remove a deb 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*

Remove a Snap package

Using remove command:

sudo snap remove package_name

sudo snap remove package_name

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
  • 1
    How can I get a list of these packages if my console doesn't scroll up far enough Commented Jan 19, 2016 at 18:27
  • 1
    @LukeTaylor apt-get install package_name > output Then less output to see all output with scrolling. Commented Jan 20, 2016 at 3:34

Instead of removing auto-installed dependent packages manually, use the following instead:

 zanfilip@zanfilip-VPCEB3L0E:~/jp/eclipse$ sudo apt-get --purge autoremove
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages will be REMOVED
      libupstart1* linux-headers-3.16.0-30* linux-headers-3.16.0-30-generic*
      linux-image-3.16.0-30-generic* linux-image-extra-3.16.0-30-generic*
    0 to upgrade, 0 to newly install, 5 to remove and 23 not to upgrade.
    After this operation, 279 MB disk space will be freed.
    Do you want to continue? [Y/n] 


If you want to remove some secific packages you can use these commands:

dpkg --get-selections | grep PACKAGE_NAME | awk '{ print $1}'| xargs apt-get -y --purge autoremove

don't forget the "-y" switch because otherwise apt-get would keep asking about removing the individual packages and won't remove anything.

  • 2
    This could be useful but could also be destructive: It could easily match a package you didn't really want removed, and delete its config without confirmation! Fortunately since package names never contain a space, we can turn it around and drop the -y: apt-get --purge autoremove $(dpkg --get-selections | grep PACKAGE_NAME | awk '{ print $1}'). That would be somewhat safer. Commented Dec 25, 2015 at 8:11
  • May 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. Commented Sep 9, 2017 at 23:28

Another option you have, is using the debfoster package. This will interactively find and suggest packages for removal (and purge) along with dependant packages.

sudo apt install debfoster
sudo debfoster
# and optionally remove debfoster too
sudo purge debfoster

If you're using snap you can remove a package using:

$ sudo snap remove <package>

Application code, its run time dependencies and associated user data are all cleaned up. If your snap declared a service, they will as well be shut down and removed.


Before uninstalling the software package, you must first find the exact package name. To get a list of all installed packages on your system type:

sudo apt list --installed

To remove an installed package, run the following command:

sudo apt remove package_name

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .