How to download rpm package and all dependencies (RHEL / CentOS 7)

Linux, How To

In my last article I have already shared the steps to sync (download) the online repositories from CentOS / RHEL 7 to your local machine, to use them offline when you do not have access to internet. In this article I will share the steps to download rpm package and all dependencies so that you don't have to struggle downloading the rpm's dependencies separately.

How to download rpm package and all dependencies (RHEL / CentOS 7)

These are some of the commands which you can use to perform this

  • yumdownloader
  • repotrack



Both yumdownloader and repotrack are part of yum-utils rpm so install this rpm before starting to use these tools.

On RHEL system you must have an active subscription to RHN or you can configure a local offline repository using which "yum" package manager can install the provided rpm and it's dependencies.
# yum install -y yum-utils


Using yumdownloader to download rpm package and all dependencies

Below is the command to download rpm package with all it's dependencies

# yumdownloader  --downloadonly --downloaddir=. glibc --resolve
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * updates:
No Match for argument .
--> Running transaction check
---> Package glibc.i686 0:2.17-222.el7 will be installed
--> Processing Dependency: glibc-common = 2.17-222.el7 for package: glibc-2.17-222.el7.i686
--> Processing Dependency: for package: glibc-2.17-222.el7.i686
--> Processing Dependency: for package: glibc-2.17-222.el7.i686
---> Package glibc.x86_64 0:2.17-222.el7 will be installed
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-196.el7 will be updated
--> Processing Dependency: glibc-common = 2.17-196.el7 for package: glibc-2.17-196.el7.x86_64
---> Package glibc-common.x86_64 0:2.17-222.el7 will be an update
---> Package nss-softokn-freebl.x86_64 0:3.28.3-6.el7 will be updated
---> Package nss-softokn-freebl.i686 0:3.36.0-5.el7_5 will be installed
--> Processing Dependency: nss-util >= 3.36.0-1 for package: nss-softokn-freebl-3.36.0-5.el7_5.i686
--> Processing Dependency: nspr >= 4.19.0 for package: nss-softokn-freebl-3.36.0-5.el7_5.i686
---> Package nss-softokn-freebl.x86_64 0:3.36.0-5.el7_5 will be an update
--> Running transaction check
---> Package glibc.x86_64 0:2.17-196.el7 will be updated
--> Processing Dependency: glibc = 2.17-196.el7 for package: glibc-headers-2.17-196.el7.x86_64
--> Processing Dependency: glibc = 2.17-196.el7 for package: glibc-devel-2.17-196.el7.x86_64
---> Package nspr.x86_64 0:4.13.1-1.0.el7_3 will be updated
---> Package nspr.x86_64 0:4.19.0-1.el7_5 will be an update
---> Package nss-util.x86_64 0:3.28.4-3.el7 will be updated
---> Package nss-util.x86_64 0:3.36.0-1.el7_5 will be an update
--> Running transaction check
---> Package glibc-devel.x86_64 0:2.17-196.el7 will be updated
---> Package glibc-devel.x86_64 0:2.17-222.el7 will be an update
---> Package glibc-headers.x86_64 0:2.17-196.el7 will be updated
---> Package glibc-headers.x86_64 0:2.17-222.el7 will be an update
--> Finished Dependency Resolution
(1/2): nss-softokn-freebl-3.36.0-5.el7_5.i686.rpm                                                                                                                             | 211 kB  00:00:00
(2/2): glibc-2.17-222.el7.i686.rpm                                                                                                                                            | 4.2 MB  00:00:01
exiting because "Download Only" specified

For example here I am downloading glibc and all it's dependency rpms

# yumdownloader --downloadonly --downloaddir=/tmp/ glibc --resolve
This command is to download the package along with its dependencies does not always successfully recognize all dependencies. It is better to use repoquery to find the dependencies and then use yumdownloader to download them
# repoquery -R --resolve --recursive glibc |xargs -r yumdownloader
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * updates:
No Presto metadata available for base
(1/27): basesystem-10.0-7.el7.centos.noarch.rpm                                                                                                                               | 5.0 kB  00:00:00
(2/27): centos-release-7-5.1804.el7.centos.x86_64.rpm                                                                                                                         |  24 kB  00:00:00
(3/27): chkconfig-1.7.4-1.el7.x86_64.rpm                                                                                                                                      | 181 kB  00:00:00
(4/27): gmp-6.0.0-15.el7.i686.rpm                                                                                                                                             | 416 kB  00:00:00
(5/27): gawk-4.0.2-4.el7_3.1.x86_64.rpm                                                                                                                                       | 874 kB  00:00:00
(6/27): gmp-6.0.0-15.el7.x86_64.rpm                                                                                                                                           | 281 kB  00:00:00
(7/27): keyutils-libs-1.5.8-3.el7.i686.rpm                                                                                                                                    |  25 kB  00:00:00
(8/27): keyutils-libs-1.5.8-3.el7.x86_64.rpm                                                                                                                                  |  25 kB  00:00:00
(9/27): libcap-2.22-9.el7.x86_64.rpm                                                                                                                                          |  47 kB  00:00:00
(10/27): grep-2.20-3.el7.x86_64.rpm                                                                                                                                           | 344 kB  00:00:00
(11/27): libffi-3.0.13-18.el7.i686.rpm                                                                                                                                        |  27 kB  00:00:00
(12/27): libffi-3.0.13-18.el7.x86_64.rpm                                                                                                                                      |  30 kB  00:00:00
(13/27): libverto-0.2.5-4.el7.x86_64.rpm                                                                                                                                      |  16 kB  00:00:00
(14/27): libgcc-4.8.5-28.el7_5.1.i686.rpm                                                                                                                                     | 108 kB  00:00:00
(15/27): libtasn1-4.10-1.el7.x86_64.rpm                                                                                                                                       | 320 kB  00:00:00
(16/27): nss-softokn-freebl-3.34.0-2.el7.i686.rpm                                                                                                                             | 206 kB  00:00:00
(17/27): nspr-4.19.0-1.el7_5.i686.rpm                                                                                                                                         | 128 kB  00:00:00
(18/27): nss-softokn-freebl-3.34.0-2.el7.x86_64.rpm                                                                                                                           | 220 kB  00:00:00
(19/27): p11-kit-0.23.5-3.el7.i686.rpm                                                                                                                                        | 241 kB  00:00:00
(20/27): nss-util-3.36.0-1.el7_5.i686.rpm                                                                                                                                     |  76 kB  00:00:00
(21/27): p11-kit-trust-0.23.5-3.el7.x86_64.rpm                                                                                                                                | 129 kB  00:00:00
(22/27): p11-kit-0.23.5-3.el7.x86_64.rpm                                                                                                                                      | 252 kB  00:00:00
(23/27): pcre-8.32-17.el7.i686.rpm                                                                                                                                            | 420 kB  00:00:00
(24/27): popt-1.13-16.el7.x86_64.rpm                                                                                                                                          |  42 kB  00:00:00
(25/27): pcre-8.32-17.el7.x86_64.rpm                                                                                                                                          | 422 kB  00:00:00
(26/27): zlib-1.2.7-17.el7.x86_64.rpm                                                                                                                                         |  90 kB  00:00:00
(27/27): sed-4.2.2-5.el7.x86_64.rpm                                                                                                                                           | 231 kB  00:00:00

This command will download glibc rpm and all it's dependencies in your current working directory. So as you see this command was successfully able to get larger list of dependencies which was skipped when we only used yumdownloader.


Using repotrack to download rpm package and all dependencies

repotrack is a program for keeping track of a particular package and its dependencies. It will download one or more packages and all dependencies.

Using the below command I am downloading glibc and all it's dependencies using repotrack in it's current directory

# repotrack glibc
Downloading basesystem-10.0-7.el7.centos.noarch.rpm
Downloading bash-4.2.46-30.el7.x86_64.rpm
Downloading ca-certificates-2018.2.22-70.0.el7_5.noarch.rpm
Downloading centos-release-7-5.1804.4.el7.centos.x86_64.rpm
Downloading chkconfig-1.7.4-1.el7.x86_64.rpm
Downloading coreutils-8.22-21.el7.x86_64.rpm
Downloading filesystem-3.2-25.el7.x86_64.rpm
Downloading gawk-4.0.2-4.el7_3.1.x86_64.rpm
Downloading glibc-2.17-222.el7.i686.rpm
Downloading glibc-2.17-222.el7.x86_64.rpm
Downloading glibc-common-2.17-222.el7.x86_64.rpm
Downloading gmp-6.0.0-15.el7.i686.rpm
Downloading gmp-6.0.0-15.el7.x86_64.rpm
Downloading grep-2.20-3.el7.x86_64.rpm
Downloading info-5.1-5.el7.x86_64.rpm
Downloading keyutils-libs-1.5.8-3.el7.i686.rpm
Downloading keyutils-libs-1.5.8-3.el7.x86_64.rpm
Downloading krb5-libs-1.15.1-19.el7.x86_64.rpm
Downloading libacl-2.2.51-14.el7.x86_64.rpm
Downloading libattr-2.4.46-13.el7.x86_64.rpm
Downloading libcap-2.22-9.el7.x86_64.rpm
Downloading libcom_err-1.42.9-12.el7_5.x86_64.rpm
Downloading libffi-3.0.13-18.el7.i686.rpm
Downloading libffi-3.0.13-18.el7.x86_64.rpm
Downloading libgcc-4.8.5-28.el7_5.1.i686.rpm
Downloading libgcc-4.8.5-28.el7_5.1.x86_64.rpm
Downloading libselinux-2.5-12.el7.x86_64.rpm
Downloading libsepol-2.5-8.1.el7.x86_64.rpm
Downloading libstdc++-4.8.5-28.el7_5.1.i686.rpm
Downloading libstdc++-4.8.5-28.el7_5.1.x86_64.rpm
Downloading libtasn1-4.10-1.el7.x86_64.rpm
Downloading libverto-0.2.5-4.el7.x86_64.rpm
Downloading ncurses-5.9-14.20130511.el7_4.x86_64.rpm
Downloading ncurses-base-5.9-14.20130511.el7_4.noarch.rpm
Downloading ncurses-libs-5.9-14.20130511.el7_4.x86_64.rpm
Downloading nspr-4.19.0-1.el7_5.i686.rpm
Downloading nspr-4.19.0-1.el7_5.x86_64.rpm
Downloading nss-softokn-freebl-3.36.0-5.el7_5.i686.rpm
Downloading nss-softokn-freebl-3.36.0-5.el7_5.x86_64.rpm
Downloading nss-util-3.36.0-1.el7_5.x86_64.rpm
Downloading nss-util-3.36.0-1.el7_5.i686.rpm
Downloading openssl-libs-1.0.2k-12.el7.x86_64.rpm
Downloading p11-kit-0.23.5-3.el7.i686.rpm
Downloading p11-kit-0.23.5-3.el7.x86_64.rpm
Downloading p11-kit-trust-0.23.5-3.el7.x86_64.rpm
Downloading pcre-8.32-17.el7.x86_64.rpm
Downloading pcre-8.32-17.el7.i686.rpm
Downloading popt-1.13-16.el7.x86_64.rpm
Downloading sed-4.2.2-5.el7.x86_64.rpm
Downloading setup-2.8.71-9.el7.noarch.rpm
Downloading tzdata-2018e-3.el7.noarch.rpm
Downloading zlib-1.2.7-17.el7.x86_64.rpm

This command also successfully download all the list of dependencies for glibc rpm.


Lastly I hope the steps from the article to download rpm package and all dependencies on (RHEL / CentOS 7) Linux node was helpful. So, let me know your suggestions and feedback using the comment section.


Views: 1,180
Deepak Prasad

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to

Thank You for your support!!

6 thoughts on “How to download rpm package and all dependencies (RHEL / CentOS 7)”

  1. Poor instructions.
    When yum can not find a dependency it does not give the name of the rpm file – only a hint of what the name is. It becomes a guessing game to try and find out the name of the rpm file. This looks like an obfuscation by yum and this web site.

    • How do you expect to find the dependency if you don’t know the rpm name itself? Yum and dnf have improved and now atleast they give us a hint of the nearest matching rpm name.

    • You can just us “yum install <pkg_name>“, it should download the rpm and then install it.
      But assuming you have a valid repository in place to download the rpm

  2. Question: If I do this (on CentOS 7)…
    yum install pgdg-redhat-repo-latest.noarch.rpm
    …does it just build and/or update my local /etc/yum.repos.d ?
    If not, what exactly happens with that particular yum command ?

    • This should create a new repo file under /etc/yum.repos.d/
      This does not means that you are updating any local database, it will just get the repository information for the provided repo which I think is Postgesql so once this repo is in place you can use yum to install the packages from this repo


Leave a Comment