RPM
Software Management
The following commands are maily used to install and maintain packages/softwares on systems running on Redhat or Fedora systems.
Redhat Packge Manager (rpm)
Update softwares using up2dtae
Yellowdog Updater Modified (yum)
Maintaining Redhat software Depots
Graphical Tools for Managing software
RPM: Package Manager
The RPM system consists of a local database, the rpm executable, rpm package files and Internet accessible metadirectories.
The local RPM database is maintained in /var/lib/rpm. The database stores information about installed packages such as file attributes and package prerequisites. Package files are named using following format
name-version-release.architecture.rpm
RPM installing and removing software:
- Install: rpm -i, --install -v gives detailed output. -h for print hash marks
- upgrade: rpm -U, --upgrade
- Freshen: rpm -F, --freshen
- Erase: rpm -e, --erase
To install rpm
rpm -ivh <package_file_name ....>
when installing rpm package, it consults the local database to ensure that prerequisites are met. The checks can be omitted by enabling the --nodpes or --replacefiles command-line switches, respectively, or both using the --force switch.
To Upgrade RPM
rpm -Uvh <package_file_name ....> rpm -F <package_file_name ....>
rpm can be used to upgrade already installed software with the -U (--upgrade) switch. When upgrading with -U, the package will be installed whether or not it is already installed. Freshening is almost identical to upgrading, but with freshening, the package will be ignored if not already installed.
To uninstallRPM
rpm -e <package_name ...>
To uninstall multiple copy of same RPM
rpm -e --allmatches filename.rpm
Software is removed from system using the -e (--erase) switch.
Updating the Kernel RPM
Do not use rpm -U while updating the kernel rpm.
Only use
rpm -ivh <kernel-version.arch.rpm>
It is possible to install multiple versions of Kernel package. If you use rpm -ivh instead of -U, the new kernel will be added to the system but the old kernel will still remain on it as well. In case of any problem with the new kernel, we can still boot from the old kernel by modifying the /boot/grub.conf file.
RPM Queries:
rpm -qa # to get list of all installed software
rpm -qi <package name> # gives detailed output of package information
rpm -ql <package name> # gives list of files contained in the package
rpm -qf <file name> # gives package that owns the file
--requires # package pre-requisites
--scripts # scripts run upon installation and removal
--provides # capabilities provided by the package
rpm queries and verification:
rpm -V <package name> # verifies the installed package against the RPM database
rpm -Va # to verify all the packages
rpm -Vf /usr/bin/vim # To verify a package containing a particular file
Other rpm utilities:
rpm2cpio: This command allows the files contained within a package file to be converted into cpio stream
rpm2cpio zip-2.3-8.i386.rpm | cpio --extract --make-directories *bin*
RPM signature verification:
Redhat signs all the package with GPG provate signature. This public key is shipped with every redhat distrubution (1st CD). The integrity of the package can be checked by using rpm --checksig option. To verify the integrity of any package, the redhat public key should be imported first.
gpg --import /mnt/cdrom/RPM-GPG-KEY # gpg is encription and signing tool
rpm --import /mnt/cdrom/RPM-GPG-KEY
rpm -qa gpg-pubkey
rpm --checksig zip-2.3-14.i386.rpm
up2date
up2date is no longer available from RHEL 5
rhn_register
Note:- Starting from RHEL 5, red-hat has replaced up2date with yum. There is no up2date command in RHEL 5.x. Use the “rhn_register” command to register the system with Red Hat Network.
up2date utility will query RHN (Red Hat Network) for any relevant updates published, download the RPM package files to /var/spool/up2date directory and optionally upgrade the packages as well.
-u, --update # update accoring to default configuration
-l, --list # list relevant updates only
-d, --download # download relevent updates only (no update)
-i, --install # download and install relevant updates
-p,--packages # resync RHN profile to currently installed rpm
To change the configuration file of up2date
/usr/sbin/up2date-config
The first time, when the up2date utility is run, it will prompt for the RHN user name and password (If it is redhat Advanced server edition). After giving the user name and password, the registration utility creates a certificate in /etc/sysconfig/rhn/systemid that serves to identify the machine to the redhat network. To regenerate a new certificate for the system, simply delete this file and re-run up2date utility.
Note: if the system is behind firewall, and need to access the system using proxy, export the server configuration of the system using the following command
export http_proxy="http://10.82.128.128:8080"
Remote administration of up2date
Webbased administration https://rhn.redhat.com
RHN can be used to perform remote administration of collections of machines. First, actions for the machine such as specifig package installation or upgrades are queued for the machine using RHN account.
Client machines use the rhnsd daemon to poll RHN priodically for quyeyed actions. By default, it polls every 2 hours. But it can be adjusted in /etc/sysconfig/rhn/rhnsd. The rhnsd daemon uses the /usr/sbin/rhn_check command to actually perform the poll and administer any queued actions.
yum - Yellowdog Updater Modified
- yum is an interactive, automated update program which can be used for maintaining systems using rpm.
- Additional yum repositories can be added by adding entries in /etc/yum.conf or putting separate files for each repo in /etc/yum.repos.d/ directory.
- The log file for yum is stored in /var/log/yum.log file
The options of yum are
- install --> To install the latest version of a package or group of packages while ensuring that all dependencies are satisfied.
- update --> If run without any packages, update will update every currently installed package. If one or more packages are specified, Yum will only update the listed packages.
- check-update --> Implemented so you could know if your machine had any updates that needed to be applied without running it interactively. Returns exit value of 100 if there are packages available for an update. Also returns a list of the pkgs to be updated in list format. Returns 0 and no packages are available for update.
- upgrade --> Is the same as the update command with the --obsoletes flag set. See update for more details.
- remove or erase --> Are used to remove the specified packages from the system as well as removing any packages which depend on the package being removed.
- list --> Is used to list various information about available packages
- provides or whatprovides --> Is used to find out which package provides some feature or file.
- search --> Is used to find any packages matching a string in the description, summary, packager and package name fields of an rpm. Useful for finding a package you do not know by name but know by some word related to it.
- deplist --> Produces a list of all dependencies and what packages provide those dependencies for the given packages.
- clean --> Is used to clean up various things which accumulate in the yum cache directory over time.
- --enablerepo=<RepoName> Enables specific repositories by id or glob that have been
disabled in the configuration file using the enabled=0 option.
- --disablerepo=<RepoName> Disables specific repositories by id or glob.
Examples
To install a package or group of packages (-y used to answer yes to all questions)
yum -y install <package1 package2 ...>
To update every currently installed package
yum -y update
To update a singel or group of packages
yum -y update <package1 package2 ...>
To remove a package
yum remove <package1>
or
yum erase <package>
To cleanup the yum cache directory
yum clean
To search for some packages matching a string in the description, summary, and package name fields of an rpm.
yum search <search_string>
To check for updates
yum check-update
To search only rpmforge repo for package 'mailscan'
yum search --disablerepo=* --enablerepo=rpmforge mailscan
Adding more centos repos:
http://wiki.centos.org/AdditionalResources/Repositories?action=show
How to add more CentOS Repositories
EPEL Frequently Asked Questions
EPEL (Extra Packages for Enterprise Linux) is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages that complement the Fedora-based Red Hat Enterprise Linux (RHEL) and its compatible spinoffs, such as CentOS and Scientific Linux.
To install EPEL Repo
# su -c 'rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm' # su -c 'rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm' # su -c 'yum -y install foo'
To install rpmforge Repo
# su -c 'rpm -Uvh http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm' # su -c 'rpm -Uvh http://apt.sw.be/redhat/el5/en/x86_64/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm'
Additional third-party repositories
Add the bellow lines in /etc/yum.conf file
[dries] name=Extra Fedora rpms dries - $releasever - $basearch baseurl=http://ftp.belnet.be/packages/dries.ulyssis.org/redhat/el4/en/i386/dries/RPMS gpgcheck=1 enabled=1 [dag] ## Large collection name=Dag RPM Repository for Red Hat Enterprise Linux baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag gpgcheck=1 enabled=1 [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://mirror.centos.org/centos/5.1/extras/i386/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 [kbs-CentOS-Extras] name=CentOS.Karan.Org-EL$releasever - Stable gpgcheck=1 gpgkey=http://centos.karan.org/RPM-GPG-KEY-karan.org.txt enabled=1 baseurl=http://centos.karan.org/el$releasever/extras/stable/$basearch/RPMS/ [kbs-CentOS-Misc] name=CentOS.Karan.Org-EL$releasever - Stable gpgkey=http://centos.karan.org/RPM-GPG-KEY-karan.org.txt gpgcheck=1 enabled=1 baseurl=http://centos.karan.org/el$releasever/misc/stable/$basearch/RPMS/ [kbs-CentOS-Misc-Testing] name=CentOS.Karan.Org-EL$releasever - Testing gpgkey=http://centos.karan.org/RPM-GPG-KEY-karan.org.txt gpgcheck=1 enabled=1 baseurl=http://centos.karan.org/el$releasever/misc/testing/i386/RPMS/ [atrpms] name=Fedora Core $releasever - $basearch - ATrpms baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms gpgcheck=1enabled=1 #[fedora7] #name=Fedora - 7 - i386 #baseurl=http://mirrors.kernel.org/fedora/releases/7/Everything/i386/os/ #gpgcheck=1 #gpgkey=http://mirrors.kernel.org/fedora/releases/7/Everything/i386/os/RPM-GPG-KEY-Fedora
To use the above repositories, you need to add their GPG key for authentication:
$ su - # rpm --import http://centos.karan.org/RPM-GPG-KEY-karan.org.txt # rpm --import http://dries.ulyssis.org/rpm/RPM-GPG-KEY.dries.txt # rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt # rpm --import http://ATrpms.net/RPM-GPG-KEY.atrpms
Graphical Tools for software
- pirut is a graphical frontend to yum. Pirut can install, remove, or update software packages. Pirut also allows searching, or viewing and installing software package groups.
- pup provides a handsome graphical front end for installing software updates via yum
- puplet is a service that runs during a desktop session, and appears in the system tray when software updates are available, allowing you to launch pup