0

I am using Ubuntu 18.04. I have a condition where I install using command apt-get install package_name which installs the package along with all of its dependencies.

When I try to uninstall the same package using command apt-get autoremove --purge package_name it uninstalls most of the dependencies but not all. On the other hand, when I try to uninstall a package using aptitude it is working fine, – e.g. uninstalling using apt-get autoremove uninstalls 55 dependencies (not removing all dependencies), but uninstalling using aptitude uninstalls 61 dependencies (which is correct).

Do you have any idea if I am going wrong with apt-get autoremove command or any help understanding why apt-get autoremove uninstalls less packages than aptitude does?

Output of sudo apt-get autoremove --purge package_name and sudo aptitude purge package_name:

$ sudo apt-get autoremove --purge package_name
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
 package_name* dependency1* dependency2* dependency3* dependency4* dependency5*
  dependency6* dependency7* dependency8* dependency9* dependency10*
  dependency11* dependency12* dependency13* dependency14* dependency15*
  dependency16* dependency17* dependency18* dependency19* dependency20*
  dependency21* dependency22* dependency23* dependency24* dependency25* 
  dependency26* dependency27* dependency28* dependency29* dependency30* 
  dependency31* dependency32* dependency33* dependency34* dependency35* 
  dependency36* dependency37* dependency38* dependency39* dependency40* 
  dependency41* dependency42* dependency43* dependency44* dependency45* 
  dependency46* dependency47* dependency48* dependency49* dependency50* 
  dependency51* dependency52* dependency53* dependency54* dependency55* 
0 upgraded, 0 newly installed, 55 to remove and 222 not upgraded.
After this operation, 727 MB disk space will be freed.
$ sudo aptitude purge package_name
The following packages will be REMOVED:
  package_name{p} dependency1{u} dependency2{u} dependency4{u} dependency5{u}
   dependency6{u} dependency8{u} dependency9{u} dependency10{u}
   dependency11{u} dependency12{u} dependency13{u} dependency14{u} dependency15{u}
   dependency16{u} dependency17{u} dependency18{u} dependency19{u}
   dependency21{u} dependency22{u} dependency23{u} dependency24{u} dependency25{u} 
   dependency26{u} dependency27{u} dependency28{u} dependency30{u} 
   dependency31{u} dependency32{u} dependency33{u} dependency34{u} dependency35{u} 
   dependency36{u} dependency38{u} dependency39{u} dependency40{u} 
   dependency41{u} dependency42{u} dependency43{u} dependency44{u} dependency45{u} 
   dependency46{u} dependency47{u} dependency48{u} dependency49{u} dependency50{u} 
   dependency51{u} dependency52{u} dependency53{u} dependency54{u} dependency55{u}
   dependency56{u} dependency57{u} dependency58{u} dependency59{u} dependency60{u} dependency61{u}
 0 packages upgraded, 0 newly installed, 61 to remove and 222 not upgraded.
 Need to get 0 B of archives. After unpacking 1,133 MB will be freed.
  • @user535733 Sorry, but will not be able to give exact names of dependencies due to some policy. – Pulkit Lall Dec 17 '18 at 6:53
3

aptitude is more aggressive than apt-get about resolving package dependencies. aptitude remembers which packages were explicitly requested and which packages were only installed due to dependencies. It will automatically uninstall packages which were not explicitly requested when they are no longer needed.

apt-get treats packages requested explicitly and their dependencies the same. apt-get autoremove doesn't remove packages installed only as dependencies, it removes orphaned dependencies. It can't tell whether a left over package was installed with intent or as a dependency so it leaves it, whereas aptitude would know and remove it.

Source: revised from https://unix.stackexchange.com/questions/767/what-is-the-real-difference-between-apt-get-and-aptitude-how-about-wajig/772#772

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.