---
title: "How to Create Repository in Linux"
date: 2019-09-03
author: "Guest Author"
featured_image: "https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-1.png"
categories:
  - name: "Linux"
    url: "/topics/computer/linux.md"
tags:
  - name: "Linux Commands"
    url: "/tags/linux-commands.md"
  - name: "Linux Tutorials"
    url: "/tags/linux-tutorials.md"
---

# How to Create Repository in Linux

Today, we will show you how to create a **repository in Linux**. We know that we can install packages in Linux by using RPM (Red Hat Package Management) but the disadvantage is that by using RPM we can’t install packages which depend on other packages i.e dependencies. so in order to install packages which depend on other packages, we have to install packages by using YUM (Yellowdog Updater Modified). Actually, YUM is added from RHEL5 onwards. YUM uses a repository for installation. YUM automatically computes dependencies and figure out what things should occur to install packages. YUM can install, remove upgrade or query the packages.

[See also

Linux Commands Cheat Sheet: Essential Commands Grouped by Task](https://www.techlila.com/linux-commands/)

## How to Create Repository?

Follow these tips to add a local repository in your hard drive, here I am showing how to create repository in RHEL6.

**Step 1:** Create any folder i.e Directory

```
# mkdir /var/ftp/pub
```

[![Create Repository Step 1](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-1.png "create-repository-step-1")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-1.png)

**Step 2:** Move all RHEL DVD files to this directory /var/ftp/pub

```
# cd /var/ftp/pub
```

[![Create Repository Step 2](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-2.png "create-repository-step-2")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-2.png)

**Step 3:** Append the file localRepo:

```
# cd /etc/yum.repos.d
```

[![Create Repository Step 3](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-3.png "create-repository-step-3")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-3.png)

```
# vi localRepo.repo
```

[![Create Repository Step 4](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-4.png "create-repository-step-4")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-4.png)

```
[localRepo]
name=localRepo
baseurl=file:///var/ftp/pub
enabled=1
gpgcheck=0

:wq! (Save and Quit)
```

[![Create Repository Step 5](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-5.png "create-repository-step-5")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-5.png)

**Step 4:** Create repository

```
#cd /var/ftp/pub/Packages
```

[![Create Repository Step 6](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-6.png "create-repository-step-6")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-6.png)

```
#rpm -ivh createrepo* --force
```

[![Create Repository Step 7](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-7.png "create-repository-step-7")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-7.png)

[![Create Repository Step 8](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-8.png "create-repository-step-8")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-8.png)

```
#createrepo -g /var/ftp/pub/repodata/repomd.xml /var/ftp/pub/Packages
```

[![Create Repository Step 9](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-9.png "create-repository-step-9")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-9.png)

[![Create Repository Step 10](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-10.png "create-repository-step-10")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-10.png)

**Step 5:** Run following command

```
# yum clean all
```

[![Create Repository Step 11](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-11.png "create-repository-step-11")](https://www.techlila.com/wp-content/uploads/2012/02/create-repository-step-11.png)

To check out the list of installed packages use the following command:

```
# yum list installed
```

So this is all about *how to create a repository*. Actually, we make our system to know where the repository is located i.e index.

Following video is not created by me, this video is created by Tim Tan, so the procedure is bit difference, you can follow any procedure :)

[![](https://i.ytimg.com/vi/8ctclSEFXY4/hqdefault.jpg)Play video: How to setup a local YUM repository on RHEL6](https://www.youtube.com/watch?v=8ctclSEFXY4)

This is a guest post by **Harkesh Kumar** He is a senior student of Computer Science and Engineering. He has good experience in Linux environment.