以vsftpd为例,讨论linux下面如何管理软件包。

[html]  view plain  copy
 print ?
  1. 以vsftpd为例,讨论linux下面如何管理软件包,原文地址 http://my.chinaunix.net/space.php?uid=14762370&do=blog&id=100681  
  2.   
  3.    
  4.   
  5. Linux下面安装软件包的介绍  
  6.   
  7. 在linux系统中管理软件包有两种方法,第一种就是利用yum的方式来管理软件包。第二种就是利用rpm的方法来管理软件包。Yum与rpm的区别在于rpm在安装软件包的时候解决不了软件包依赖性关系,而yum在安装软件包的时候很好的解决了软件包的依赖性关系,很强大。  
  8.   
  9.    
  10.   
  11. 下面首先来讲解利用yum来管理软件包。  
  12.   
  13. Yum介绍  
  14.   
  15. Yum全称为 Yellow dog Updater, Modified(软件包管理器)  
  16.   
  17. 主要功能是更方便的添加/删除/更新RPM包, yum很好的解决了linux下面安装软件包的依赖性关系。很强大哦! 他能便于管理大量系统的更新问题  ,能同时设置多个资源库(Repository),而且使用起来十分的方便。  
  18.   
  19.    
  20.   
  21. 如果想使用yum的方式来安装软件包,那么必须配置yum仓库。  
  22.   
  23. 关于yum仓库的配置方法可以参考:  
  24.   
  25. http://blog.chinaunix.net/u3/111899/showart_2197778.html  
  26.   
  27.    
  28.   
  29. 1.      利用yum的方式来安装软件包  
  30.   
  31. #yum  -y  install   vsftpd  
  32.   
  33. -y            不用交互式  
  34.   
  35. Install       安装  
  36.   
  37. Vsftpd     需要安装软件包(这个是软件包,而不是软件包的rpm文件名)  
  38.   
  39. [root@localhost ~]#   
  40.   
  41. [root@localhost ~]# yum -y install vsftpd  
  42.   
  43. Loaded plugins: rhnplugin, security  
  44.   
  45. This system is not registered with RHN.  
  46.   
  47. RHN support will be disabled.  
  48.   
  49. Cluster                                                       | 1.3 kB     00:00       
  50.   
  51. Cluster/primary                                          | 6.5 kB     00:00       
  52.   
  53. Cluster                                                                   32/32  
  54.   
  55. ClusterStorage                                           | 1.3 kB     00:00       
  56.   
  57. ClusterStorage/primary                              | 8.8 kB     00:00       
  58.   
  59. ClusterStorage                                                            39/39  
  60.   
  61. Server                                                       | 1.3 kB     00:00       
  62.   
  63. Server/primary                                          | 732 kB     00:00       
  64.   
  65. Server                                                                2292/2292  
  66.   
  67. VT                                                           | 1.3 kB     00:00       
  68.   
  69. VT/primary                                               | 9.0 kB     00:00       
  70.   
  71. VT                                                                        36/36  
  72.   
  73. Setting up Install Process  
  74.   
  75. Resolving Dependencies  
  76.   
  77. --> Running transaction check  
  78.   
  79. ---> Package vsftpd.i386 0:2.0.5-16.el5 set to be updated  
  80.   
  81. Cluster/filelists                                          | 110 kB     00:00       
  82.   
  83. ClusterStorage/filelists                              |  11 kB     00:00       
  84.   
  85. Server/filelists                                          | 2.3 MB     00:00       
  86.   
  87. VT/filelists                                               |  26 kB     00:00       
  88.   
  89. --> Finished Dependency Resolution  
  90.   
  91.    
  92.   
  93. Dependencies Resolved  
  94.   
  95.    
  96.   
  97. ================================================================================  
  98.   
  99.  Package          Arch           Version                 Repository        Size  
  100.   
  101. ================================================================================  
  102.   
  103. Installing:  
  104.   
  105.  vsftpd           i386           2.0.5-16.el5            Server           140 k  
  106.   
  107.    
  108.   
  109. Transaction Summary  
  110.   
  111. ================================================================================  
  112.   
  113. Install           1 Package(s)           
  114.   
  115. Update        0 Package(s)           
  116.   
  117. Remove       0 Package(s)           
  118.   
  119.    
  120.   
  121. Total download size: 140 k  
  122.   
  123. Downloading Packages:  
  124.   
  125. vsftpd-2.0.5-16.el5.i386.rpm                             | 140 kB     00:00       
  126.   
  127. Running rpm_check_debug  
  128.   
  129. Running Transaction Test  
  130.   
  131. Finished Transaction Test  
  132.   
  133. Transaction Test Succeeded  
  134.   
  135. Running Transaction  
  136.   
  137.   Installing     : vsftpd                                                   1/1   
  138.   
  139.    
  140.   
  141. Installed:  
  142.   
  143.   vsftpd.i386 0:2.0.5-16.el5                                                      
  144.   
  145.    
  146.   
  147. Complete!  
  148.   
  149. [root@localhost ~]#  
  150.   
  151. 这样我们就利用yum的方式安装成功了ftp服务。  
  152.   
  153.    
  154.   
  155. 2.      利用yum的方式来安装本地软件包  
  156.   
  157. #yum -y install dovecot-1.0.7-7.el5.i386.rpm  
  158.   
  159. [root@localhost ~]#   
  160.   
  161. [root@localhost ~]# ls  
  162.   
  163. anaconda-ks.cfg  dovecot-1.0.7-7.el5.i386.rpm  install.log         server.repo  
  164.   
  165. Desktop          grub.conf                     install.log.syslog  
  166.   
  167. [root@localhost ~]# yum -y install dovecot-1.0.7-7.el5.i386.rpm   
  168.   
  169. Loaded plugins: rhnplugin, security  
  170.   
  171. This system is not registered with RHN.  
  172.   
  173. RHN support will be disabled.  
  174.   
  175. Setting up Install Process  
  176.   
  177. Examining dovecot-1.0.7-7.el5.i386.rpm: dovecot-1.0.7-7.el5.i386  
  178.   
  179. Marking dovecot-1.0.7-7.el5.i386.rpm to be installed  
  180.   
  181. Resolving Dependencies  
  182.   
  183. --> Running transaction check  
  184.   
  185. ---> Package dovecot.i386 0:1.0.7-7.el5 set to be updated  
  186.   
  187. --> Processing Dependency: libmysqlclient.so.15 for package: dovecot  
  188.   
  189. --> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: dovecot  
  190.   
  191. --> Processing Dependency: libpq.so.4 for package: dovecot  
  192.   
  193. --> Running transaction check  
  194.   
  195. ---> Package mysql.i386 0:5.0.77-3.el5 set to be updated  
  196.   
  197. --> Processing Dependency: perl(DBI) for package: mysql  
  198.   
  199. ---> Package postgresql-libs.i386 0:8.1.11-1.el5_1.1 set to be updated  
  200.   
  201. --> Running transaction check  
  202.   
  203. ---> Package perl-DBI.i386 0:1.52-2.el5 set to be updated  
  204.   
  205. --> Finished Dependency Resolution  
  206.   
  207.    
  208.   
  209. Dependencies Resolved  
  210.   
  211.    
  212.   
  213. ================================================================================  
  214.   
  215.  Package           Arch   Version             Repository                   Size  
  216.   
  217. ================================================================================  
  218.   
  219. Installing:    
  220.   
  221.  dovecot                i386   1.0.7-7.el5         /dovecot-1.0.7-7.el5.i386   3.6 M  
  222.   
  223. Installing for dependencies:  
  224.   
  225.  mysql                    i386    5.0.77-3.el5         Server                             4.8 M  
  226.   
  227.  perl-DBI               i386    1.52-2.el5            Server                             605 k  
  228.   
  229.  postgresql-libs       i386   8.1.11-1.el5_1.1   Server                             196 k  
  230.   
  231.    
  232.   
  233. Transaction Summary  
  234.   
  235. ================================================================================  
  236.   
  237. Install            4 Package(s)           
  238.   
  239. Update         0 Package(s)           
  240.   
  241. Remove        0 Package(s)           
  242.   
  243.    
  244.   
  245. Total size: 9.1 M  
  246.   
  247. Total download size: 5.5 M  
  248.   
  249. Downloading Packages:  
  250.   
  251. (1/3): mysql-5.0.77-3.el5.i386.rpm                                 | 4.8 MB     00:00       
  252.   
  253. (2/3): postgresql-libs-8.1.11-1.el5_1.1.i386.rpm             | 196 kB     00:00       
  254.   
  255. (3/3): perl-DBI-1.52-2.el5.i386.rpm                               | 605 kB     00:00       
  256.   
  257. --------------------------------------------------------------------------------  
  258.   
  259. Total                                                               7.3 MB/s | 5.5 MB     00:00       
  260.   
  261. Running rpm_check_debug  
  262.   
  263. Running Transaction Test  
  264.   
  265. Finished Transaction Test  
  266.   
  267. Transaction Test Succeeded  
  268.   
  269. Running Transaction  
  270.   
  271.   Installing     : perl-DBI                                                  1/4   
  272.   
  273.   Installing     : mysql                                                       2/4   
  274.   
  275.   Installing     : postgresql-libs                                          3/4   
  276.   
  277.   Installing     : dovecot                                                    4/4   
  278.   
  279.    
  280.   
  281. Installed:  
  282.   
  283.   dovecot.i386 0:1.0.7-7.el5                                                      
  284.   
  285.    
  286.   
  287. Dependency Installed:  
  288.   
  289.   mysql.i386 0:5.0.77-3.el5                perl-DBI.i386 0:1.52-2.el5        
  290.   
  291.   postgresql-libs.i386 0:8.1.11-1.el5_1.1        
  292.   
  293.    
  294.   
  295. Complete!  
  296.   
  297. [root@localhost ~]#  
  298.   
  299. 安装本地软件包的意义在于如果我们从互联网上面下载了一个rpm软件包,这个软件包用rpm方式安装可能会提示有依赖性关系,这个时候可以使用本地安装的方式来安装,因为我们的yum仓库有可能会解决这个包的依赖性关系。  
  300.   
  301. 但是这个后面接的是一个软件包rpm文件名,而不是软件包。  
  302.   
  303.    
  304.   
  305. 3.      利用yum使用组的方式来安装软件包  
  306.   
  307. 我们如何去查询那些组是可以安装的呢,  
  308.   
  309. 使用下面这条命令  
  310.   
  311. #yum  grouplist  
  312.   
  313. [root@localhost ~]#   
  314.   
  315. [root@localhost ~]# yum grouplist  
  316.   
  317. Loaded plugins: rhnplugin, security  
  318.   
  319. This system is not registered with RHN.  
  320.   
  321. RHN support will be disabled.  
  322.   
  323. Setting up Group Process  
  324.   
  325. Cluster/group                                                 | 101 kB     00:00       
  326.   
  327. ClusterStorage/group                                     | 105 kB     00:00       
  328.   
  329. Server/group                                                 | 1.0 MB     00:00       
  330.   
  331. VT/group                                                      | 103 kB     00:00       
  332.   
  333. Installed Groups:  
  334.   
  335.    Administration Tools  
  336.   
  337.    Editors  
  338.   
  339.    FTP Server  
  340.   
  341.    GNOME Desktop Environment  
  342.   
  343.    Graphical Internet  
  344.   
  345.    Graphics  
  346.   
  347.    Legacy Network Server  
  348.   
  349.    Mail Server  
  350.   
  351.    MySQL Database  
  352.   
  353.    Network Servers  
  354.   
  355.    Office/Productivity  
  356.   
  357.    Printing Support  
  358.   
  359.    Server Configuration Tools  
  360.   
  361.    Sound and Video  
  362.   
  363.    System Tools  
  364.   
  365.    Text-based Internet  
  366.   
  367.    X Window System  
  368.   
  369. Available Groups:  
  370.   
  371.    Authoring and Publishing  
  372.   
  373.    Cluster Storage  
  374.   
  375.    Clustering  
  376.   
  377.    DNS Name Server  
  378.   
  379.    Development Libraries  
  380.   
  381.    Development Tools  
  382.   
  383.    Engineering and Scientific  
  384.   
  385.    GNOME Software Development  
  386.   
  387.    Games and Entertainment  
  388.   
  389.    Java Development  
  390.   
  391.    KDE (K Desktop Environment)  
  392.   
  393.    KDE Software Development  
  394.   
  395.    Legacy Software Development  
  396.   
  397.    Legacy Software Support  
  398.   
  399.    News Server  
  400.   
  401.    OpenFabrics Enterprise Distribution  
  402.   
  403.    PostgreSQL Database  
  404.   
  405.    Virtualization  
  406.   
  407.    Web Server  
  408.   
  409.    Windows File Server  
  410.   
  411.    X Software Development  
  412.   
  413. Done  
  414.   
  415. [root@localhost ~]#  
  416.   
  417. 在这个命令里面显示的软件包都是可以使用组的方式来安装的。  
  418.   
  419. 下面我们利用组的方式来安装。  
  420.   
  421. # yum -y groupinstall "DNS Name Server"  
  422.   
  423. [root@localhost ~]#   
  424.   
  425. [root@localhost ~]# yum -y groupinstall "DNS Name Server"  
  426.   
  427. Loaded plugins: rhnplugin, security  
  428.   
  429. This system is not registered with RHN.  
  430.   
  431. RHN support will be disabled.  
  432.   
  433. Setting up Group Process  
  434.   
  435. Resolving Dependencies  
  436.   
  437. --> Running transaction check  
  438.   
  439. ---> Package bind.i386 30:9.3.6-4.P1.el5 set to be updated  
  440.   
  441. ---> Package bind-chroot.i386 30:9.3.6-4.P1.el5 set to be updated  
  442.   
  443. --> Finished Dependency Resolution  
  444.   
  445.    
  446.   
  447. Dependencies Resolved  
  448.   
  449.    
  450.   
  451. ================================================================================  
  452.   
  453.  Package            Arch        Version                     Repository     Size  
  454.   
  455. ================================================================================  
  456.   
  457. Installing:  
  458.   
  459.  bind                   i386        30:9.3.6-4.P1.el5           Server        978 k  
  460.   
  461.  bind-chroot        i386        30:9.3.6-4.P1.el5           Server         44 k  
  462.   
  463.    
  464.   
  465. Transaction Summary  
  466.   
  467. ================================================================================  
  468.   
  469. Install           2 Package(s)           
  470.   
  471. Update        0 Package(s)           
  472.   
  473. Remove       0 Package(s)           
  474.   
  475.    
  476.   
  477. Total download size: 1.0 M  
  478.   
  479. Downloading Packages:  
  480.   
  481. (1/2): bind-9.3.6-4.P1.el5.i386.rpm                          | 978 kB     00:00       
  482.   
  483. (2/2): bind-chroot-9.3.6-4.P1.el5.i386.rpm               |  44 kB      00:00       
  484.   
  485. --------------------------------------------------------------------------------  
  486.   
  487. Total                                                         2.9 MB/s | 1.0 MB     00:00       
  488.   
  489. Running rpm_check_debug  
  490.   
  491. Running Transaction Test  
  492.   
  493. Finished Transaction Test  
  494.   
  495. Transaction Test Succeeded  
  496.   
  497. Running Transaction  
  498.   
  499.   Installing     : bind                                                         1/2   
  500.   
  501.   Installing     : bind-chroot                                              2/2   
  502.   
  503.    
  504.   
  505. Installed:  
  506.   
  507.   bind.i386 30:9.3.6-4.P1.el5         bind-chroot.i386 30:9.3.6-4.P1.el5          
  508.   
  509.    
  510.   
  511. Complete!  
  512.   
  513. [root@localhost ~]#  
  514.   
  515. 我们知道安装DNS服务需要安装三个包,而我们利用组的方式来安装软件包,系统会自动的安装所有DNS服务需要的软件包,很方便。  
  516.   
  517.    
  518.   
  519. 4.      利用yum的方式来卸载软件包  
  520.   
  521. #yum  -y  remove  vsftpd  
  522.   
  523. [root@localhost ~]#   
  524.   
  525. [root@localhost ~]# yum -y remove vsftpd  
  526.   
  527. Loaded plugins: rhnplugin, security  
  528.   
  529. This system is not registered with RHN.  
  530.   
  531. RHN support will be disabled.  
  532.   
  533. Setting up Remove Process  
  534.   
  535. Resolving Dependencies  
  536.   
  537. --> Running transaction check  
  538.   
  539. ---> Package vsftpd.i386 0:2.0.5-16.el5 set to be erased  
  540.   
  541. --> Finished Dependency Resolution  
  542.   
  543.    
  544.   
  545. Dependencies Resolved  
  546.   
  547.    
  548.   
  549. ================================================================================  
  550.   
  551.  Package         Arch          Version                 Repository          Size  
  552.   
  553. ================================================================================  
  554.   
  555. Removing:  
  556.   
  557.  vsftpd            i386          2.0.5-16.el5            installed          285 k  
  558.   
  559.    
  560.   
  561. Transaction Summary  
  562.   
  563. ================================================================================  
  564.   
  565. Install           0 Package(s)           
  566.   
  567. Update        0 Package(s)           
  568.   
  569. Remove       1 Package(s)           
  570.   
  571.    
  572.   
  573. Downloading Packages:  
  574.   
  575. Running rpm_check_debug  
  576.   
  577. Running Transaction Test  
  578.   
  579. Finished Transaction Test  
  580.   
  581. Transaction Test Succeeded  
  582.   
  583. Running Transaction  
  584.   
  585.   Erasing        : vsftpd                                                   1/1   
  586.   
  587.    
  588.   
  589. Removed:  
  590.   
  591.   vsftpd.i386 0:2.0.5-16.el5                                                      
  592.   
  593.    
  594.   
  595. Complete!  
  596.   
  597. [root@localhost ~]#  
  598.   
  599. 卸载的时候也是接软件包,而不是软件包的rpm文件名。  
  600.   
  601.    
  602.   
  603. 5.      利用yum的方式来更新软件包  
  604.   
  605. #yum  update  
  606.   
  607. [root@localhost ~]#   
  608.   
  609. [root@localhost ~]# yum update  
  610.   
  611. Loaded plugins: rhnplugin, security  
  612.   
  613. This system is not registered with RHN.  
  614.   
  615. RHN support will be disabled.  
  616.   
  617. Skipping security plugin, no data  
  618.   
  619. Setting up Update Process  
  620.   
  621. No Packages marked for Update  
  622.   
  623. [root@localhost ~]#  
  624.   
  625. 这个是更新全部的软件包  
  626.   
  627. #yum  update  vsftpd  
  628.   
  629. [root@localhost ~]#   
  630.   
  631. [root@localhost ~]# yum update vsftpd  
  632.   
  633. Loaded plugins: rhnplugin, security  
  634.   
  635. This system is not registered with RHN.  
  636.   
  637. RHN support will be disabled.  
  638.   
  639. Skipping security plugin, no data  
  640.   
  641. Setting up Update Process  
  642.   
  643. No Packages marked for Update  
  644.   
  645. [root@localhost ~]#  
  646.   
  647. 这个更新指定的软件包(也是接软件包)  
  648.   
  649. #yum  check-update  
  650.   
  651. [root@localhost ~]#   
  652.   
  653. [root@localhost ~]# yum check-update  
  654.   
  655. Loaded plugins: rhnplugin, security  
  656.   
  657. This system is not registered with RHN.  
  658.   
  659. RHN support will be disabled.  
  660.   
  661. Skipping security plugin, no data  
  662.   
  663. [root@localhost ~]#  
  664.   
  665. 这个检查可更新的软件包。  
  666.   
  667.    
  668.   
  669. 6.      利用yum来查询软件包  
  670.   
  671. #yum  search  vsftpd  
  672.   
  673. [root@localhost ~]#   
  674.   
  675. [root@localhost ~]# yum search vsftpd  
  676.   
  677. Loaded plugins: rhnplugin, security  
  678.   
  679. This system is not registered with RHN.  
  680.   
  681. RHN support will be disabled.  
  682.   
  683. =============================== Matched: vsftpd ================================  
  684.   
  685. vsftpd.i386 : vsftpd - Very Secure Ftp Daemon  
  686.   
  687. [root@localhost ~]#  
  688.   
  689. 这个是查询指定的软件包  
  690.   
  691. #yum  list  all  
  692.   
  693. 列出系统中所有的软件,包括安装的和未安装的。  
  694.   
  695. #yum  list  all  | grep vsftpd  
  696.   
  697. [root@localhost ~]#   
  698.   
  699. [root@localhost ~]# yum list all |grep vsftpd  
  700.   
  701. This system is not registered with RHN.  
  702.   
  703. RHN support will be disabled.  
  704.   
  705. vsftpd.i386                             2.0.5-16.el5              installed       
  706.   
  707. [root@localhost ~]#  
  708.   
  709. 通过查询,可以看到,vsftpd已经安装了。这个命令也很好用。  
  710.   
  711. #yum list available   
  712.   
  713. 查询系统中没有安装的软件包  
  714.   
  715. #yum list installed  
  716.   
  717. 查询系统中安装的软件包  
  718.   
  719. #yum info vsftpd  
  720.   
  721. [root@localhost ~]#   
  722.   
  723. [root@localhost ~]# yum info vsftpd  
  724.   
  725. Loaded plugins: rhnplugin, security  
  726.   
  727. This system is not registered with RHN.  
  728.   
  729. RHN support will be disabled.  
  730.   
  731. Installed Packages  
  732.   
  733. Name          : vsftpd  
  734.   
  735. Arch            : i386  
  736.   
  737. Version        : 2.0.5  
  738.   
  739. Release       : 16.el5  
  740.   
  741. Size             : 285 k  
  742.   
  743. Repo          : installed  
  744.   
  745. Summary    : vsftpd - Very Secure Ftp Daemon  
  746.   
  747. URL           : http://vsftpd.beasts.org/  
  748.   
  749. License       : GPL  
  750.   
  751. Description: vsftpd is a Very Secure FTP daemon. It was written completely from  
  752.   
  753.                   : scratch.  
  754.   
  755.    
  756.   
  757. [root@localhost ~]#  
  758.   
  759. 查询软件包的详细信息。  
  760.   
  761. #yum whatprovides /etc/inittab  
  762.   
  763. [root@localhost ~]#   
  764.   
  765. [root@localhost ~]# yum whatprovides /etc/inittab   
  766.   
  767. Loaded plugins: rhnplugin, security  
  768.   
  769. This system is not registered with RHN.  
  770.   
  771. RHN support will be disabled.  
  772.   
  773. initscripts-8.45.30-2.el5.i386 : The inittab file and the /etc/init.d scripts.  
  774.   
  775. Repo        : Server  
  776.   
  777. Matched from:  
  778.   
  779. Filename    : /etc/inittab  
  780.   
  781.    
  782.   
  783.    
  784.   
  785.    
  786.   
  787. initscripts-8.45.30-2.el5.i386 : The inittab file and the /etc/init.d scripts.  
  788.   
  789. Repo        : installed  
  790.   
  791. Matched from:  
  792.   
  793. Other       : Provides-match: /etc/inittab  
  794.   
  795.    
  796.   
  797.    
  798.   
  799.    
  800.   
  801. [root@localhost ~]#  
  802.   
  803. 这个是查询某个文件是属于那个包的。  
  804.   
  805. #yum clean all   
  806.   
  807. 清除缓存信息  
  808.   
  809. Yum的使用方法到这里就基本完成了。  
  810.   
  811.    
  812.   
  813. 下面首先讲解利用rpm来管理软件包。  
  814.   
  815. Rpm介绍  
  816.   
  817. Rpm的全称为RedHat package manager(红帽软件包管理器),虽然rpm的方式并不可以解决软件包的依赖性关系,但是rpm的查询方式也是非常的强大的。  
  818.   
  819.    
  820.   
  821. 1.      利用rpm的方式来安装软件包  
  822.   
  823. #rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm  
  824.   
  825. [root@localhost ~]#   
  826.   
  827. [root@localhost ~]# ls | grep vsftpd-2.0.5-16.el5.i386.rpm   
  828.   
  829. vsftpd-2.0.5-16.el5.i386.rpm  
  830.   
  831. [root@localhost ~]# rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm   
  832.   
  833. Preparing...  ########################################### [100%]  
  834.   
  835. 1:vsftpd       ########################################### [100%]  
  836.   
  837. [root@localhost ~]#  
  838.   
  839. -v  h    输出选项  
  840.   
  841. 利用rpm安装软件包一定是接软件包的rpm文件名。  
  842.   
  843. #rpm -Fvh vsftpd-2.0.5-16.el5.i386.rpm  
  844.   
  845. #rpm -Uvh vsftpd-2.0.5-16.el5.i386.rpm  
  846.   
  847. 这两条命令的区别在于  
  848.   
  849. -Fvh    原来安装了软件包就更新,没有安装就不管。只更新。  
  850.   
  851. -Uvh   原来安装了软件包就更新,没有安装就自动安装。  
  852.   
  853.    
  854.   
  855. 2.      利用rpm的方法来卸载软件包  
  856.   
  857. #rpm  -evh  vsftpd  
  858.   
  859. [root@localhost ~]#   
  860.   
  861. [root@localhost ~]# rpm -e vsftpd  
  862.   
  863. [root@localhost ~]#  
  864.   
  865. 用rpm卸载软件包的时候要注意后面只可以接软件包。  
  866.   
  867.    
  868.   
  869. 3.      利用rpm重新安装软件包  
  870.   
  871. # rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm -- replacepkgs  
  872.   
  873. [root@localhost ~]#   
  874.   
  875. [root@localhost ~]# rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm --replacepkgs   
  876.   
  877. Preparing...  ########################################### [100%]  
  878.   
  879. 1:vsftpd       ########################################### [100%]  
  880.   
  881. [root@localhost ~]#  
  882.   
  883. # rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm -- force  
  884.   
  885. 这两条命令的作用都是一样的,都是重新安装软件包,它们的区别在于—replacepkgs在系统正常运行的时候可以使用这个,但是在修复模式下面只可以使用—force。  
  886.   
  887.    
  888.   
  889. 在利用rpm安装软件包的时候,可以使用url的方式来安装软件包。  
  890.   
  891. #rpm –ivh ftp://192.168.0.254/pub/Server/vsftpd-2.0.5-16.el5.i386.rpm  
  892.   
  893.    
  894.   
  895. 4.      利用rpm来查询软件包  
  896.   
  897. #rpm  -qa   
  898.   
  899. 查询系统中所有已经安装的软件包  
  900.   
  901. #rpm  -qa  | grep  vsftpd  
  902.   
  903. [root@localhost ~]#   
  904.   
  905. [root@localhost ~]# rpm -qa | grep vsftpd  
  906.   
  907. vsftpd-2.0.5-16.el5  
  908.   
  909. [root@localhost ~]#  
  910.   
  911. 查询vsftpd这个软件包有没有安装  
  912.   
  913. #rpm  -q  vsftpd  
  914.   
  915. 查询vsftpd这个软件包有没有安装,和上面一样。  
  916.   
  917. #rpm  -qf  /etc/inittab  
  918.   
  919. [root@localhost ~]#   
  920.   
  921. [root@localhost ~]# rpm -qf /etc/inittab   
  922.   
  923. initscripts-8.45.30-2.el5  
  924.   
  925. [root@localhost ~]#  
  926.   
  927. 查询文件是属于那个软件包的。  
  928.   
  929. # rpm –qpi  dovecot-1.0.7-7.el5.i386.rpm  
  930.   
  931. [root@localhost ~]#   
  932.   
  933. [root@localhost ~]# rpm -qpi dovecot-1.0.7-7.el5.i386.rpm   
  934.   
  935. Name        : dovecot                       Relocations: (not relocatable)  
  936.   
  937. Version     : 1.0.7                            Vendor: Red Hat, Inc.  
  938.   
  939. Release     : 7.el5                            Build Date: Tue 25 Nov 2008 12:47:16 AM CST  
  940.   
  941. Install Date: (not installed)               Build Host: hs20-bc1-2.build.redhat.com  
  942.   
  943. Group       : System Environment/Daemons    Source RPM: dovecot-1.0.7-7.el5.src.rpm  
  944.   
  945. Size           : 3730313                     License: LGPL  
  946.   
  947. Signature   : DSA/SHA1, Wed 10 Dec 2008 08:42:34 PM CST, Key ID 5326810137017186  
  948.   
  949. Packager   : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>  
  950.   
  951. URL         : http://www.dovecot.org/  
  952.   
  953. Summary  : Dovecot Secure imap server  
  954.   
  955. Description :  
  956.   
  957. Dovecot is an IMAP server for Linux/UNIX-like systems, written with security  
  958.   
  959. primarily in mind.  It also contains a small POP3 server.  It supports mail  
  960.   
  961. in either of maildir or mbox formats.  
  962.   
  963. [root@localhost ~]#  
  964.   
  965. 查询一个没有安装软件包的信息。  
  966.   
  967. #rpm  -ql  vsftpd  
  968.   
  969. 查询vsftpd这个服务产生了那些文件。  
  970.   
  971. #rpm -ivh --nodeps dovecot-1.0.7-7.el5.i386.rpm  
  972.   
  973. 去掉软件包的依赖性关系,但是前提是你已经知道了去掉依赖性关系后的软件包,你的服务也没有问题。  
  974.   
  975.    
  976.   
  977. 5.      rpm的校验  
  978.   
  979. #rpm  -V  vsftpd  
  980.   
  981. 校验rpm软件包是否有问题。  
  982.   
  983. #rpm  -Vp vsftpd-2.0.5-16.el5.i386.rpm  
  984.   
  985. 和上面一样,也是校验rpm软件包是否有问题。  
  986.   
  987. #rpm  -Va    
  988.   
  989. 校验所有的rpm软件包。  
  990.   
  991. # rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release  
  992.   
  993. 利用rpm第一次安装软件包的时候必须导入这个gpg-key。  
  994.   
  995.    
  996.   
  997. 6.      利用rpm来升级内核  
  998.   
  999. #rpm -ivh kernel-PAE-2.6.18-164.el5.i686.rpm  
  1000.   
  1001. [root@localhost ~]#   
  1002.   
  1003. [root@localhost ~]# ls | grep kernel  
  1004.   
  1005. kernel-PAE-2.6.18-164.el5.i686.rpm  
  1006.   
  1007. [root@localhost ~]# rpm -ivh kernel-PAE-2.6.18-164.el5.i686.rpm   
  1008.   
  1009. Preparing...      ########################################## [100%]  
  1010.   
  1011. 1:kernel-PAE ########################################### [100%]  
  1012.   
  1013. [root@localhost ~]#   
  1014.   
  1015. 这样我们的内核就安装成功了。  
  1016.   
  1017. 安装成功内核以后,我们可以去/boot/grub/grub.conf文件中定义从新内核启动。  
  1018.   
  1019.    
  1020.   
  1021. 在linux下面软件包管理讨论就到这里了。  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值