15

I want to remove the package, but I forgot how I installed it through dpkg or apt-get

I try to check through dpkg-query -list | grep myPackage and apt list --installed | grep myPackage, but myPackage was shown on both.

so how can I tell whether the package was installed by dpkg or apt ?

In order to do the correct uninstall command, like: apt-get remove or dpkg -r

  • 7
    You can uninstall either way. – Pilot6 Feb 25 '17 at 12:19
28
  1. Compare the log of /var/log/apt/term.log, which is the log file generated by apt and /var/log/dpkg.log, which is the log file generated by dpkg. If you note a package name which can be found in /var/log/dpkg.log but not in /var/log/apt/term.log, it is very likely that you installed the package by dpkg that time.

  2. Please remember apt is a frontend for dpkg. Thus, it is recommended to remove any package by apt rather than dpkg, because apt will handle the dependency to remove those packages which will not be used by any other packages (, or mark them as "not use anymore" to let you remove them later. It depends on the exact apt options you actually use). However, it is no harm to you to remove your package by dpkg if you want. You will just likely leave many packages that you won't use anymore.

| improve this answer | |
  • Thanks for the comment @user535733. I edited the answer according to your comment. – tai271828 Feb 28 '17 at 8:46
21

Any package installed with APT is also installed with dpkg. APT calculates dependencies and fetches the packages, which are then unpacked and installed by dpkg.

If you can find your packages with APT, then you should use apt commands to uninstall them, because APT will calculate dependencies of the package and:

  • remove packages that depend on the package selected for removal
  • mark packages that are dependencies of the package selected for removal as no longer needed, so that they can be cleaned up with sudo apt autoremove
| improve this answer | |
4

It does not matter how to uninstall a package.

dpkg also requires dependencies that are set in the package.

When you run apt remove it starts dpkg to remove the package.

When you install a package using dpkg and it requires some dependenices, the installation process stops with an error. You can fix it by sudo apt install -f that will install dependencies if they are available. In this case apt autoremove will work the same way.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.