How to cache yum repositories on CentOS using apt-cacher-ng on Debian or Ubuntu

  If you have a lot of virtual (or real) machines running Debian or Ubuntu and a limited internet connection, it can make a lot of sense to use apt-cacher-ng to create a local cache of the packages you use so that they are only downloaded once. The current version of apt-cacher-ng can also help out with yum repositories!   On CentOS, edit /etc/yum.conf and add:  
proxy=http://[ip-of-your-local-apt-cacher-ng-server]:3142
  If you have changed the default port of apt-cacher-ng from 3142, you will need to modify that. Our example file:  
[main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release proxy=http://10.1.1.12:3142 #  This is the default, if you make this bigger yum won’t see if the metadata # is newer on the remote and so you’ll “gain” the bandwidth of not having to # download the new metadata and “pay” for it by yum not having correct # information. #  It is esp. important, to have correct metadata, for distributions like # Fedora which don’t keep old packages around. If you don’t like this checking # interupting your command line usage, it’s much better to have something # manually check the metadata once an hour (yum-updatesd will do this). # metadata_expire=90m # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d
  As you can see, our local apt-cacher-ng VM is 10.1.1.12.   Run yum update and check your apt-cacher-ng’s cache – you should now see some CentOS respositories cached there.

Fedora 20: Installing packages

  To install a package on Fedora via the command line, we use the yum command like so:  
yum install [package]
  Using tmux as an example:  
yum install tmux
 
Loaded plugins: langpacks, refresh-packagekit Resolving Dependencies –> Running transaction check —> Package tmux.x86_64 0:1.8-3.fc20 will be installed –> Finished Dependency Resolution Dependencies Resolved =========================================== Package        Arch             Version                 Repository        Size =========================================== Installing: tmux           x86_64           1.8-3.fc20              fedora           243 k Transaction Summary =========================================== Install  1 Package Total download size: 243 k Installed size: 558 k Is this ok [y/d/N]:
  You can see that the yum command provides some useful information about the package you have asked it to install. If you are happy with the information provided you can install with “y” or cancel with “n”.

Fedora 20: Updating via the command line

  Fedora, unlike Ubuntu with apt-get, uses yum to update it’s software. Run the following as root (either by logging in as root or using su in front of the command):  
yum update
  You will see a list of the updated packages and a confirmation at the end. On our test system it looks like this:  
Transaction Summary ============================================ Install   3 Packages (+  6 Dependent packages) Upgrade  97 Packages (+157 Dependent packages) Total size: 332 M Total download size: 275 M Is this ok [y/d/N]:
  If you are happy with the listed upgrades and/or new installations hit ‘y’ to update!