These are some rpm commands a system Admin must know for daily use ,i too did not know the proper useage of these commands learnt this from a friend and Internet i have put up these commands for quick reference for some linux beginners, hope someone finds them useful.
1-Install a RPM
rpm -ivh package-name.rpm
eg: epel-release-5-3.noarch.rpm
2- Update a RPM
rpm -Uvh package-name.rpm
eg: rpm -Uvh epel-release-5-3.noarch.rpm
3- List contents of installed RPM
rpm -qvl package-name
eg: rpm -qvl epel-release
output is as follows
-rw-r--r-- 1 root root 1698 Apr 3 2007 /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
-rw-r--r-- 1 root root 1054 Apr 25 2008 /etc/yum.repos.d/epel-testing.repo
-rw-r--r-- 1 root root 954 Apr 25 2008 /etc/yum.repos.d/epel.repo
drwxr-xr-x 2 root root 0 Apr 25 2008 /usr/share/doc/epel-release-5
-rw-r--r-- 1 root root 18385 Apr 3 2007 /usr/share/doc/epel-release-5/GPL
4-List contents of a RPM
rpm -qlp package-name.rpm
eg: rpm -qlp epel-release-5-3.noarch.rpm
output is as follows
/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
/etc/yum.repos.d/epel-testing.repo
/etc/yum.repos.d/epel.repo
/usr/share/doc/epel-release-5
/usr/share/doc/epel-release-5/GPL
5-Print information about an installed RPM
rpm -qi package-name
eg: rpm -qi epel-release
output is as follows
Name : epel-release Relocations: (not relocatable)
Version : 5 Vendor: Fedora Project
Release : 3 Build Date: Fri 25 Apr 2008 10:16:23 PM GST
Install Date: Wed 04 Aug 2010 10:02:08 PM GST Build Host: ppc2.fedora.redhat.com
Group : System Environment/Base Source RPM: epel-release-5-3.src.rpm
Size : 22091 License: GPL
Signature : DSA/SHA1, Sat 26 Apr 2008 04:03:47 AM GST, Key ID 119cc036217521f6
Packager : Fedora Project
URL : http://download.fedoraproject.org/pub/epel
Summary : Extra Packages for Enterprise Linux repository configuration
Description : This package contains the Extra Packages for Enterprise Linux (EPEL) repository GPG key as well as configuration for yum.
6-Print information about a RPM
rpm -qpi package-name.rpm
eg rpm -qpi epel-release-5-3.noarch.rpm
output is as follows
Name : epel-release Relocations: (not relocatable)
Version : 5 Vendor: Fedora Project
Release : 3 Build Date: Fri 25 Apr 2008 10:16:23 PM GST
Install Date: (not installed) Build Host: ppc2.fedora.redhat.com
Group : System Environment/Base Source RPM: epel-release-5-3.src.rpm
Size : 22091 License: GPL
Signature : DSA/SHA1, Sat 26 Apr 2008 04:03:47 AM GST, Key ID 119cc036217521f6
Packager : Fedora Project
URL : http://download.fedoraproject.org/pub/epel
Summary : Extra Packages for Enterprise Linux repository configuration
Description : This package contains the Extra Packages for Enterprise Linux (EPEL) repository
GPG key as well as configuration for yum.
7-List all installed RPM on your system
rpm -qa
8-Search for a installed RPM
rpm -qa | grep package-name
rpm -qa | grep epel-release
9-Print which package a file belongs
rpm -qf /path/to/file
eg : rpm -qf /usr/share/doc/epel-release-5
10-List out configuration file for a RPM
rpm -qc package-name
eg: rpm -qc epel-release
11-List package dependencies
rpm -qpR package-name.rpm
eg: rpm -qpR epel-release-5-3.noarch.rpm
12-Integrity check
rpm -V package-name
rpm -V epel-release
13-Integrity check for a RPM
rpm -Vp package-name.rpm
eg: rpm -Vp epel-release-5-3.noarch.rpm
14-Extract files from a RPM into current directory
rpm2cpio package-name.rpm | cpio -idv
eg: rpm2cpio epel-release-5-3.noarch.rpm | cpio -idv
15-To compile a rpm
rpmbuild -ba something.spec
16- compile a rpm from its source file
rpmbuild --rebuild package-name.src.rpm