LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-16-2019, 11:49 PM   #1
young_jedi
Member
 
Registered: Mar 2019
Posts: 37

Rep: Reputation: Disabled
How to change where apt-cache caches packages?


apt-cache by default caches packages in '/var/cache/apt/archives', but I want to change it to somewhere else on the system.. The following is what I already tried, except it doesn't work...

Code:
apt-cache -o Dir::Cache="~/some/other/cache"

Last edited by young_jedi; 04-16-2019 at 11:51 PM.
 
Old 04-17-2019, 12:12 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

apt-cache doesn't cache anything. It queries the cache maintained by apt. So, to change the location of the cache itself I think you'd need to edit your /etc/apt/apt.conf file.

Evo2.
 
1 members found this post helpful.
Old 04-17-2019, 01:16 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by young_jedi View Post
apt-cache by default caches packages in '/var/cache/apt/archives', but I want to change it to somewhere else on the system.. The following is what I already tried, except it doesn't work...

Code:
apt-cache -o Dir::Cache="~/some/other/cache"
where are you changing this? as evo2 said, it probably should be under /etc/apt/ (i personally have an apt.conf.d in there with individual entries).

also, i'm pretty sure apt won't know what "~" signifies. you probably need to write out /home/young_jedi/some/other/cache. then there's also the question of apt having permission to write to that directory.
 
Old 04-17-2019, 02:27 AM   #4
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Or, leave apt alone and bind-mount some/other/dir onto /var/cache/apt/archive
 
1 members found this post helpful.
Old 04-17-2019, 08:08 PM   #5
young_jedi
Member
 
Registered: Mar 2019
Posts: 37

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by evo2 View Post
Hi, apt-cache doesn't cache anything. It queries the cache maintained by apt.
Thanks for the clarification

Quote:
Originally Posted by ondoho View Post
i'm pretty sure apt won't know what "~" signifies. you probably need to write out /home/young_jedi/some/other/cache. then there's also the question of apt having permission to write to that directory.
I tried it both ways (full path and ~) and im running as root, but apt-cache is just not recognizing it.. I think the more correct syntax would actually be
Code:
apt-cache -o Dir::Cache::Archives='/root/cache/'
... But there's nothing on the internet that describes how to actually use the -o option....

Quote:
Originally Posted by descendant_command View Post
Or, leave apt alone and bind-mount some/other/dir onto /var/cache/apt/archive
I could also use a symlink but I dont want to replicate the packages, I want to leave the packages in '/var/cache/apt/archives' alone, but dynamically alter the cache location for certain packages I download...


@all I'm doing this a part of a shell script so modifying a configuration file would not be as "robust" as using -o flag to set an arbitrary configuration option..

Last edited by young_jedi; 04-17-2019 at 08:14 PM.
 
Old 04-17-2019, 08:21 PM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,732

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by young_jedi View Post
But there's nothing on the internet that describes how to actually use the -o option....
The man page says:
Code:
-o, --option
    Set a Configuration Option. This will set an arbitrary configuration option. The syntax is -o Foo::Bar=bar.
Also note, from man apt.conf:
Code:
 Dir::State contains the default directory to prefix on all sub items if they do not start with / or ./.

Last edited by scasey; 04-17-2019 at 08:24 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating squid caches Acess Denied binary1011100 Linux - Server 4 01-13-2007 03:16 AM
Purge caches in memory before suspending yozhhh Linux - General 3 12-01-2006 09:34 AM
LXer: Chapter 7: Static Meets Dynamic Adding Caches to Reduce Costs LXer Syndicated Linux News 0 08-16-2006 01:54 PM
Does rebooting and reseting my router and DSL modem clear caches? M$ISBS Linux - Security 5 07-26-2006 05:23 PM
Update others arp caches rickthemick Linux - Networking 2 12-14-2004 06:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration