Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

A lot of times when I run yum search, it tends first to download the metadata from a repository. How do I force it to only search the local cache? I prefer quick results to accurate data in this case, and am on a slow line.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

You can search through the cached package meta data:

yum -C search mysearch

This way yum won't update the local meta data, therefore your search will be a little bit faster.

I prefer to create a local file with all the packages doing this way:

yum list all > yum-package-list.log

Then I can grep what I'm searching:

grep -i mysearch yum-package-list.log

That's all...

From time to time I'll execute again the yum list all, to update the list.

Important note

From the Fedora manual

  1. List item

By default, current versions of yum delete the data files and packages that they download, after these have been successfully used for an operation. This minimizes the amount of storage space that yum uses. You may enable caching, so that yum retains the files that it downloads in cache directories. Caches provide three advantages:

* The performance of yum increases
* You may carry out yum operations without a network connection, by using only the caches
* You may copy packages from the caches and reuse them elsewhere 

By default, yum stores temporary files under the directory /var/cache/yum/, with one subdirectory for each configured repository. The packages/ directory within each repository directory holds the cached packages. For example, the directory /var/cache/yum/development/packages/ holds packages downloaded from the development repository.

If you remove a package from the cache, you do not affect the copy of the software installed on your system.

1.1. Enabling the Caches

To configure yum to retain downloaded files rather than discarding them, set the keepcache option in /etc/yum.conf to 1:

 keepcache=1 

Refer to Section 9.1, “Editing the yum Configuration” for more information on editing the yum configuration file. Once you enable caching, every yum operation may download package data from the configured repositories. To ensure that the caches have a set of package data, carry out an operation after you enable caching. Use a list or search query to download package data without modifying your system.

share|improve this answer
1  
It's not entirely true that yum caches are disabled by default. the package cache is disabled, but the metadata is cached by default. yum -C as you mention uses that locally cached metadata. –  Dan Pritts Oct 3 '13 at 4:04
    
@DanPritts you are right, I've updated the answer accordingly. –  tmow Oct 3 '13 at 7:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.