Monday, July 16, 2012

Package Management

Linux penguinLinux penguin (Photo credit: Wikipedia)
All packages that is needed for linux installation will be available in a format packagename_version_architecture.rpm. (Example: dhclient-3.0.5-23.el5_6.4.rpm). For convinence all the packages required for Linux can be made available at common place. This common place is called repository. Redhat maintains it own repository online (RHN - Redhat Network). The repository can also be created locally and can be made available to local network users.

There are two methods available to work with Packages.
2. YUM (Yum dog Updater Modifier)

RPM

RPM Package Manager (RPM) is a utility to install,update,remove individual rpms.

#Install using RPM
rpm -ivh <PackageName>

#Update installed package. If the package is not installed this command will install the package.
rpm -Uvh <PackageName>

#Refresh already installed package. This can done when some configuration files are deleted accidently.
rpm -Fvh <PackageName>

#Remove installed Package
rpm -e <PackageName>

#Remove installed Package without checking the dependency
rpm -e <PackageName> --nodeps

Display rpms
------------
#Check a package is installed or not
rpm -q <packageName>

#Display all installed rpms
rpm -qa

#List all the files in package
rpm -ql <PackageName>

#List only configuration files in a package
rpm -qc <PackageName>

#List all file in package which is not installed in system
rpm -qpl <PackageName>

#List the package which holds the file
rpm -qf <FileName>
rpm -qf /etc/fstab

#List only configuration files in a package
rpm -qc <PackageName>


YUM (Yum dog Updater Modifier)

YUM is utility which developed to overcome the problem of dependencies. ie, While installing a package, yum itself will verify all the dependency package and also install them. Similarly while removing a package it will erase all dependent packages. This makes the life bit easier for System Administration who is involved in installation/Maintanance of linux packages.

Since YUM automatically accesses the dependent packages it is necessary to point repository before installation. Let us see how to create YUM repository which is also called local repository.

Steps to create YUM Repository

1. Ensure the yum is package is installed.
rpm -q yum

2. Create file with .repo extention under /etc/yum.repos.d directory with following template. 

[Header.repo]      #Header
name=             #Name of repository
baseurl=          #Location where rpms are available.
enabled=          #Enable overnetwork (0-disable, 1-enable)
gpgcheck=         #Enable security check (0-disable, 1-enable)
gpgkey=           #Location of key file if gpcheck is enabled


Sample
#cat /etc/yum.repos.d/server.repo

[server.repo]
name=server
baseurl=file://mnt/share
enable=1
gpgcheck=0

Now server.repo repository is ready.

#Refresh repository files information.
yum clean all

#List all files in repository
yum list all

#List all installed packages
yum list installed

#Display information about package
yum info <package_name>

#Install a package with all its dependencies.
yum install <package_name>

#Install all packages starting with word.
yum install <word*>

#Erase package
yum remove <package_name>
Enhanced by Zemanta

No comments:

Post a Comment