Documente Academic
Documente Profesional
Documente Cultură
20PracticalExamplesofRPMCommandsinLinux
20PracticalExamplesofRPMCommandsinLinux
byRaviSaive|Published:April10,2013|LastUpdated:January3,2015
DownloadYourFreeeBooksNOW10FreeLinuxeBooksforAdministrators|4FreeShell
ScriptingeBooks
RPM(RedHatPackageManager)isandefaultopensourceand
mostpopularpackagemanagementutilityforRedHatbased
systemslike(RHEL,CentOSandFedora).Thetoolallowssystem
administratorsandusers
toinstall,update,uninstall,query,verifyandmanagesystem
softwarepackagesinUnix/Linuxoperatingsystems.TheRPM
formerlyknownas.rpmfile,thatincludescompiledsoftware
programsandlibrariesneededbythepackages.Thisutilityonly
workswithpackagesthatbuilton.rpmformat.
20MostUsefulRPMCommandExamples
Thisarticleprovidessomeuseful20RPMcommandexamplesthat
mightbehelpfultoyou.Withthehelpoftheserpmcommandyou
canmanagedtoinstall,update,removepackagesinyourLinux
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
1/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
systems.
SomeFactsaboutRPM(RedHat
PackageManager)
RPMisfreeandreleasedunderGPL(GeneralPublicLicense).
RPMkeepstheinformationofalltheinstalledpackages
under/var/lib/rpmdatabase.
RPMistheonlywaytoinstallpackagesunderLinuxsystems,
ifyouveinstalledpackagesusingsourcecode,thenrpmwont
manageit.
RPMdealswith.rpmfiles,whichcontainstheactualinformation
aboutthepackagessuchas:whatitis,fromwhereit
comes,dependenciesinfo,versioninfoetc.
Therearefivebasicmodesfor
RPMcommand
Install:ItisusedtoinstallanyRPMpackage.
Remove:Itisusedtoerase,removeoruninstallanyRPM
package.
Upgrade:ItisusedtoupdatetheexistingRPMpackage.
Verify:ItisusedtoqueryaboutdifferentRPMpackages.
Query:ItisusedfortheverificationofanyRPMpackage.
WheretofindRPMpackages
Belowisthelistofrpmsites,whereyoucanfindanddownload
allRPMpackages.
http://rpmfind.net
http://www.redhat.com
http://freshrpms.net/
http://rpm.pbone.net/
ReadAlso:
20YUMCommandExamplesinLinux
10WgetCommandExamplesinLinux
30MostUsefulLinuxCommandsforSystemAdministrators
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
2/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
Pleaserememberyoumustberootuserwheninstallingpackages
inLinux,withtherootprivilegesyoucanmanagerpmcommands
withtheirappropriateoptions.
1.HowtoCheckanRPM
SignaturePackage
AlwayscheckthePGPsignatureofpackagesbeforeinstallingthem
onyourLinuxsystemsandmakesureitsintegrityandoriginisOK.
Usethefollowingcommandwithchecksig(checksignature)option
tocheckthesignatureofapackagecalledpidgin.
[root@tecmint]#rpmchecksigpidgin2.7.95.el6.2
.i686.rpm
pidgin2.7.95.el6.2.i686.rpm:rsasha1(md5)pgpm
d5OK
2.HowtoInstallanRPMPackage
Forinstallinganrpmsoftwarepackage,usethefollowingcommand
withioption.Forexample,toinstallanrpmpackagecalledpidgin
2.7.95.el6.2.i686.rpm.
[root@tecmint]#rpmivhpidgin2.7.95.el6.2.i686.
rpm
Preparing...#######################
####################[100%]
1:pidgin#######################
####################[100%]
RPMcommandandoptions
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
3/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
i:installapackage
v:verboseforanicerdisplay
h:printhashmarksasthepackagearchiveisunpacked.
3.Howtocheckdependenciesof
RPMPackagebeforeInstalling
Letssayyouwouldliketodoadependencycheckbeforeinstalling
orupgradingapackage.Forexample,usethefollowingcommandto
checkthedependenciesofBitTorrent5.2.21
Python2.4.noarch.rpmpackage.Itwilldisplaythelistof
dependenciesofpackage.
[root@tecmint]#rpmqpRBitTorrent5.2.21Python2
.4.noarch.rpm
/usr/bin/python2.4
python>=2.3
python(abi)=2.4
pythoncrypto>=2.0
pythonpsyco
pythontwisted>=2.0
pythonzopeinterface
rpmlib(CompressedFileNames)=2.6
RPMcommandandoptions
q:Queryapackage
p:Listcapabilitiesthispackageprovides.
R:Listcapabilitiesonwhichthispackagedepends..
4.HowtoInstallaRPMPackage
WithoutDependencies
IfyouknowthatallneededpackagesarealreadyinstalledandRPM
isjustbeingstupid,youcanignorethosedependenciesbyusingthe
optionnodeps(nodependenciescheck)beforeinstallingthe
package.
[root@tecmint]#rpmivhnodepsBitTorrent5.2.2
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
4/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
1Python2.4.noarch.rpm
Preparing...#######################
####################[100%]
1:BitTorrent#######################
####################[100%]
Theabovecommandforcefullyinstallrpmpackagebyignoring
dependencieserrors,butifthosedependencyfilesaremissing,then
theprogramwillnotworkatall,untilyouinstallthem.
5.HowtocheckanInstalledRPM
Package
Usingqoptionwithpackagename,willshowwhetheranrpm
installedornot.
[root@tecmint]#rpmqBitTorrent
BitTorrent5.2.21.noarch
6.HowtoListallfilesofan
installedRPMpackage
Toviewallthefilesofaninstalledrpmpackages,usetheql(query
list)withrpmcommand.
[root@tecmint]#rpmqlBitTorrent
/usr/bin/bittorrent
/usr/bin/bittorrentconsole
/usr/bin/bittorrentcurses
/usr/bin/bittorrenttracker
/usr/bin/changetrackerconsole
/usr/bin/launchmanyconsole
/usr/bin/launchmanycurses
/usr/bin/maketorrent
/usr/bin/maketorrentconsole
/usr/bin/torrentinfoconsole
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
5/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
7.HowtoListRecentlyInstalled
RPMPackages
Usethefollowingrpmcommandwithqa(queryall)option,willlist
alltherecentlyinstalledrpmpackages.
[root@tecmint]#rpmqalast
BitTorrent5.2.21.noarchTue0
4Dec201205:14:06PMBDT
pidgin2.7.95.el6.2.i686Tue0
4Dec201205:13:51PMBDT
cyrussasldevel2.1.2313.el6_3.1.i686Tue0
4Dec201204:43:06PMBDT
cyrussasl2.1.2313.el6_3.1.i686Tue0
4Dec201204:43:05PMBDT
cyrussaslmd52.1.2313.el6_3.1.i686Tue0
4Dec201204:43:04PMBDT
cyrussaslplain2.1.2313.el6_3.1.i686Tue0
4Dec201204:43:03PMBDT
8.HowtoListAllInstalledRPM
Packages
Typethefollowingcommandtoprinttheallthenamesofinstalled
packagesonyourLinuxsystem.
[root@tecmint]#rpmqa
initscripts9.03.312.el6.centos.i686
polkitdesktoppolicy0.962.el6_0.1.noarch
thunderbird17.01.el6.remi.i686
9.HowtoUpgradeaRPM
Package
IfwewanttoupgradeanyRPMpackageU(upgrade)optionwill
beused.Oneofthemajoradvantagesofusingthisoptionisthatit
willnotonlyupgradethelatestversionofanypackage,butitwill
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
6/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
alsomaintainthebackupoftheolderpackagesothatincaseifthe
newerupgradedpackagedoesnotrunthepreviouslyinstalled
packagecanbeusedagain.
[root@tecmint]#rpmUvhnx3.5.02.el6.centos.i686
.rpm
Preparing...#######################
####################[100%]
1:nx#######################
####################[100%]
10.HowtoRemoveaRPM
Package
TouninstallanRPMpackage,forexampleweusethepackage
namenx,nottheoriginalpackagenamenx3.5.0
2.el6.centos.i686.rpm.Thee(erase)optionisusedtoremove
package.
[root@tecmint]#rpmevvnx
11.HowtoRemoveanRPM
PackageWithoutDependencies
Thenodeps(Donotcheckdependencies)optionforcefullyremove
therpmpackagefromthesystem.Butkeepinmindremoving
particularpackagemaybreakotherworkingapplications.
[root@tecmint]#rpmevnodepsvsftpd
12.HowtoQueryafilethat
belongswhichRPMPackage
Letssay,youhavelistoffilesandyouwouldliketofindoutwhich
packagebelongstothesefiles.Forexample,thefollowingcommand
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
7/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
withqf(queryfile)optionwillshowyouafile/usr/bin/htpasswdis
ownbypackagehttpdtools2.2.1515.el6.centos.1.i686.
[root@tecmint]#rpmqf/usr/bin/htpasswd
httpdtools2.2.1515.el6.centos.1.i686
13.HowtoQueryaInformationof
InstalledRPMPackage
Letssayyouhaveinstalledanrpmpackageandwanttoknowthe
informationaboutthepackage.Thefollowingqi(queryinfo)option
willprinttheavailableinformationoftheinstalledpackage.
[root@tecmint]#rpmqivsftpd
Name:vsftpd
Relocations:(notrelocatable)
Version:2.2.2
Vendor:CentOS
Release:11.el6
BuildDate:Fri22Jun201201:54:24PMBDT
InstallDate:Mon17Sep201207:55:28PMBDT
BuildHost:c6b8.bsys.dev.centos.org
Group:SystemEnvironment/Daemons
SourceRPM:vsftpd2.2.211.el6.src.rpm
Size:351932
License:GPLv2withexceptions
Signature:RSA/SHA1,Mon25Jun201204:07:34AM
BDT,KeyID0946fca2c105b9de
Packager:CentOSBuildSystem<http://bugs.cento
s.org>
URL:http://vsftpd.beasts.org/
Summary:VerySecureFtpDaemon
Description:
vsftpdisaVerySecureFTPdaemon.Itwaswritten
completelyfrom
scratch.
14.GettheInformationofRPM
PackageBeforeInstalling
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
8/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
Youhavedownloadapackagefromtheinternetandwanttoknow
theinformationofapackagebeforeinstalling.Forexample,the
followingoptionqip(queryinfopackage)willprinttheinformationof
apackagesqlbuddy.
[root@tecmint]#rpmqipsqlbuddy1.3.31.noarch.rp
m
Name:sqlbuddyRelocati
ons:(notrelocatable)
Version:1.3.3Vendor:
(none)
Release:1BuildDa
te:Wed02Nov201111:01:21PMBDT
InstallDate:(notinstalled)BuildHo
st:rpm.bar.baz
Group:Applications/InternetSourceR
PM:sqlbuddy1.3.31.src.rpm
Size:1155804License:
MIT
Signature:(none)
Packager:ErikMJacobs
URL:http://www.sqlbuddy.com/
Summary:SQLBuddyWebbasedMySQLadministr
ation
Description:
SQLBuddyisaPHPscriptthatallowsforwebbased
MySQLadministration.
15.HowtoQuerydocumentation
ofInstalledRPMPackage
Togetthelistofavailabledocumentationofaninstalledpackage,
usethefollowingcommandwithoptionqdf(querydocumentfile)
willdisplaythemanualpagesrelatedtovmstatpackage.
[root@tecmint]#rpmqdf/usr/bin/vmstat
/usr/share/doc/procps3.2.8/BUGS
/usr/share/doc/procps3.2.8/COPYING
/usr/share/doc/procps3.2.8/COPYING.LIB
/usr/share/doc/procps3.2.8/FAQ
/usr/share/doc/procps3.2.8/NEWS
/usr/share/doc/procps3.2.8/TODO
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
9/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
16.HowtoVerifyaRPMPackage
Verifyingapackagecomparesinformationofinstalledfilesofthe
packageagainsttherpmdatabase.TheVp(verifypackage)is
usedtoverifyapackage.
[root@tecmintdownloads]#rpmVpsqlbuddy1.3.31.
noarch.rpm
S.5....T.c/etc/httpd/conf.d/sqlbuddy.conf
17.HowtoVerifyallRPM
Packages
Typethefollowingcommandtoverifyalltheinstalledrpmpackages.
[root@tecmint]#rpmVa
S.5....T.c/etc/rc.d/rc.local
.......T.c/etc/dnsmasq.conf
.......T./etc/ld.so.conf.d/kernel2.6.32279.5.
2.el6.i686.conf
S.5....T.c/etc/yum.conf
S.5....T.c/etc/yum.repos.d/epel.repo
18.HowtoImportanRPMGPG
key
ToverifyRHEL/CentOS/Fedorapackages,youmustimport
theGPGkey.Todoso,executethefollowingcommand.Itwill
importCentOS6GPGkey.
[root@tecmint]#rpmimport/etc/pki/rpmgpg/RPMG
PGKEYCentOS6
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
10/11
12/20/2015
20PracticalExamplesofRPMCommandsinLinux
19.HowtoListallImportedRPM
GPGkeys
ToprintalltheimportedGPGkeysinyoursystem,usethefollowing
command.
[root@tecmint]#rpmqagpgpubkey*
gpgpubkey0608b8954bd22942
gpgpubkey7fac59914615767f
gpgpubkey0f2672c84cd950ee
gpgpubkeyc105b9de4e0fd3a3
gpgpubkey00f97f56467e318a
gpgpubkey6b8d79e63f49313d
gpgpubkey849c449f4cb9df30
20.HowTorebuildCorrupted
RPMDatabase
Sometimesrpmdatabasegetscorruptedandstopsallthe
functionalityofrpmandotherapplicationsonthesystem.So,atthe
timeweneedtorebuildtherpmdatabaseandrestoreitwiththehelp
offollowingcommand.
[root@tecmint]#cd/var/lib
[root@tecmint]#rm__db*
[root@tecmint]#rpmrebuilddb
[root@tecmint]#rpmdb_verifyPackages
http://www.tecmint.com/20practicalexamplesofrpmcommandsinlinux/
11/11