Wednesday, 3 July 2013

Some useful RPM commands in Linux

RPM (Red Hat Package Manager) 

RPM keeps the information of all the installed packages under /var/lib/rpm database.


RPM is the only way to install packages under Linux systems, if you’ve installed packages using source code, then rpm won’t manage it.


RPM deals with .rpm files, which contains the actual information about the packages such as: what it is, from where it comes, dependencies info, version info etc.


There are five basic modes for RPM command

Install : It is used to install any RPM package.
Remove:It is used to erase,remove or un-install any 

           RPM package.
Upgrade : It is used to update the existing RPM package.
Verify : It is used to query about different RPM packages.
Query : It is used for the verification of any RPM package.

Please remember you must be root user when installing packages in Linux, with the root privileges you can manage rpm commands with their appropriate options. 


1.Check an RPM Signature Package

Always check the PGP signature of packages before installing them on your Linux systems and make sure its integrity and origin is OK.

# rpm --checksig epel-release-5-4.noarch.rpm

2.How to Install an RPM Package

# rpm -ivh epel-release-5-4.noarch.rpm

 -i : install a package
 -v : verbose for a nicer display
 -h : print hash marks as the package archive is unpacked.

3.How to check dependencies of RPM Package before Installing

# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm


 -q : Query a package
 -p : List capabilities this package provides.
 -R : List capabilities on which this package depends..

4.How to Install a RPM Package Without Dependencies

# rpm -ivh --nodeps epel-release-5-4.noarch.rpm

above command forcefully install rpm package by ignoring dependencies errors, but if those dependency files are missing, then the program will not work at all, until you install them.

5.How to check an Installed RPM Package

# rpm -q BitTorrent-5.2.2-1-Python2.4.noarch.rpm

6.How to List all files of an installed RPM package

# rpm -ql BitTorrent

7.How to List Recently Installed RPM Packages

# rpm -qa --last

to List All Installed RPM Packages


# rpm -qa

8.How to upgrade rpm package

# rpm -Uvh epel-release-5-4.noarch.rpm

9.To Remove a RPM Package

# rpm -e packagename

-e --- erase

10.How to Remove an RPM Package Without Dependencies

# rpm -ev --nodeps packagename

11.How to Query a file that belongs which RPM Package

# rpm -qf /usr/bin/htpasswd

-qf -- query file

12.How to Query a Information of Installed RPM Package

# rpm -qi vsftpd

-qi (query info)

13.How to Query documentation of Installed RPM Package

# rpm -qdf /usr/bin/vmstat
-qdf (query document file)

14.How to Verify a RPM Package

# rpm -Vp BitTorrent-5.2.2-1-Python2.4.noarch.rpm


Verifying a package compares information of installed files of the package against the rpm database.
 

The -Vp (verify package) is used to verify a package.

How to Verify all RPM Packages
# rpm -Va

15.How to Import an RPM GPG key

# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

16.How to List all Imported RPM GPG keys

# rpm -qa gpg-pubkey*

17.How To rebuild Corrupted RPM Database

Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system.
So, at the time we need to rebuild the rpm database and restore it with the help of following command.

# cd /var/lib
# rm __db*
# rpm --rebuilddb
# rpmdb_verify Packages


No comments:

Post a Comment