Thursday, November 7, 2013

RPM command cheat sheet for RH Linux

rpm is a powerful Package Manager for Red Hat, Suse and Fedora Linux. It can be used to build, install, query, verify, update, and remove/erase individual software packages. A Package consists of an archive of files, and package information, including name, version, and description:

Syntax Description Example(s)
rpm -ivh {rpm-file} Install the package rpm -ivh mozilla-mail-1.7.5-17.i586.rpm
rpm -ivh --test mozilla-mail-1.7.5-17.i586.rpm
rpm -Uvh {rpm-file} Upgrade package rpm -Uvh mozilla-mail-1.7.6-12.i586.rpm
rpm -Uvh --test mozilla-mail-1.7.6-12.i586.rpm
rpm -ev {package} Erase/remove/ an installed package rpm -ev mozilla-mail
rpm -ev --nodeps {package} Erase/remove/ an installed package without checking for dependencies rpm -ev --nodeps mozilla-mail
rpm -qa Display list all installed packages rpm -qa
rpm -qa | less
rpm -qi {package} Display installed information along with package version and short description rpm -qi mozilla-mail
rpm -qf {/path/to/file} Find out what package a file belongs to i.e. find what package owns the file rpm -qf /etc/passwd
rpm -qf /bin/bash
rpm -qc {pacakge-name} Display list of configuration file(s) for a package rpm -qc httpd
rpm -qcf {/path/to/file} Display list of configuration files for a command rpm -qcf /usr/X11R6/bin/xeyes
rpm -qa --last Display list of all recently installed RPMs rpm -qa --last
rpm -qa --last | less
rpm -qpR {.rpm-file}
rpm -qR {package}
Find out what dependencies a rpm file has rpm -qpR mediawiki-1.4rc1-4.i586.rpm
rpm -qR bash
{package} - Replace with actual package name 


RPM is nothing but a a package management system. To install an rpm file, open a terminal and then type the following command:
 
rpm -ivh .rpm.file-name
 
Please note that you need to log in as root, or use the su command to change to the root user to install the software using rpm command:
$ su -

Install RPM File

To install an rpm file called awstats.i386.rpm, enter:
# rpm -ivh awstats.i386.rpm

Note: you can download the package in rpm format from the official project web pages or public ftp servers.

 Upgrade RPM File

Type the following command:
# rpm -Uvh awstats.i386.rpm

If you are upgrading from an earlier version of the software package, use upgrade mode command as described above.


Erase (Delete) RPM File (package)

Type the following command:
# rpm -ev packagename
To find list of all install packages, enter:
# rpm -qa
# rpm -qa | less
# rpm -qa | grep something

Sample outputs:
comps-extras-11.1-1.1
libattr-2.4.32-1.1
libidn-0.6.5-1.1
grep-2.5.1-55.el5
libxslt-1.1.17-2.el5_2.2
perl-Digest-SHA1-2.11-1.2.1
time-1.7-27.2.2
libdaemon-0.10-5.el5
....
.....
..
mysql-server-5.0.77-4.el5_5.5
mysql-devel-5.0.77-4.el5_5.5
samba-client-3.0.33-3.29.el5_6.2
pcre-6.6-6.el5_6.1
yum-rhn-plugin-0.5.4-17.el5_6.1
libtiff-3.8.2-7.el5_6.7
nash-5.1.19.6-68.el5_6.1
quota-3.13-5.el5
xorg-x11-server-Xorg-1.1.1-48.76.el5_6.4
xorg-x11-server-Xnest-1.1.1-48.76.el5_6.4

To remove samba-client-3.0.33-3.29.el5_6.2, enter:
# rpm -ev samba-client-3.0.33-3.29.el5_6.2


 

No comments:

Post a Comment