How to modify settings in 'apt.conf' file that no longer exists in 12.04?
I would like to add settings to the file apt.conf
, but I realized that it was replaced by a folder called etc/apt/apt.conf.d/
.
How can I configure with this new model?
It is best to create your own user file in /etc/apt/apt.conf.d
so you can guarantee that it won't be overwritten by package updates. Rather than adding to existing files in the directory, create your own general file called 99mysettings
with
sudo touch /etc/apt/apt.conf.d/99mysettings
It is labelled with a 99
so that your settings are run last and so override any of the same values for the specified settings present in other files in the directory.
Then to edit your file run
sudo nano /etc/apt/apt.conf.d/99mysettings
and then, for example, you could add the following (although not usually recommended) configuration item:
APT::Install-Suggests "true";
If you wanted apt to stop installing recommended packages (again not usually the best decision) you could use
APT::Install-Recommends "false";
The syntax of these commands differs to how the man page will describe how entries for the older apt.conf
should be set up; previously APT::GET::Install-Suggests "true";
would have been the syntax, but that will not work for the example above.
The man page will give you an indication of the general settings available, so please enter man apt.conf
or see the Ubuntu manpages online. However, the best source for apt configuration settings is the Debian Handbook, available here online or as a complete pdf here, and it contains very useful information that is mostly applicable for Ubuntu as well.
From versions newer than Gutsy, the file /etc/apt/apt.conf has been replaced by /etc/apt/apt.conf.d/proxy (create it if needed), with the same structure.
The apt.conf
file which contains configuration for APT is by default located in /etc/apt/
.
To check what's under apt
directory, do the following in terminal:
cd /etc/apt
ls
The apt.conf
file should be listed after the ls
command.
However, if it does not exist, you can create it by running the following command:
gksu gedit apt.conf
(Make sure the present working directory is /etc/apt
, if not, then cd
to /etc/apt
first.)
This will ask for your password and launch gedit
allowing you to create your apt.conf
file.
You can also use:
sudo nano apt.conf
Find the existing configuration by apt-config dump
command, e.g.:
apt-config dump | grep -we Recommends -e Suggests
Change the values and add into /etc/apt/apt.conf.d/99somefile
(a new file). The number before file gives priority (lower runs earlier, higher runs latest).
Here is the example disabling APT::Install-Recommends
and APT::Install-Suggests
:
apt-config dump | grep -we Recommends -e Suggests | sed s/1/0/ | sudo tee /etc/apt/apt.conf.d/99norecommend