change cache location path for APT

When using apt, can I tell it to use other then /var/cache/apt location?
I tried adding the following line in /etc/apt/apt.conf:

% cat /etc/apt/apt.conf
Dir::Cache /home/apt

and re-run apt but it still writes in /var/cache/apt

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can add one of the following lines to any file inside /etc/apt/apt.conf.d/ or to /etc/apt/apt.conf:

Dir::Cache{Archives /home/apt/}
Dir::Cache::Archives /home/apt;

This will store all partially/full downloaded .deb files inside /home/apt.

Dir{Cache /home/apt}
Dir::Cache /home/apt;

This will store pkgcache.bin, srcpkgcache.bin inside /home/apt and all partially/full downloaded .deb files inside /home/apt/archives

Remember to add enough privileges to _apt user to that directory, so that everything works properly.

You can see the whole configuration of apt with apt-config dump, for example:

> apt-config dump | grep Dir::Cache
Dir::Cache "/home/apt";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x