"yum clean" Command Examples in CentOS/RHEL/Fedora
During its typical operation, YUM will create a cache of metadata and packages that can be found at /var/cache/yum. These files are essential, but as they grow in size, this cache will ultimately serve to slow down the overall use of this utility and may even cause some issues.
By default YUM Cache set to remove packages after successful installation and can be save the packages by changing the parameter from 0 to 1 in /etc/yum.conf yum configuration file:
# vi /etc/yum.conf [main] ............... keepcache=1 ...............
We can clean or empty the cached directory to save space at any time by executing the following command:
$ yum clean all
yum clean Command Examples
1. To clean all the saved packages run the following command. It will help to reclaim used space:
# yum clean packages Loaded plugins: fastestmirror Cleaning repos: base extras updates 0 package files removed
2. To Clean Metadata, run the following command:
# yum clean metadata Loaded plugins: fastestmirror Cleaning repos: base extras updates 10 metadata files removed 6 sqlite files removed 0 metadata files removed
This removed any excess XML-based files.
3. To clean package headers, run the flowing command:
# yum clean headers Loaded plugins: fastestmirror Cleaning repos: base extras updates 0 header files removed
4. To remove any cached database files:
# yum clean dbcache Loaded plugins: fastestmirror Cleaning repos: base extras updates 0 dbcache files removed
Yum uses SQLite as a part of its normal operation, so the above operation would remove any remaining database files.
4. To clean all cached information, run the yum clean all command:
# yum clean all Loaded plugins: fastestmirror Cleaning repos: base extras updates Cleaning up everything Cleaning up list of fastest mirrors
The above command will clean all files associated with enabled repositories in order to reclaim any unused disk space.
6. To rebuild the Yum cache by typing:
# yum makecache
Over time yum can build up a large cache of RPM headers and other assorted information that can gradually build up to occupy a sizeable amount of room on your hard drive. This cache is kept in /var/cache/yum and can be managed by using the yum command with your choice of options. If you decide to remove the yum cache files, yum will have to redownload them the next time that you decide to update your system. This can take a little bit of time, but should not be a problem if you have a fast network connection.