Tip: Tell apt-get not to install “recommends” packages in Debian Linux
Purpose: If you are using Debian Lenny and are installing software packages using apt-get then you might have noticed the new version of apt-get in Lenny installs the “recommends” packages automatically thus increasing the number of packages installed on your computer. The “apt-get” in Debian Etch (4.0) did not use to install “recommends” packages. In this post, we will see how we can permanently tell apt-get NOT to install “recommends” packages. For those of you who are not sure about Debian’s “depends”, “recommends” and “suggested” packages, please refer to this doc. This is important if you have limited storage space on your system, say for example an embedded system.
The Problem:
Let’s see how to do this with an example. Suppose we need to install the perl package. If you do:
# apt-get update
# apt-get install perl
You will get something like this:
# apt-get install perl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
perl-doc perl-modules
Suggested packages:
libterm-readline-gnu-perl libterm-readline-perl-perl groff
The following NEW packages will be installed:
perl perl-doc perl-modules
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 15.9MB of archives.
After this operation, 41.4MB of additional disk space will be used.
Do you want to continue [Y/n]?
Notice that if you go ahead with this (say Y) you will end up using 41.4 MB of disk space. However if you look here, you can see that the package perl-doc is optional because it is just a “recommends” package and not a “depends” package.
Red = Depends
Green = Recommends (optional)
Blue = Suggests (optional)
The Solution:
Create or Edit the file /etc/apt/apt.conf file and add the following contents to it:
// Recommends are as of now still abused in many packages
APT::Install-Recommends "0";
APT::Install-Suggests "0";
Now save the file and run:
#apt-get update
# apt-get install perl
Now you should get something like this:
# apt-get install perl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
perl-modules
Suggested packages:
libterm-readline-gnu-perl libterm-readline-perl-perl
Recommended packages:
perl-doc
The following NEW packages will be installed:
perl perl-modules
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 7731kB of archives.
After this operation, 27.5MB of additional disk space will be used.
Do you want to continue [Y/n]?
If you noticed now that the total size of the installation reduced from 41.4 MB to 27.5 MB i.e. almost 33% less disk space will be used now. This is very helpful if you storage space is a concern for you. Also you can see that “apt-get” now lists “recommended” package as a separate entity above (see green above).
Temporary Solution:
Also if you do not want to create the “apt.conf” file because you do want “apt-get” to install “recommends” package but sometime you don’t want to install the “recommends” packages selectively for a particular package install then you can give the following command:
# apt-get --no-install-recommends install perl
and it will have the same effect as having those lines “apt.conf” file but you will have to give the flag “–no-install-recommends” every time you use apt-get to install any package.
As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.
Also don’t forget to rate this post below.

Free Email Subscription









January 11th, 2009 at 12:09 pm
hmmm… in ubuntu also, aptitude installs recommended packages. debian went ubuntu way, wtf?!
Reply to this comment
Kushal Reply:
January 11th, 2009 at 11:10 pm
HI LMZ,
The post talks about apt-get. I don’t use Aptitude much but I remember that aptitude has been installing “recommended” packages since a long time. Not sure who went whose way.
Thank you for your comment.
Reply to this comment
March 21st, 2009 at 4:06 pm
[...] Tell "apt-get" not to install "recommends" packages – Debian (and Ubuntu) will install recommends packages by default. Turn it off to save space [...]
July 5th, 2009 at 6:28 am
if you use aptitude. you want to use the option “–without-recommends”
Alternatively, you can do the configuration file change, and use the option “–with-recommends” to reverse the behavior.
Really, one should be using aptitude nowadays. Not much reason to use apt-get directly, and plenty of reasons to use aptitude (such as better dependency handling)
Reply to this comment
January 17th, 2010 at 6:39 am
Thanks! Just what I was looking for!
Reply to this comment
March 3rd, 2010 at 11:54 pm
Thanks LMZ and Draeath for the apt-get and aptitude commands!
Reply to this comment