How can I use yum to download source packages instead of manually downloading every single package from RHN / CentOS / RedHat Ftp website?

You need to install a package called yum-utils. yum-utils is a collection of utilities and examples for the yum package manager. It includes utilities by different authors that make yum easier and more powerful to use. These tools include: debuginfo-install, package-cleanup, repoclosure, repodiff, repo-graph, repomanage, repoquery, repo-rss, reposync, repotrack, verifytree, yum-builddep, yum-complete-transaction, yumdownloader, yum-debug-dump and yum-groups-manager. Type the following to install yum-utils:
# yum install yum-utils
Once installed, create a repo for SRPM as follows:
# vi /etc/yum.repos.d/srpm.repo
Append the following code:


name=Red Hat Enterprise Linux $releasever - $basearch - Source

Save and close the file.

How do I download php srpm file?

Simply use the command as follows:
# yumdownloader --source {packagename}
# yumdownloader --source php

Sample output:

Loaded plugins: rhnplugin
rhel-src                                                                                                                               |  951 B     00:00     
primary.xml.gz                                                                                                                         | 615 kB     00:02     
rhel-src                                                       2266/2266
Enabling epel-source repository
epel-source                                                                                                                            | 1.9 kB     00:00     
primary.sqlite.bz2                                                                                                                     | 662 kB     00:00     
Enabling epel-source repository
php-5.1.6-23.el5.src.rpm                                                                                                               | 8.0 MB     00:20     

To list file, enter:
# ls *src.rpm

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

4 comments… add one
  • tink May 28, 2010 @ 1:11

    Centos replaces $releasever, the RH ftp site has 5Server for release – how does one work that w/o hardcoding 5Server?

    • haoling-geeker Jun 7, 2013 @ 10:07

      I can’t open the ftp websit,I only open the websit of http://xxxxxx; you can try the http website as follows. And you will find 6Server! And I am confused. Is the website false ?
      the websit:

    • haoling-geeker Jun 7, 2013 @ 10:14

      I just download some srpms to learn!
      But my linux distribution is the Fedora!
      So I have the quesion!
      Thanks a lot!
      And I know w/o means without!

  • haoling-geeker Jun 7, 2013 @ 9:50

    this samples have some faults! I use it and find some code which is modified! as follows:
    1) baseurl=$releasever/en/os/SRPMS/
    modified : baseurl=
    versions is filled with the word that you browse the website and match a version, such as : 6Server;
    I use the fedora linux. But if I download some Redhat source code,I can”t use the enviroment variables! So, I replaced the $varaibles!

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.