Showing posts with label yum. Show all posts
Showing posts with label yum. Show all posts

Monday, December 6, 2021

Create a local repository in CentOS 7 over http

What you need to create a local repository in centos 7 over http is a web server (httpd) and createrepo command. Let's assume the ip address of this server is 10.10.10.10.

# yum install httpd createrepo yum-utils -y

Then, create a directory to store the repository files

# mkdir /var/www/html/repos

Create XML based rpm meta-structure repository, like an index file that points to rpm files for our repository

# createrepo /var/www/html

Configure httpd to allow followsymlinks 

# diff -u /etc/httpd/conf/httpd.conf.ori /etc/httpd/conf/httpd.conf

--- httpd.conf.ori      2021-12-06 12:23:36.704096479 +0800

+++ httpd.conf  2021-12-06 12:21:37.423092872 +0800

@@ -141,7 +141,8 @@

     # http://httpd.apache.org/docs/2.4/mod/core.html#options

     # for more information.

     #

-    Options Indexes FollowSymLinks

+    #Options Indexes FollowSymLinks

+    Options All Indexes FollowSymLinks

 

     #

     # AllowOverride controls what directives may be placed in .htaccess files.


Check for any error
# httpd -t
Restart httpd
# systemctl restart httpd
Sync files from the official repo
# yum install yum-utils
# reposync -g -l -d -m --repoid=base --newest-only --download-metadata --download_path=/var/www/html/repos/ 
Allow port 80 in firewall
# firewall-cmd --add-service http
# firewall-cmd --add-service http --permanent
Create a yum repo configuration file
# cat >> /etc/yum.repos.d/local.repo <<EOF
[local]
name=CentOS Apache
baseurl=http://10.10.10.10
enabled=1
gpgcheck=0
EOF

Test repo. You should be able to see the local repository being listed. Run a yum search command to see whether yum is able to get package info from the local repo.
# yum repolist

Thursday, April 1, 2021

Installing elinks in CentOS 8

Elinks is a text based web browser, and it is now available in powertools repository. Powertools repository is not enabled by default, thus elinks is not available to be installed just by using standard yum install command.


List all available repositories

$ sudo yum repolist --all

...

powertools

...


Install elinks while enabling powertools repository temporarily

$ sudo yum install --enablerepo=powertools elinks -y

...

Installed:

  elinks-0.12-0.58.pre6.el8.x86_64                                                     gpm-libs-1.20.7-15.el8.x86_64                                                    

Complete!


Congratulations, you can now use elinks to view any website, but only in text based mode.

Thursday, November 5, 2020

Download rpm installer file for already installed packages

If you have not install the packages, you can always use --downloadonly flag to just download the packages without installing. For example, I want to download rpm file for curl

# yum install --downloadonly curl


The file and its dependencies will be saved into /var/cache/yum.


But if you have installed the package, the above command will only return a message saying that "Packages is already installed, and nothing to do."


In order to download rpm file of an installed package with dependencies, another command is needed, which is repotrack, that is a command in yum-utils package.


First, install yum-utils

# yum install -y yum-utils


Then, run repotrack on the package that you need the rpm installer

# repotrack curl


All the packages will be downloaded to the current directory. Nice!

Monday, August 24, 2020

Using yum through socks5 proxy

This is useful when you have a server that is not allowed to go to the internet, but have an ssh connection to another server that is able to go to the internet (we can call it jumphost).


1. Setup a socks proxy on port 8888 (any port will do, 8888 is just my preference) via the jumphost

# ssh -D 8888 -fN user@jumphost


2. Append below line into yum.conf

# cat  >> /etc/yum.conf <<EOF

proxy=socks5h://localhost:8888

EOF


3. Yum away (or run the yum command). All yum command will now tunneled through jumphost

# yum update


4. Once done, kill the socks proxy connection

# kill -9 $(ps -ef | grep fN | grep -v grep | awk '{print $2}')


5. And remove the proxy setting in /etc/yum.conf

# sed -i '$d' /etc/yum.conf

Saturday, August 4, 2018

Download rpm with dependencies without installing

The tool we are going to use is yum-utils. First, you need to install yum-utils


# yum install yum-utils

Then, use yumdownloader command, to download the package, adding --destdir for destination the files are going to be downloaded, and --resolve to make yumdownloader download the dependencies as well. For example, I want to download rpm for elinks, and its dependencies, to /tmp:

# yumdownloader --destdir=/tmp --resolve elinks

That's all folks, happy rpm downloading :)


Wednesday, September 13, 2017

Using yum via socks proxy using proxychains

This is useful when you have a CentOS/Redhat server that needs to be updated, but does not have internet connection to get app from the repo. The only requirement is that the server need to be able to ssh into another server that have internet connection. Let's begin.

Download source for proxychain. You can use the server that have internet connection to do this
# wget -c https://github.com/rofl0r/proxychains-ng/archive/master.zip

Transfer the downloaded file into the server without internet, and unzip the file into /usr/local/src
# unzip master.zip -d /usr/local/src

Change directory to /usr/local/src/proxychains-ng-master
# cd /usr/local/src/proxychains-ng-master

Compile, configure and make
# ./configure && make && make install && make install-config

Setup a dynamic socks proxy on port 8888 by ssh'ing into the server that has internet connection:
# ssh foo@server.with.internet -D 8888

Set proxychains to use the dynamic tunnel, by changing the last line of /usr/local/etc/proxychains.conf to "socks4 127.0.0.1 8888"
# tail -1 /usr/local/etc/proxychains.conf 
socks4  127.0.0.1 8888


Open a new terminal, and run yum command with proxychains. You can see that your yum is tunneled via localhost port 8888:
# proxychains4 yum update
[proxychains] config file found: /usr/local/etc/proxychains.conf
[proxychains] preloading /usr/local/lib/libproxychains4.so
[proxychains] DLL init: proxychains-ng 4.12
...

Thursday, November 22, 2012

Listing all available version of a package using yum

Sometimes you want to see what version of a package is available on a repo, below is how you do it:

[humans@earth]$ sudo yum list subversion --showduplicates

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: dist1.800hosting.com

 * epel: mirror.steadfast.net

 * extras: centos.mirror.lstn.net

 * rpmforge: mirror.us.leaseweb.net

 * updates: mirror.raystedman.net

Installed Packages

subversion.x86_64                                                         1.6.11-10.el5_8                                                           installed

Available Packages

subversion.i386                                                           1.6.11-7.el5_6.4                                                          base    

subversion.x86_64                                                         1.6.11-7.el5_6.4                                                          base    

subversion.i386                                                           1.6.11-10.el5_8                                                           updates 

subversion.x86_64                                                         1.6.11-10.el5_8                                                           updates

You make that happened by using --showduplicates flag, which will show all version available for subversion, in this case :)


Thursday, December 2, 2010

yum plugin to remove dependencies

You can remove dependencies using yum-plugin-remove-with-leaves plug-in.

To install:

# yum install yum-plugin-remove-with-leaves

To use:
# yum remove --remove-leaves <package-name>

That's all folks :)

Tuesday, February 12, 2008

Fedora 8 additional repository

If you are using fedora linux, here are a few additional repositories that you might want to install in addition to the official repository and the installation instruction.

  1. Livna rpm
    • Download the installer from here
    • Install the repository
      • rpm -Uvh livna-release-8.rpm
  2. freshrpms
    • Download the installer from here
    • Install the repository
      • rpm -Uvh freshrpms-release-1.1-1.fc.noarch.rpm
  3. atrpms
    • Import the atrpms signing key
      • rpm --import http://ATrpms.net/RPM-GPG-KEY.atrpms
    • Create atrpms.conf in /etc/yum.repos.d/
      • touch /etc/yum.repos.d/atrpms.conf
    • Add the below lines to the atrpms.conf file
      • [atrpms]
        name=Fedora Core $releasever - $basearch - ATrpms
        baseurl=http://dl.atrpms.net/f$releasever-$basearch/atrpms/stable
        gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
        gpgcheck=1
You can start using yum to install any software and yum will pick source from these new repositories straight away.