apt vs aptitude

4 minute read


Both, apt (apt-get, apt-cache) and aptitude are commands for package administration from the text on Debian and spin-off distros like Ubuntu. In fact, both check repositories according to the /etc/apt/sources.list and use the package gotten from those repositories. But many people still use apt-get for installing packages even though aptitude is better. In deed, if you read tutorials and manuals on Internet many of them mention apt-get almost exclusively over aptitude.

Maybe this is because  apt-get was first and people got custom to use it. For example, the other day I was talking with a friend and I told him to switch to aptitude because it’s better than apt-get, and my friend answered me with a “Uhmm…I don’t have problems with apt. Any way, if apt works why to use aptitude?”. Well, lets’s why:

Dependencies

The answer is that aptitude has a better package dependency resolution than apt. In fact at installing a package with dependency conflicts, aptitude suggests solutions for that conflict, while apt-get doesn’t. On the other hand, apt-get can’t remove dependency from non using packages while aptitude can. In the following example I will install and uninstall a package called junior-games-card with apt-get and then with aptitude to show my point:

apt

Let’s install it with apt-get:

arthur:~# apt-get install junior-games-card  

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
 ace-of-penguins blt cdd-common junior-config junior-tasks pysol python-tk python2.4
 python2.4-minimal tcl8.4 tk8.4
Suggested packages:  
  blt-demo cdd-doc pysol-cardsets python-tk-dbg tix python2.4-doc python-profiler
  binfmt-support tclreadline
The following NEW packages will be installed:
  ace-of-penguins blt cdd-common junior-config junior-games-card junior-tasks pysol python-tk
  python2.4 python2.4-minimal tcl8.4 tk8.4**
0 upgraded, 12 newly installed, 0 to remove and 23 not upgraded.
Need to get 9363kB of archives.
  
After this operation, 30.9MB of additional disk space will be used.
Do you want to continue [Y/n]?

Now let’s uninstall it:

arthur:~# apt-get remove junior-games-card
  
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  pysol python2.4-minimal python2.4 junior-tasks blt python-tk junior-config tcl8.4 tk8.4
  ace-of-penguins cdd-common
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  junior-games-card**
0 upgraded, 0 newly installed, 1 to remove and 23 not upgraded.
After this operation, 61.4kB disk space will be freed.
Do you want to continue [Y/n]

Bad, bad…it just uninstalls _junior-games-card _but not its dependencies (and it should because not any other package is using them). I highlighted in red the warning message that apt-get shows if you want to remove the dependencies with the ‘autotoremove’ option, which I’m sure nobody knows about it.

aptitude

Now it’s aptitude’s turn:

arthur:~# aptitude install junior-games-card 
  
Reading package lists... Done  
Building dependency tree  
Reading state information... Done  
Reading extended state information  
Initializing package states... Done  
Reading task descriptions... Done  
The following NEW packages will be installed:
  ace-of-penguins{a} blt{a} cdd-common{a} junior-config{a} junior-games-card junior-tasks{a}
  pysol{a} python-tk{a} python2.4 {a} python2.4-minimal{a} tcl8.4{a} tk8.4{a}** 
0 packages upgraded, 12 newly installed, 0 to remove and 23 not upgraded.
Need to get 9363kB of archives. After unpacking 30.9MB will be used.
Do you want to continue? [Y/n/?]

Let’s uninstall it:

arthur:~# aptitude remove junior-games-card 
  
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
The following packages will be REMOVED:
  ace-of-penguins{u} blt{u} cdd-common{u} junior-config{u} junior-games-card junior-tasks{u}
  pysol{u} python-tk{u} python2.4{u} python2.4-minimal{u} tcl8.4{u} tk8.4{u}
0 packages upgraded, 0 newly installed, 12 to remove and 23 not upgraded.
Need to get 0B of archives. After unpacking 30.9MB will be freed.
Do you want to continue? [Y/n/?]

I’s evident which is more efficient: aptitude.

Using apt vs. aptitude

The dependencies is not the only issue. It turns out that using apt is more complicated than aptitude, because you have to remember the command combinations and options, while with aptitude you only need to remember the options. Let’s see this:

apt

Command Option Package name Description
apt-get update Get the package list from repositories
apt-get install junior-games-card Install package junior-games-card
apt-cache search junior-games-card Search package junior-games-card
apt-get upgrade junior-games-card Upgrade package junior-games-card
apt-cache show junior-games-card Show package junior-games-card description
apt-get remove junior-games-card Uninstall package junior-games-card , but leaving the config files
apt-get remove –purge junior-games-card Uninstall package junior-games-card , including the config files

aptitude

Command Option Package name Description
aptitude update Get the package list from repositories
install junior-games-card Install package junior-games-card
search junior-games-card Search package junior-games-card
upgrade junior-games-card Upgrade package junior-games-card
show junior-games-card Show package junior-games-card description
remove junior-games-card Uninstall package junior-games-card , but leaving the config files
purge junior-games-card Uninstall package junior-games-card , including the config files

Here you can see aptitude it’s easier to learn and use!

Want more?

If you are not convinced that aptitude is the better to use, check other stuff you are missing:

  • It offers access to all package versions
  • It has a log in the /var/log/aptitude file
  • It shows the result search in a more tidy eay than apt-cache (and it just look up in package names)
  • It can install recommedned packages automatically (see -r option on the manual)
  • It can install predifiened task (see man tasksel)

References:

Leave a Comment