rpm command 15 examples to install, uninstall, upgrade, query rpm packages

14
≡ Menu Home Free eBook Start Here Contact About RPM Command: 15 Examples to Install, Uninstall, Upgrade, Query RPM Packages by Sasikala on July 7, 2010 Tweet RPM command is used for installing, uninstalling, upgrading, querying, listing, and checking RPM packages on your Linux system. RPM stands for Red Hat Package Manager. With root privilege, you can use the rpm command with appropriate options to manage the RPM software packages. In this article, let us review 15 practical examples of rpm command. Riverhawk MP0273,HP5852 New Hydraulic PumpPusher Assembly Hub Installation & Removal IM118

Upload: jmerejoc

Post on 17-Sep-2015

276 views

Category:

Documents


0 download

DESCRIPTION

Linux RedHat RPM Commands

TRANSCRIPT

  • 6Menu

    HomeFreeeBookStartHereContactAbout

    RPMCommand:15ExamplestoInstall,Uninstall,Upgrade,QueryRPMPackagesbySasikalaonJuly7,2010

    Tweet

    RPMcommandisusedforinstalling,uninstalling,upgrading,querying,listing,andcheckingRPMpackagesonyourLinuxsystem.

    RPMstandsforRedHatPackageManager.

    Withrootprivilege,youcanusetherpmcommandwithappropriateoptionstomanagetheRPMsoftwarepackages.

    Inthisarticle,letusreview15practicalexamplesofrpmcommand.

    RiverhawkMP0273,HP5852NewHydraulicPumpPusherAssemblyHubInstallation&RemovalIM118

  • LetustakeanrpmofMysqlClientandrunthroughallourexamples.

    1.InstallingaRPMpackageUsingrpmivh

    RPMfilenamehaspackagename,version,releaseandarchitecturename.

    Forexample,IntheMySQLclient3.23.571.i386.rpmfile:

    MySQLclientPackageName3.23.57Version1Releasei386Architecture

    WhenyouinstallaRPM,itcheckswhetheryoursystemissuitableforthesoftwaretheRPMpackagecontains,figuresoutwheretoinstallthefileslocatedinsidetherpmpackage,installsthemonyoursystem,andaddsthatpieceofsoftwareintoitsdatabaseofinstalledRPMpackages.

    ThefollowingrpmcommandinstallsMysqlclientpackage.

    #rpmivhMySQLclient3.23.571.i386.rpmPreparing...###########################################[100%]1:MySQLclient###########################################[100%]

    rpmcommandandoptions

    i:installapackagev:verboseh:printhashmarksasthepackagearchiveisunpacked.

    YoucanalsousedpkgonDebian,pkgaddonSolaris,depotonHPUXtoinstallpackages.

    2.QueryalltheRPMPackagesusingrpmqa

    Youcanuserpmcommandtoqueryallthepackagesinstalledinyoursystem.

    #rpmqacdrecord2.0110.7.el5bluezlibs3.71.1setarch2.01.1

  • ..

    qqueryoperationaqueriesallinstalledpackages

    Toidentifywhetheraparticularrpmpackageisinstalledonyoursystem,combinerpmandgrepcommandasshownbelow.Followingcommandcheckswhethercdrecordpackageisinstalledonyoursystem.

    #rpmqa|grep'cdrecord'

    3.QueryaParticularRPMPackageusingrpmq

    Theaboveexamplelistsallcurrentlyinstalledpackage.Afterinstallationofapackagetochecktheinstallation,youcanqueryaparticularpackageandverifyasshownbelow.

    #rpmqMySQLclientMySQLclient3.23.571

    #rpmqMySQLpackageMySQLisnotinstalled

    Note:Toqueryapackage,youshouldspecifytheexactpackagename.Ifthepackagenameisincorrect,thenrpmcommandwillreportthatthepackageisnotinstalled.

    4.QueryRPMPackagesinavariousformatusingrpmqueryformat

    Rpmcommandprovidesanoptionqueryformat,whichallowsyoutogivetheheadertagnames,tolistthepackages.Enclosetheheadertagwithin{}.

    #rpmqaqueryformat'%{name%{version}%{release}%{size}\n'cdrecord2.0110.712324bluezlibs3.71.15634setarch2.01.1235563..

    #

    5.WhichRPMpackagedoesafilebelongto?Userpmqf

    Letussay,youhavelistoffilesandyouwouldwanttoknowwhichpackageownsallthesefiles.rpmcommandhasoptionstoachievethis.

    Thefollowingexampleshowsthat/usr/bin/mysqlaccessfileispartoftheMySQLclient3.23.571rpm.

    #rpmqf/usr/bin/mysqlaccessMySQLclient3.23.571

    f:filename

    6.Locatedocumentationofapackagethatownsfileusingrpmqdf

    Usethefollowingtoknowthelistofdocumentations,forapackagethatownsafile.Thefollowingcommand,givesthelocationofallthemanualpagesrelatedtomysqlpackage.

  • #rpmqdf/usr/bin/mysqlaccess/usr/share/man/man1/mysql.1.gz/usr/share/man/man1/mysqlaccess.1.gz/usr/share/man/man1/mysqladmin.1.gz/usr/share/man/man1/mysqldump.1.gz/usr/share/man/man1/mysqlshow.1.gz

    d:refersdocumentation.

    7.InformationaboutInstalledRPMPackageusingrpmqi

    rpmcommandprovidesalotofinformationaboutaninstalledpacakgeusingrpmqiasshownbelow:

    #rpmqiMySQLclientName:MySQLclientRelocations:(notrelocatable)Version:3.23.57Vendor:MySQLABRelease:1BuildDate:Mon09Jun200311:08:28PMCESTInstallDate:Mon06Feb201003:19:16AMPSTBuildHost:build.mysql.comGroup:Applications/DatabasesSourceRPM:MySQL3.23.571.src.rpmSize:5305109License:GPL/LGPLSignature:(none)Packager:LenzGrimmerURL:http://www.mysql.com/Summary:MySQLClientDescription:ThispackagecontainsthestandardMySQLclients.

    IfyouhaveanRPMfilethatyouwouldliketoinstall,butwanttoknowmoreinformationaboutitbeforeinstalling,youcandothefollowing:

    #rpmqipMySQLclient3.23.571.i386.rpmName:MySQLclientRelocations:(notrelocatable)Version:3.23.57Vendor:MySQLABRelease:1BuildDate:Mon09Jun200311:08:28PMCESTInstallDate:(notinstalled)BuildHost:build.mysql.comGroup:Applications/DatabasesSourceRPM:MySQL3.23.571.src.rpmSize:5305109License:GPL/LGPLSignature:(none)Packager:LenzGrimmerURL:http://www.mysql.com/Summary:MySQLClientDescription:ThispackagecontainsthestandardMySQLclients.

    i:viewinformationaboutanrpmp:specifyapackagename

    8.ListalltheFilesinaPackageusingrpmqlp

    TolistthecontentofaRPMpackage,usethefollowingcommand,whichwilllistoutthefileswithoutextractingintothelocaldirectoryfolder.

    $rpmqlpovpc2.1.10.rpm/usr/bin/mysqlaccess/usr/bin/mysqldata/usr/bin/mysqlperm../usr/bin/mysqladmin

    q:querytherpmfile

  • l:listthefilesinthepackagep:specifythepackagename

    YoucanalsoextractfilesfromRPMpackageusingrpm2cpioaswediscussedearlier.

    9.ListtheDependencyPackagesusingrpmqRP

    Toviewthelistofpackagesonwhichthispackagedepends,

    #rpmqRpMySQLclient3.23.571.i386.rpm/bin/sh/usr/bin/perl

    10.Findoutthestateoffilesinapackageusingrpmqsp

    Thefollowingcommandistofindstate(installed,replacedornormal)forallthefilesinaRPMpackage.

    #rpmqspMySQLclient3.23.571.i386.rpmnormal/usr/bin/msql2mysqlnormal/usr/bin/mysqlnormal/usr/bin/mysql_find_rowsnormal/usr/bin/mysqlaccessnormal/usr/bin/mysqladminnormal/usr/bin/mysqlbinlognormal/usr/bin/mysqlchecknormal/usr/bin/mysqldumpnormal/usr/bin/mysqlimportnormal/usr/bin/mysqlshownormal/usr/share/man/man1/mysql.1.gznormal/usr/share/man/man1/mysqlaccess.1.gznormal/usr/share/man/man1/mysqladmin.1.gznormal/usr/share/man/man1/mysqldump.1.gznormal/usr/share/man/man1/mysqlshow.1.gz

    11.VerifyaParticularRPMPackageusingrpmVp

    Verifyingapackagecomparesinformationabouttheinstalledfilesinthepackagewithinformationaboutthefilestakenfromthepackagemetadatastoredintherpmdatabase.Inthefollowingcommand,Visforverificationandpoptionisusedtospecifyapackagenametoverify.

    #rpmVpMySQLclient3.23.571.i386.rpmS.5....Tc/usr/bin/msql2mysqlS.5....Tc/usr/bin/mysqlS.5....Tc/usr/bin/mysql_find_rowsS.5....Tc/usr/bin/mysqlaccess

    Thecharacterintheaboveoutputdenotesthefollowing:

    SfileSizediffersMModediffers(includespermissionsandfiletype)5MD5sumdiffersDDevicemajor/minornumbermismatchLreadlink(2)pathmismatchUUserownershipdiffersGGroupownershipdiffersTmTimediffers

  • 6 Tweet

    12.VerifyaPackageOwningfileusingrpmVf

    Thefollowingcommandverifythepackagewhichownsthegivenfilename.

    #rpmVf/usr/bin/mysqlaccessS.5....Tc/usr/bin/mysql#

    13.UpgradingaRPMPackageusingrpmUvh

    Upgradingapackageissimilartoinstallingone,butRPMautomaticallyuninstallsexistingversionsofthepackagebeforeinstallingthenewone.Ifanoldversionofthepackageisnotfound,theupgradeoptionwillstillinstallit.

    #rpmUvhMySQLclient3.23.571.i386.rpmPreparing... ###########################################[100%]1:MySQLclient###########################################

    14.UninstallingaRPMPackageusingrpme

    Toremoveaninstalledrpmpackageusingeasshownbelow.Afteruninstallation,youcanqueryusingrpmqaandverifytheuninstallation.

    #rpmevMySQLclient

    15.VerifyingalltheRPMPackagesusingrpmVa

    Thefollowingcommandverifiesalltheinstalledpackages.

    #rpmVaS.5....Tc/etc/issueS.5....Tc/etc/issue.netS.5....Tc/var/service/imap/ssl/seedS.5....Tc/home/httpd/html/horde/ingo/config/backends.php..S.5....Tc/home/httpd/html/horde/ingo/config/prefs.phpS.5....Tc/etc/printcap

    >Addyourcomment

    Ifyouenjoyedthisarticle,youmightalsolike..

    1. 50LinuxSysadminTutorials2. 50MostFrequentlyUsedLinuxCommands(With

    Examples)3. Top25BestLinuxPerformanceMonitoringand

    DebuggingTools4. Mommy,Ifoundit!15PracticalLinuxFind

    CommandExamples5. Linux101Hacks2ndEditioneBook

    AwkIntroduction7AwkPrintExamplesAdvancedSedSubstitutionExamples8EssentialVimEditorNavigationFundamentals25MostFrequentlyUsedLinuxIPTablesRulesExamplesTurbochargePuTTYwith12PowerfulAddOns

  • Taggedas:CentOSRPM,RedHatRPM,RHELRPM,RPM2,RPMi386,RPMPackage

    {26commentsaddone}

    JoshJuly7,2010,12:12pm

    On#4itappearsyouhaveatypo.Ithinkyouleftoffaclosebracket}afterthenamefield.

    Youwrote:rpmqaqueryformat%{name%{version}%{release}%{size}\n

    Shouldbe:rpmqaqueryformat%{name}%{version}%{release}%{size}\n

    LinkJoshJuly7,2010,12:16pm

    Oh,andatleastonmyRHEL4systems,therpmvflagisforverbose,Visforverify.

    LinkdiptanupaulJuly8,2010,12:30am

    Ihaveaproblemwithrpm.Irecentrlyinstalledonerpmbpowerd3.0b11inmysystemandlaterifoundthatidonotrequireit.butwheniremoveitusingrpme..itgivesanerror.Pleasesuggest[root@www~]#rpmqa|grepibpowerd3.0b11bpowerd3.0b11[root@www~]#rpmebpowerd3.0b11errorreadinginformationonservicebpowerd:Nosuchfileordirectoryerror:%postun(bpowerd3.0b11.i386)scriptletfailed,exitstatus1[root@www~]#rpmqa|grepibpowerd3.0b11bpowerd3.0b11[root@www~]#

    Howtoremovethesamefromtherpmlist,Pleaseguide

    LinkArjanJuly8,2010,12:56am

    Ifyouaresurethebpowerdserviceisnotrunninganymore,youcouldttryrpmenopostunbpowerd3.0b11

  • LinkdiptanuJuly8,2010,1:55am

    Arjan,Thanksalot.Itworked.Icompletelymissedtochecktheoptionwhilelookingoutforthesolution..Thanksagain

    LinkBalaCJuly9,2010,7:52am

    rpmqlpwasaworthyone.ineedthemmostly

    LinkGautamKashyapAugust17,2010,12:49am

    Gr8postisthereanywaytorollbacktheoldpackageafterupgradation???

    LinkmanojNovember23,2010,6:30am

    Theabovestuffisworthknowingforthosewhowanttoworkonlinux

    LinkpsankarDecember13,2010,5:21am

    pls,explaintomehowtounderstandrpmcommandsinlinuxRHEL5serverandhowwecangetallrpmpackagesanditscommandsforinstallationanduninstallwithitsownsys

    LinkjmartinezJanuary24,2011,12:39pm

    Prettygoodinformation.IaddedabookmarksinceImalwayslookingforoneofthesecommandsthroughouttheday.

    Ididseeonemistake,however.rpmqigivesyouinformationaboutaninstalledpackage.

    TheexampleyouusedwithrpmqipMySQLclient3.23.571.i386.rpmishowyougetinformationaboutapackagefromtheRPMfile.ThatswhytheInstallDateintheoutputshowsthatitsnotinstalled.Thepswitchtakesanrpmfileasitsargument.

    LinkarunprakashNovember26,2011,2:42am

    veryusefulexamples..thanksalot

    LinkOpenSourceDecember5,2011,3:02am

    #11.VerifyaParticularRPMPackageusingrpmvp

    itshouldbeV(incaps)andnotv(inlowercase)

    VerifyoptionV(caps)=================rpm{V|verify}

  • v(smallcase)============vPrintverboseinformationnormallyroutineprogressmessageswillbedisplayed

    LinkRameshNatarajanFebruary8,2012,11:09am

    @jmartinez,

    Youareright.Thanksforpointingitout.Iveupdateditem#7accordingly.

    @OpenSource,

    Thanksforpointingitout.Ivefixedit.

    LinksenthamilJuly21,2012,7:30am

    allinformationveryusefull,thanks

    LinkMadhuriNovember11,2012,12:14am

    ExcellentInfo..AwesomeExplanationandveryuseful.

    Regards.,Madhuri

    LinkKannanNovember14,2012,3:41am

    Hi,

    Pleaseletmeknowthathowtologinwithpostgresql@redhatlinux.

    RegardsKannan

    LinknareenJanuary22,2013,5:08am

    howtorunvlcplayerfromrootuser

    LinkphaniApril1,2013,1:50pm

    Goodarticle

    thanks

    LinkAbhinavAugust22,2013,2:40am

    awesomearticle!!

  • LinkmadhuAugust23,2013,12:55am

    Superbarticle!Veryuseful!

    LinkTimApril28,2014,5:23pm

    VeryinterestingbutonecommandescapemeIwanttoknowwhatprogramsuseaparticularpackage/dependency?EG.Iinstallaprogram,yum(orrpm)identifiesthedependenciesthisprogramrequiresandinstallsthemalongwiththeprogram.

    IfIhaveapackagewhichisadependencyhowdoIfindoutwhatotherprogramsneedthispackage?AtthemomentIhavex86&64bitversionsofmediainfowhichiscausingyumupdatemanyproblems!

    Cheers

    LinkAnonymousJuly2,2014,1:00am

    Goodpost..

    LinkniranjanaAugust4,2014,10:58pm

    howtoinstallrpmpackageinubuntu.ialreadytriedmanycommandsbutnotworkout

    LinkgauravAugust29,2014,9:59pm

    HiRamesh,

    HowdoIcreatearpmpackagetoinstallbunchrpmsfromavendorwithpreandpostbashscripttodosomecustomconfigchecks?

    LinkarunOctober20,2014,9:00pm

    HiRamesh,IsthereanywaytomodifyRPMmetadatalikeBuilddate,version,Installdate?

    Arun

    LinkJalalHajigholamaliApril21,2015,9:41pm

    Hi,Verynicearticlethanksalot

    Link

    LeaveaComment

    Name

  • Email

    Website

    Comment

    Submit

    Notifymeoffollowupcommentsviaemail

    Nextpost:8PostgreSQLDateandTimeFunctionExamples

    Previouspost:ScreenCommandExamples:GetControlofLinux/UnixTerminal

    RSS|Email|Twitter|Facebook|Google+

    Search

    EBOOKS

    Linux101Hacks2ndEditioneBookPracticalExamplestoBuildaStrongFoundationinLinuxBash101HackseBookTakeControlofYourBashCommandLineandShellScriptingSedandAwk101HackseBookEnhanceYourUNIX/LinuxLifewithSedandAwkVim101HackseBookPracticalExamplesforBecomingFastandProductiveinVimEditorNagiosCore3eBookMonitorEverything,BeProactive,andSleepWell

  • POPULARPOSTS

    12AmazingandEssentialLinuxBooksToEnrichYourBrainandLibrary50UNIX/LinuxSysadminTutorials50MostFrequentlyUsedUNIX/LinuxCommands(WithExamples)HowToBeProductiveandGetThingsDoneUsingGTD30ThingsToDoWhenyouareBoredandhaveaComputerLinuxDirectoryStructure(FileSystemStructure)ExplainedwithExamplesLinuxCrontab:15AwesomeCronJobExamplesGetaGripontheGrep!15PracticalGrepCommandExamplesUnixLSCommand:15PracticalExamples15ExamplesToMasterLinuxCommandLineHistoryTop10OpenSourceBugTrackingSystemViandVimMacroTutorial:HowToRecordandPlayMommy,Ifoundit!15PracticalLinuxFindCommandExamples15AwesomeGmailTipsandTricks15AwesomeGoogleSearchTipsandTricksRAID0,RAID1,RAID5,RAID10ExplainedwithDiagramsCanYouTopThis?15PracticalLinuxTopCommandExamplesTop5BestSystemMonitoringToolsTop5BestLinuxOSDistributionsHowToMonitorRemoteLinuxHostusingNagios3.0AwkIntroductionTutorial7AwkPrintExamplesHowtoBackupLinux?15rsyncCommandExamplesTheUltimateWgetDownloadGuideWith15AwesomeExamplesTop5BestLinuxTextEditorsPacketAnalyzer:15TCPDUMPCommandExamplesTheUltimateBashArrayTutorialwith15Examples3StepstoPerformSSHLoginWithoutPasswordUsingsshkeygen&sshcopyidUnixSedTutorial:AdvancedSedSubstitutionExamplesUNIX/Linux:10NetstatCommandExamplesTheUltimateGuideforCreatingStrongPasswords6StepstoSecureYourHomeWirelessNetworkTurbochargePuTTYwith12PowerfulAddOns

    CATEGORIES

    LinuxTutorials

  • VimEditorSedScriptingAwkScriptingBashShellScriptingNagiosMonitoringOpenSSHIPTablesFirewallApacheWebServerMySQLDatabasePerlProgrammingGoogleTutorialsUbuntuTutorialsPostgreSQLDBHelloWorldExamplesCProgrammingC++ProgrammingDELLServerTutorialsOracleDatabaseVMwareTutorials

    Ramesh Natarajan

    Follow

    AboutTheGeekStuff

    MynameisRameshNatarajan.Iwillbepostinginstructionguides,howto,troubleshootingtipsandtricksonLinux,database,hardware,securityandweb.Myfocusistowritearticlesthatwilleitherteachyouorhelpyouresolveaproblem.ReadmoreaboutRameshNatarajanandtheblog.

    ContactUs

    EmailMe:UsethisContactFormtogetintouchmewithyourcomments,questionsorsuggestionsaboutthissite.Youcanalsosimplydropmealinetosayhello!.

    FollowusonGoogle+

    FollowusonTwitter

    BecomeafanonFacebook

    SupportUs

  • Supportthisblogbypurchasingoneofmyebooks.

    Bash101HackseBook

    SedandAwk101HackseBook

    Vim101HackseBook

    NagiosCore3eBook

    Copyright20082015RameshNatarajan.Allrightsreserved|TermsofService