How to create a local yum repo CentOS 6.x / RHEL 6.x

This is an early junior System Administrator guide:

This time I will show you how to create a local yum repository that you can use in your environment.

First you need to create a directory to host your local yum repo in.

I have decided to create two directories because I might add several local repositories in the future.

sudo mkdir /repostore
sudo mkdir /repostore/nmap6.40-1

Then move or copy the rpm files that you would like to have in your local yum repository.

Move rpm file
sudo mv nmap-6.40-1.x86_64.rpm /repostore/nmap6.40-1/
Or copy rpm file
sudo cp nmap-6.40-1.x86_64.rpm /repostore/nmap6.40-1/

Now we need to run the command createrepo:

sudo createrepo /repostore/nmap6.40-1
[c-johsor@sesstl168 /]$ sudo createrepo /repostore/nmap6.40-1/
Spawning worker 0 with 1 pkgs
Workers Finished
Gathering worker results

Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

Now we need to create the yum repo configuration file in the folder /etc/yum.repos.d/

sudo vi /etc/yum.repos.d/nmap-6.40-1.repo
[nmap-6.40-1]
name=Nmap Version 6.1.40-1 Local Repo
baseurl=file:///repostore/
enabled=1
gpgcheck=0

The we install the repo with the command:

sudo yum install nmap-6.40-1
[c-johsor@sesstl168 ~]$ sudo yum install nmap-6.40-1
[sudo] password for c-johsor: 
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.searchdaimon.com
 * extras: mirror.searchdaimon.com
 * updates: mirror.academica.fi
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nmap.x86_64 2:6.40-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package        Arch             Version            Repository             Size
================================================================================
Installing:
 nmap           x86_64           2:6.40-1           nmap-6.40-1           4.8 M

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 4.8 M
Installed size: 17 M
Is this ok [y/N]:

Press y/Y to continue or n/N to cancel

We continue:

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 2:nmap-6.40-1.x86_64                                                                                                                                 1/1 
  Verifying  : 2:nmap-6.40-1.x86_64                                                                                                                                 1/1 

Installed:
  nmap.x86_64 2:6.40-1                                                                                                                                                  

Complete!
[c-johsor@sesstl168 ~]$

Let’s run yum info nmap and check the information about nmap.

[c-johsor@sesstl168 ~]$ yum info nmap-6.40-1
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.funet.fi
 * extras: ftp.funet.fi
 * updates: ftp.lysator.liu.se
Installed Packages
Name        : nmap
Arch        : x86_64
Epoch       : 2
Version     : 6.40
Release     : 1
Size        : 17 M
Repo        : installed
From repo   : nmap-6.40-1
Summary     : Network exploration tool and security scanner
URL         : http://nmap.org
License     : http://nmap.org/man/man-legal.html
Description : 
            : Nmap ("Network Mapper") is a free and open source utility
            : for network exploration or security auditing. Many systems and
            : network administrators also find it useful for tasks such as
            : network inventory, managing service upgrade schedules, and
            : monitoring host or service uptime. Nmap uses raw IP packets in
            : novel ways to determine what hosts are available on the network,
            : what services (application name and version) those hosts are
            : offering, what operating systems (and OS versions) they are
            : running, what type of packet filters/firewalls are in use, and
            : dozens of other characteristics. It was designed to rapidly scan
            : large networks, but works fine against single hosts. Nmap runs on
            : all major computer operating systems, and both console and
            : graphical versions are available.

[c-johsor@sesstl168 ~]$

Let’s check the version information of nmap to get more details:

[c-johsor@sesstl168 /]$ nmap -version

Nmap version 6.40 ( http://nmap.org )
Platform: x86_64-redhat-linux-gnu
Compiled with: liblua-5.2.2 openssl-0.9.8k nmap-libpcre-7.6 nmap-libpcap-1.2.1 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select
[c-johsor@sesstl168 /]$

That is the end of the tutorial.

Next you can read about how to use namp by checking out the current nmap tutorials here:

Or you can check out more information about yum:

I am a Senior System Administrator that work daily with Virtualization,Xenserver, Linux, IT automation, Ansible,Windows, Active Directory, Exchange and a lot more. Here you will find tips and trix from early junior, middle junior and senior to unique information of the topics I mentioned earlier. If you need help with something do not hesitate to contact me I will gladly help.

Tagged with: , , , , , ,

0 Comments on “How to create a local yum repo CentOS 6.x / RHEL 6.x