Linux repository management

Linux repository management

Linux repository management introduction

This tutorial deals with how to do Linux repository management. Linux repository can be defined as a location where data is stored and managed. Linux  repository is a place where many databases and files are located for distributing it over the network. When you try to install something on your Linux server, Your server tries to download and install the packages from these repositories over the internet network. Very important thing to note here is that your computer must be configured to use digitally signed repositories from vendors as it minimizes the chance of malware threat. It is very necessary to have the correct repositories in your system. Here we will learn about how to add repositories in your Linux system (Red Hat & Debian).

Some of the most popular Linux repository management tools are RPM (For Red hat), YUM (For Red hat), APT (For Debian), Equo (For Sabayon), pacman (For Arch Linux), YaST & Zypper (For Suse Linux). However in this tutorial we will keep our focus mainly on YUM and APT.

                                                  RED HAT BASED SYSTEM

Lets see how to add and manage yum repositories in your Linux red hat based system. YUM stands for Yellowdog Updater Modified. It is fully opensource. But Some geeks may have a question that Red Hat already comes with RPM, then whats the use of YUM?. Let me explain the two.

  • RPM is a packager manager program, which is used to install packages.
  • YUM is a tool which uses number of repositories to find correct and suitable packages for your Linux system.

Add Yum repositories

The below command is used to add yum repository.

# yum-config-manager  --add-repo    <repository-url>
# yum-config-manager  --add-repo

Enable Yum repositories

To make the repository work, we need to enable it. See the below command for enabling yum repository.

# yum-config-manager --enable repository                  

Note: here repository  is repository id

Enable all matching Yum repositories

If you want to enable all the repositories with the matching name then use the below command.

# yum-config-manager  --enable  repository*        

Disable Yum repositories

To disable any yum repository, use the below command.

# yum-config-manager  --disables repository

Disable all matching Yum repositories

Below command is used to disable all matching yum repository.

# yum-config-manager  --disables repository*

Add yum repositories in directory

If you don't want to add repositories by command you can also add it in 'repos.d'  directory directly. Add the downloaded repositories in the below directory that is 'repos.d' directory

# /etc/yum.repos.d/

See the below image of repo files under  yum.repos.d  directory

[root@techsakh ~]$ cd /etc/yum.repos.d/
[root@techsakh yum.repos.d]$ ls
adobe-linux-x86_64.repo CentOS-fasttrack.repo epel-testing.repo mirrors-rpmforge-testing playonlinux.repo
CentOS-Base.repo CentOS-Sources.repo iRedMail.repo mysql-community.repo rpmforge.repo
CentOS-CR.repo CentOS-Vault.repo mirrors-rpmforge mysql-community-source.repo zimbra.repo
CentOS-Debuginfo.repo epel.repo mirrors-rpmforge-extras nux-dextop.repo

                                                   DEBIAN BASED SYSTEM

In Debian based system repository management tool is found as APT (Advance Packaging Tool)

In Debian based system you can add repositories in source.list file. But, before making any changes to the original file, take backup first.

# cp  /etc/apt/sources.list   /etc/apt/sources.list.original

Now edit the file as given below with 'vi' editor.

# vi /etc/apt/sources.list

put the required repositories into the file and save the file by CTRL+D

Adding repositories by command line

To add repositories in Debian based system by command line, you need to use the command 'add-apt-repository' If you are unable to use  add-apt-repository,  then first install the following software.

# apt-get-install python-software-properties

then try

# add-apt-repository   <repository-url>

See the below example.

# add-apt-repository   deb jessie-backports main contrib non-free


How to create a custom Linux yum repository

You can create a custom repository on a self hosted red hat based server. Your self hosted server can be used by other Linux system or server for yum update. But before that you need to have Apache server installed on the server.

Install createrepo

# yum install createrepo

Create a directory 'repo' under  '/var/www/' directory. Copy all the required repository packages under 'repo'.

Now you need to create metadata.

# cd /var/www/repo/
# createrepo --database /var/www/repo

Now as the Apache server is already installed and running, connect any server to your self hosted server with the below command.

# yum-config-manager --add-repo http://server_IP_address/repo

Create a repo file

You can create a repo file in your system, wherein you can given the url of your self hosted server. So next time while yum updates, it will also fetch your custom yum repository. See below for example.

Change the directory to 'yum.repos.d'

# cd /etc/yum.repos.d/

Create a repo file and name it 'my.repo' . There should be .repo extension of the file. Create in the format as given below.

[root@localhost yum.repos.d]# vi my.repo
[My repo]
name=My local Repository

In the above 'name' is the name of the repository
'baseurl' is the URL of the server where the package is present. I have given the baseurl of my self hosted server address.
If 'gpgcheck' value = 1 , then it tells YUM to check signature of the package when downloading
If the value of 'enable=1', it means that the package is active and available, however if its value=0, then it is inactive.


This is it with the tutorial Linux repository management


Download Our Free eBook now

Linux and UNIX Shell scripting ebook

1 Comment on Linux repository management

Leave a Reply

Your email address will not be published.