以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下面软件包管理讨论就到这里了。  
vsftpd搭建步骤 1、首先安装vsftpd,并设置开机启动 yum -y install vsftpd chkconfig vsftpd on 2、基于虚拟用户配置,(所谓虚拟用户就是没有使用真实的帐户,只是通过映射到真实帐户和设置权限的目的。虚拟用户不能登录CentOS系统)  2.1 配置参数 [root@ftp vuser_conf]# sed -n '/^[^#]/P' /etc/vsftpd/vsftpd.conf anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_file=/var/log/xferlog xferlog_std_format=YES idle_session_timeout=600 data_connection_timeout=120 ascii_upload_enable=YES ascii_download_enable=YES chroot_list_enable=YES listen=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES guest_enable=YEs guest_username=ftp user_config_dir=/etc/vsftpd/vuser_conf pasv_enable=YES pasv_min_port=40000 pasv_max_port=40080 pasv_promiscuous=YES accept_timeout=60 connect_timeout=60  2.2 参数解释 [root@ftp /]# sed -n '/^[^#]/P' /etc/vsftpd/vsftpd.conf #设定不允许匿名访问 anonymous_enable=NO #设定本地用户可以访问。注:如使用虚拟宿主用户,在该项目设定为NO的情况下所有虚拟用户将无法访问 local_enable=YES #允许用户上传数据(包括文档与目录) write_enable=YES #建立新目录(775)与档案(644)的权限 local_umask=022 #若目录下有.message则显示该文档内容 dirmessage_enable=YES #启动登录文件记录,记录于 /var/log/xferlog xferlog_enable=YES #支持主动式联机功能 connect_from_port_20=YES #如果上一个xferlog_enable=YES的话,这里可以设定了!这个是登录档案的档名。 xferlog_file=/var/log/xferlog #是否设定为 wu ftp 相同的登录档格式?预设为 NO ,因为登录档会比较容易读! 不过,如果你有使用 wu ftp 登录文件的分析软件,这里才需要设定为 YES xferlog_std_format=YES #若匿名者发呆超过 10 分钟就断线 idle_session_timeout=600 #如果服务器与客户端的数据联机已经成功建立 (不论主动还是被动联机),但是可能由于线路问题导致 120 秒内还是无法顺利的完成数据的传送,那客户端的联机就会被我们的 vsftpd 强制剔除! data_connection_timeout=120 #如果设定为 YES ,那么 client 就优先 (预设) 使用 ASCII 格式上传文件。 ascii_upload_enable=YES #如果设定为 YES ,那么 client 就优先 (预设) 使用 ASCII 格式下载文件。 ascii_download_enable=YES #是否启用 chroot 写入列表的功能?与底下的 chroot_list_flie 有关!这个项目得要开启,否则底下的列表档案会无效。 chroot_list_enable=YES #若设定为 YES 表示 vsftpd 是以 standalone 的方式来启动的!预设是 NO !所以我们的 CentOS 将它改为 YES !这样才能使用 stand alone 的方式来唤醒。 listen=YES #这个是 pam 模块的名称,我们放置在 /etc/pam.d/vsftpd 即是这个。 pam_service_name=vsftpd #支持 /etc/vsftpd/user_list 档案内的账号登入管控! userlist_enable=YES #支持 TCP Wrappers 的防火墙机制 tcp_wrappers=YES #若这个值设定为 YES 时,那么任何实体账号,均会被假设成为 guest (所以预设是不开放的)! 至于访客在 vsftpd 当中,预设会取得 ftp 这个使用者的相关权限。但可以透过 guest_username 来修改。 guest_enable=YES #指定虚拟用户的宿主用户,CentOS中已经有内置的ftp用户了 guest_username=ftp # FTP服务文件(配置文件名=虚拟用户名) user_config_dir=/etc/vsftpd/vuser_conf #支持数据流的被动式联机模式(passive mode),一定要设定为 YES pasv_enable=YES #在防火墙配置内开启40000到40080端口(没有测试过) -A INPUT -m state --state NEW -m tcp -p -dport 40000:40080 -j ACCEPT pasv_min_port=40000 pasv_max_port=40080 #是否屏蔽对pasv进行安全检查,(当有安全隧道时可禁用) pasv_promiscuous=YES #当用户以被动式 PASV 来进行数据传输时,如果服务器启用 passive port 并等待 client 超过 60 秒而无回应, 那么就给他强制断线!这个设定值与 connect_timeout accept_timeout=60 #单位是秒,在数据连接的主动式联机模式下,我们发出的连接讯号在 60 秒内得不到客户端的响应,则不等待并强制断线 connect_timeout=60  2.3 FTP协议有两种工作方式:PORT方式和PASV方式,中文意思为主动式和被动式。 一、PORT(主动)方式的连接过程是:客户端向服务器的FTP端口(默认是21)发送连接请求,服务器接受连接,建立一条命令链路。 当需要传送数据时,客户端在命令链路上用 PORT命令告诉服务器:“我打开了****端口,你过来连接我”。于是服务器从20端口向客户端的****端口发送连接请求,建立一条数据链路来传送数据。 二、PASV(被动)方式的连接过程是:客户端向服务器的FTP端口(默认是21)发送连接请求,服务器接受连接,建立一条命令链路。 当需要传送数据时,服务器在命令链路上用 PASV命令告诉客户端:“我打开了****端口,你过来连接我”。于是客户端向服务器的****端口发送连接请求,建立一条数据链路来传送数据。 从上面可以看出,两种方式的命令链路连接方法是一样的,而数据链路的建立方法就完全不同。而FTP的复杂性就在于此。 3 进行认证  安装Berkeley DB工具,很多人找不到db_load的问题就是没有安装这个包 yum install db4 db4-utils  创建用户密码文本,注意奇行是用户名,偶行是密码 [root@ftp /]# cat /etc/vsftpd/vuser_passwd.txt lixiang 8qu.com.cn shuaicong 8qu.com.cn gaojingyuan 8qu.com.cn  生成虚拟用户认证的db文件 db_load -T -t hash -f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db 注:(每添加一用户和秘密就得生成一次)  编辑认证文件,全部注释掉原来语句,再增加以下两句 [root@ftp /]# cat /etc/pam.d/vsftpd #%PAM-1.0 #session optional pam_keyinit.so force revoke #auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed #auth required pam_shells.so #auth include password-auth #account include password-auth #session required pam_loginuid.so #session include password-auth auth required pam_userdb.so db=/etc/vsftpd/vuser_passwd account required pam_userdb.so db=/etc/vsftpd/vuser_passwd  创建虚拟用户配置文件 mkdir /etc/vsftpd/vuser_conf/ -p [root@ftp /]# cd /etc/vsftpd/vuser_conf/  文件名等于vuser_passwd.txt里面的账户名,否则下面设置无效 [root@ftp /]# cat /etc/vsftpd/vuser_passwd.txt lixiang 8qu.com.cn shuaicong 8qu.com.cn gaojingyuan 8qu.com.cn [root@ftp /]# cd /etc/vsftpd/vuser_conf/ [root@ftp vuser_conf]# ll total 12 -rw-r--r-- 1 root root 159 Apr 1 17:57 gaojingyuan -rw-r--r-- 1 root root 161 Apr 1 16:27 lixiang -rw-r--r-- 1 root root 161 Apr 1 17:00 shuaicong  虚拟用户根目录,根据实际情况修改 #指定虚拟用户的具体主路径。 local_root=/data/ftp #设定可以进行写操作 write_enable=YES # umask = 022 时,新建的目录 权限是755,文件的权限是 644 umask = 077 时,新建的目录 权限是700,文件的权限时 600。这里应该是anonymous用户创建的文件权限。 anon_umask=022 #仅允许 anonymous 具有下载可读档案的权限 anon_world_readable_only=NO #是否让 anonymous 具有上传数据的功能,默认是 NO,如果要设定为 YES ,则 anon_other_write_enable=YES 必须设定 anon_upload_enable=YES #是否让 anonymous 具有建立目录的权限?默认值是 NO!如果要设定为 YES, 那么 anony_other_write_enable 必须设定为 YES ! anon_mkdir_write_enable=YES #是否允许 anonymous 具有除了写入之外的权限?包括删除与改写服务器上的档案及档名等权限。预设当然是 NO!如果要设定为 YES, anon_other_write_enable=YES 4 设置FTP根目录权限  最新的vsftpd要求对主目录不能有写的权限所以ftp为755,主目录下面的子目录再设置777权限 mkdir /data/ftp chmod -R 755 /data chmod -R 777 /data/ftp [root@ftp data]# ls -ld /data/ drwxr-xr-x 3 root root 4096 Apr 1 16:25 /data/ [root@ftp data]# ll total 4 drwxrwxrwx 2 root root 4096 Apr 1 17:21 ftp  建立限制用户访问目录的空文件(不需要也得创建) touch /etc/vsftpd/chroot_list  如果启用vsftpd日志需手动建立日志文件 touch /var/log/xferlog touch /var/log/vsftpd.log  重启iptabls和vsftpd service iptables restart service vsftpd restart 5 Selinux和防火墙  该关闭的关闭,该放行的放行 1 2 3 4 5 #关闭selinux/iptables sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config setenforce 0 chkconfig iptables off service iptables stop 常见问题 如果登录时出现 500 OOPS: priv_sock_get_result. Connection closed by remote host. 这样的错误,需要升级pam yum update pam 6日志分析 vsftpd的两个日志文件分析如下: /var/log/xferlog 记录内容举例 /var/log/vsftpd.log Sat Apr 1 16:34:14 2017 1 10.13.98.101 55 /vsftpd(1).txt b _ i g lixiang ftp 0 * c /var/log/xferlog日志文件中数据的分析和参数说明 记录数据 参数名称 参数说明 Thu Sep 6 09:07:48 2007 当前时间 当前服务器本地时间,格式为: DDD MMM dd hh:mm:ss YYY 7 传输时间 传送文件所用时间,单位为秒 192.168.57.1 远程主机名称/IP 远程主机名称/IP 4323279 文件大小 传送文件的大小,单位为byte /home/student/phpMyadmin- 2.11.0-all-languages.tar.gz 文件名 传输文件名,包括路径 b 传输类型 传输方式的类型,包括两种: a以ASCII传输 b以二进制文件传输 – 特殊处理标志 特殊处理的标志位,可能的值包括: _ 不做任何特殊处理 C 文件是压缩格式 U 文件是非压缩格式 T 文件是tar格式 i 传输方向 文件传输方向,包括两种: o 从FTP服务器向客户端传输 i 从客户端向FTP服务器传输 r 访问模式 用户访问模式,包括: a 匿名用户 g 来宾用户 r 真实用户,即系统中的用户 student 用户名 用户名称 ftp 服务名 所使用的服务名称,一般为FTP 0 认证方式 认证方式,包括: 0 无 1 RFC931认证 * 认证用户id 认证用户的id,如果使用*,则表示无法获得该id c 完成状态 传输的状态: c 表示传输已完成 i 表示传输示完成
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值