이 콘텐츠는 선택한 언어로 제공되지 않습니다.

8.4.7. Working with Yum Cache


By default, yum deletes downloaded data files when they are no longer needed after a successful operation. This minimizes the amount of storage space that yum uses. However, you can enable caching, so that the package files downloaded by yum stay in cache directories. By using cached data, you can carry out certain operations without a network connection, you can also copy packages stored in the caches and reuse them elsewhere.
Yum stores temporary files in the /var/cache/yum/$basearch/$releasever/ directory, where $basearch and $releasever are Yum variables referring to base architecture of the system and the release version of Red Hat Enterprise Linux. Each configured repository has one subdirectory. For example, the directory /var/cache/yum/$basearch/$releasever/development/packages/ holds packages downloaded from the development repository. You can find the values for the $basearch and $releasever variables in the output of the yum version command.
To change the default cache location, modify the cachedir option in the [main] section of the /etc/yum.conf configuration file. See Section 8.4, “Configuring Yum and Yum Repositories” for more information on configuring yum.

Enabling the Caches

To retain the cache of packages after a successful installation, add the following text to the [main] section of /etc/yum.conf.
keepcache = 1
Copy to Clipboard Toggle word wrap
Once you enabled caching, every yum operation may download package data from the configured repositories.
To download and make usable all the metadata for the currently enabled yum repositories, type:
yum makecache
Copy to Clipboard Toggle word wrap
This is useful if you want to make sure that the cache is fully up to date with all metadata. To set the time after which the metadata will expire, use the metadata-expire setting in /etc/yum.conf.

Using yum in Cache-only Mode

To carry out a yum command without a network connection, add the -C or --cacheonly command-line option. With this option, yum proceeds without checking any network repositories, and uses only cached files. In this mode, yum may only install packages that have been downloaded and cached by a previous operation.
For instance, to list packages that use the currently cached data with names that contain gstreamer, enter the following command:
yum -C list gstreamer*
Copy to Clipboard Toggle word wrap

Clearing the yum Caches

It is often useful to remove entries accumulated in the /var/cache/yum/ directory. If you remove a package from the cache, you do not affect the copy of the software installed on your system. To remove all entries for currently enabled repositories from the cache, type the following as a root:
yum clean all
Copy to Clipboard Toggle word wrap
There are various ways to invoke yum in clean mode depending on the type of cached data you want to remove. See Table 8.3, “Available yum clean options” for a complete list of available configuration options.
Expand
Table 8.3. Available yum clean options
OptionDescription
expire-cacheeliminates time records of the metadata and mirrorlists download for each repository. This forces yum to revalidate the cache for each repository the next time it is used.
packageseliminates any cached packages from the system
headerseliminates all header files that previous versions of yum used for dependency resolution
metadataeliminates all files that yum uses to determine the remote availability of packages. These metadata are downloaded again the next time yum is run.
dbcacheeliminates the sqlite cache used for faster access to metadata. Using this option will force yum to download the sqlite metadata the next time it is run. This does not apply for repositories that contain only .xml data, in that case, sqlite data are deleted but without subsequent download
rpmdbeliminates any cached data from the local rpmdb
pluginsenabled plugins are forced to eliminate their cached data
allremoves all of the above
The expire-cache option is most preferred from the above list. In many cases, it is a sufficient and much faster replacement for clean all.
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat