How to Setup a Network Repository to Install or Update Packages – Part 11

Configuring the Client Machine

You can add the configuration files for custom repositories in the /etc/yum.repos.d directory. Configuration files need to end in .repo and follow the same basic structure.


Most likely, there will be already other .repo files in /etc/yum.repos.d. To properly test your repository, you can either delete those configuration files (not really recommended, since you may need them later) or rename them, as I did, by appending .orig to each file name:

# cd /etc/yum.repos.d
# for i in $(ls *.repo); do mv $i $i.orig; done
Backup Yum Repositories
Backup Yum Repositories

In our case, we will name our configuration file as tecmint.repo and insert the following lines:

name=Example repo for Part 11 of the LFCE series on

In addition, we have enabled GPG signature-checking for all packages in our repository.

Using the Repository

Once the client has been properly configured, you can issue the usual yum commands to query the repository. Note how yum info subversion indicates that the information about the package is coming from our newly created repository:

# yum info subversion
Check Yum Repository Info
Check Yum Repository Info

Or you can install or update an already installed package:

# yum { install | update } package

For example,

# yum update && yum install subversion
Yum Install Package
Yum Install Package

Keeping the Repository Up-to-date

To make sure our repository is always current, we need to synchronize it with the online repositories on a periodic basis. We can use rsync for this task as well (as explained in Part 6 of the LFCS series.

rsync allows us to synchronize two directories, one local and one remote). Run the rsync command that was used to initially download the repository through a cron job and you’re good to go. Remember to set the cron job to a time of the day when the update will not cause a negative impact in the available bandwidth.

For example, if you want to update your repository every day beginning at 2:30 AM:

30 2 * * * rsync -avz rsync:// /var/www/html/repos/centos/6/6/ 

Important: Make sure to execute above command on the CentOS 7 server to keep your repository.

Of course, you can put that line inside a script to do more complex and customized tasks before or after performing the update. Feel free to experiment and tell me about the results.


You should never underestimate the importance of a local or network repository given the many benefits it brings as I explained in this article. If you can afford the disk space, this is definitely the way to go. I look forward to hearing from you and don’t hesitate to let me know if you have any questions.

Gabriel Cánepa
Gabriel Cánepa is a GNU/Linux sysadmin and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

28 thoughts on “How to Setup a Network Repository to Install or Update Packages – Part 11”

    • @Ricardo,

      First you need to set proxy connection settings in your exports path as shown.

      # export HTTP_PROXY=http://user:password@proxyhost:8080

      Then you can tell that you want rsync to use below proxy settings for its traffic.

      # RSYNC_PROXY=user:password@proxyhost:8080

      You can modify the above command as per your proxy connection requirements (some do not need user/password)

      Finally you run your rsync job.

  1. Hi, I’m afraid your instructions are not correct. You must not use createrepo to create the repodata, but instead you should use the repodata you get from the mirror you sync from.

    If you create the repodata yourself, you will break the GPG signing of repomd.xml (see repomd.xml.asc). Please remove all references to “createrepo‘”.

    For those thinking of setting up a public CentOS mirror based on this blog posting, you should sync everything with one rsync command, and not by individual version or repository. In this case the -H (preserve hard links) rsync option would save you some bandwidth and hard disk space.

    Best regards, avij on behalf of the CentOS Linux Project.

  2. Dear Tecmint Team,

    Thanks for your support with reference to Hadoop and Maria DB. Good Article and very good for a beginner like me. I request to kindly help me with the article for creation Installation and usage of Active Directory Services for Centos 7 64bit Server and Centos 7 64bit Client.(i.e i should communicate with Centos 7 Server with Centos 7 Client).

    Please help
    Thanks and Regards
    Dinakar N K

  3. It’s important to remember that after you setup your rsync in cron, you also need to update the repo, may be include the update command after the rsync in cron.

  4. Anyone wondering how to quickly undo the renaming of their .repo files (remove the .orig extension) can use this. Always backup your files first.

    for i in $(ls *.orig); do mv -- "$i" "${i%.orig}"; done

    BTW – These tutorials are great. Thanks!

  5. Since you have this whole setup spread across 2 or 3 different pages, I may have missed it, but I’m pretty sure you left out the part about opening up the ports on the firewall for the web server.

    # firewall-cmd --permanent --add-port=80/tcp
    # firewall-cmd --permanent --add-port=443/tcp
    # firewall-cmd --reload
  6. Hi,

    Would you say this process is an alternative to using RedHat Satellite in a RHEL environment? I’d like to save my company a tons of money getting Satellite or all our servers.

    • @Doyin,

      Yes you absolutely correct, just setup one local network yum repository server, and tell all Linux clients to use this local yum repository to install and update packages over local network, this way you can save lots of money + network bandwidth too, and very quickly..

      • Thanks Ravi. In order to centrally initiate/manage the yum updates and the repository, would I still need redhat satellite?

        Even though all the servers make use of the local repo, I’ll still need to centrally manage updates. What’s the best way you would advise to achieve this?

  7. Hi Gabriel,

    There is a small issue here – Once we download the entire structure under “OS” , we get the necessary updates which can be fed to all in house servers through FTP/HTTP. But this update will NOT be complete – for example, we will not get the latest kernel, firefox etc. as their updated packages are contained in “updates, centosplus, extras” etc. directories, which will not get downloaded by the described procedure.

    Also, if we include these directories (updates, centosplus, extras etc.) in separate commands using rsync, we will be downloading lot of data which will be irrelevant – for example the “updates” directory contains around 18 files for firefox rpm of different versions and each of 70 MB size ( half of which are 32bit ) – whereas we just need the latest version of the rpm only. How to get “Only” the required rpms of latest versions from these directories ?

  8. when I run rsync (# rsync -avz rsync:// /var/www/html/repos/centos/) on Centos 7.1, I get always this error:

    rsync: failed to connect to ( Connection timed out (110)
    rsync: failed to connect to ( Connection timed out (110)
    rsync error: error in socket IO (code 10) at clientserver.c(122) [Receiver=3.0.9]

    How can I fix this?
    If has something to do with ports

    P.S. I’ve already tried in different repositories

    Many thanks

    • @Alberto,
      Make sure you have the package openssh-clients (that’s the exact name) installed on your CentOS 7.1 box. Also, have you checked the firewalld log, in case you have it enabled? You can do systemctl stop firewalld and then try to connect again in order to discard a firewall issue on your end. Last, but not least, please check this article on rsync that may be helpful in this case: Please let us know how everything goes.

  9. Dear Gabriel Cánepa

    I am a System Administrator at a financial institution. We have around 40 servers with RHEL 6.5, 6.2, 5.5, OEL 5.5, Centos 5.7 etc. We don’t have all the servers connected to the public internet. We want to create a local yum repository that is connected with both outside and inside and get all software updates there and use this repo from all other internal servers. The problem is that could I connect all versions specially the 5x to use the central yum repo on RHEL 6.5? There are many mirrors for CentOS as described in this article. Is the same process will work in RHEL and where will I get the RHEL mirrors?
    I am desperately seeking for a solution for a long time. Many of my new projects are pending for this. Please help me in this regard.
    Thanks in advance.

    • @asbir,
      The same process described in this article for CentOS should work for RHEL as well. I am afraid that the information provided in your comment is not enough for me to assess the situation. If you can be more specific, upload a document somewhere with your intended set up and I will take a look.

  10. Hi:
    On cron, after running “rsync”, it’s mandatory/recommended to run the “createrepo –update”?


    • @Carlos,
      I must confess I didn’t think of it while writing this article, so thank you for bringing this to my attention. Absolutely – I would recommend using createrepo with the update flag in the scenario that you described.

  11. Please note: Some ISPs knock-out the standard port(s) for rsync.

    This will cause your initial-load and your refreshes to fail.

    • @Pim,
      Thank you for bringing that to our attention. Luckily at least my ISP didn’t do it :). I was able to complete the tutorial without issues or unnecesary delays.
      That being said, it would be a good idea to find out if other ISPs block the ports (or not) in order to know which one we can use.
      Thanks for your comment, again!

  12. Thank for your great coverage of exam objectives , i wish this all 12 parts put on pdf , mobi ,epub format or develop as book ,also the same for LFCS parts ,I really appreciate everything you’ve done.


Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.