Skip to content

How to Download and Install Yum Packages Locally

On CentOS, we sometimes need to install yum packages as RPMs locally because we may need them at a time when we don’t have internet access.

How to Download Yum Packages Locally

Option #1

I like to use yum-downloadonly to download packages locally.

yum install yum-plugin-downloadonly

Make a directory where you will download the RPMs.

mkdir /nfs

Now, we use –downloadonly to download all the RPMs of the package and its dependencies into the /nfs directory.

yum install git -y --downloadonly --downloaddir=/nfs
ls /nfs

If you think that you have already installed the files, you should use reinstall:

yum reinstall git -y --downloadonly --downloaddir=/nfs

Option #2

A second option is to use yumdownloader. I prefer Option #1 though.

yum install yum-utils
yumdownloader git

How to Install Yum Downloaded Packages Locally

Change directory to where all the .rpm’s are stored. Yum downloader downloads the packages and dependencies as .rpm’s.

cd /nfs

Install all the RPM packages locally:

yum --nogpgcheck localinstall *.rpm