Monday, November 10, 2014

YUM in RHEL

Yum or Yellow dog Update, Modified is a package manager that was developed by Duke University to improve the installation of RPMs.

Yum searches numerous repositories for packages and their dependencies so they may be installed together in an effort to alleviate dependency issues. Red Hat Enterprise Linux 5 uses Yum to fetch packages and install RPMs.

Yum uses a configuration file at /etc/yum.conf. Also refer yum(8) man page for more information.

There are multiple ways by which you can install a repository on the system and install/update packages :

  1. Add an existing repository.
  2. Setup a new repository having packages populated from ISO's downloaded from RHN.
  3. Register the system on RHN and subscribe to the channels depending on the subscription you have.
To automatically install software from the DVD I would like to use YUM, but I have to set it up first. There is a main configuration file - yum.conf which resides in /etc. This is the default content of it:

# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3


Next we need the Media ID from the DVD. It can be obtained from a file call media.repo from the DVD. First mount the DVD:

# mkdir -p /mnt/dvd
# mount /dev/sr0 /mnt/dvd


Or mount the ISO file:

# mkdir -p /mnt/dvd
# mount /root/rhel6.iso /mnt/dvd -o loop


Get Media ID from DVD:

# cat /mnt/dvd/media.repo
[InstallMedia]
name=Red Hat Enterprise Linux 6.0
mediaid=0123456789.012345
...


Now configure /etc/yum.repos.d/file.repo and add the DVD (or the ISO file) as a repository and add /mnt/dvd as baseurl:

# cat /etc/yum.repos.d/file.repo
[dvd]
mediaid=0123456789.012345
name=DVD
baseurl=file:///mnt/dvd
enabled=1
gpgcheck=0


Check if it accept the repository:

# yum repolist
Loaded plugins: rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
dvd                          | 3.7 kB     00:00 ...
dvd/primary_db               | 2.9 MB     00:00 ...


Install a package from the repository (e.g. tree):

# yum install tree
Loaded plugins: rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.5.3-2.el6 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved
Package   Arch       Version         Repository     Size
tree      x86_64     1.5.3-2.el6     dvd            36 k

Transaction Summary
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 36 k
Installed size: 65 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing     : tree-1.5.3-2.el6.x86_64

1/1
Installed:
  tree.x86_64 0:1.5.3-2.el6


Complete! Just keep in mind that you always have to mount the DVD or the ISO file before you can install any software via YUM.

Yum must be running as root. Here are some useful commands:

1) Install a package:
yum install package
Example:
yum install httpd
2) Remove a package:
yum remove package
Example:
yum remove httpd
3) Update a package:
yum update package
Example:
yum update httpd
4) Search for a package:
yum search package
Example:
yum search httpd
5) Find information about a package:
yum info package
Example:
yum info httpd
6) List packages containing a certain term:
yum list term
Example:
yum list httpd
7) Find what package provides a particular file:
yum whatprovides 'path/filename'
Example:
yum whatprovides 'etc/httpd.conf'
yum whatprovides '*/libXp.so.6'
8) Update all installed packages with kernel package :
yum update
Example:
yum update
9) To update a specific package:
yum update <package-name>
Example:
yum update openssh-server 

No comments:

Post a Comment