In many Linux system, we are using yum (Yellowdog update manager) for packages management. While installing or updating packages in Virtual machine, i always like keep backup of download packages in same machine so that need not to download it from internet again on another Virtual machines, that save my internet and time of download.So in this post we will see HowTo keep yum packages after successful installation.

For enable this feature, we just need to retain yum cacahe with one simple change in yum.conf (yum configuration file)

For this post, we have CentOS7 machine.

SetUp

[root@mysql-pri ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 

[root@mysql-pri ~]# uname  -r
3.10.0-693.2.2.el7.x86_64

[root@mysql-pri ~]# yum --version
3.4.3
  Installed: rpm-4.11.3-25.el7.x86_64 at 2017-09-25 14:42
  Built    : CentOS BuildSystem  at 2017-08-03 03:48
  Committed: Panu Matilainen  at 2017-03-17

  Installed: yum-3.4.3-154.el7.centos.noarch at 2017-09-25 14:43
  Built    : CentOS BuildSystem  at 2017-08-05 19:13
  Committed: CentOS Sources  at 2017-08-01

  Installed: yum-plugin-fastestmirror-1.1.31-42.el7.noarch at 2017-09-25 14:43
  Built    : CentOS BuildSystem  at 2017-08-11 10:23
  Committed: Valentina Mukhamedzhanova  at 2017-03-21

In above output, we can see OS and yum version details.

Edit yum.conf

Add below text in [main] section of /etc/yum.conf

keepcache=1

After change keepcache=1, during installation download packages will keep in their respective directory of /var/cache/yum.

[root@mysql-sec ~]# ls -l /var/cache/yum/x86_64/7/base/packages/tree-1.6.0-10.el7.x86_64.rpm 
-rw-r--r-- 1 root root 47508 Jul  4  2014 /var/cache/yum/x86_64/7/base/packages/tree-1.6.0-10.el7.x86_64.rpm

[root@mysql-sec ~]# rpm -q tree --last
tree-1.6.0-10.el7.x86_64                      Thu 28 Sep 2017 04:49:33 AM IST

Above, tree packages is installed on system but still present in yum cache.