首页 > 代码库 > Linux_安装软件包

Linux_安装软件包

一、软件包:

  1. 源码包
  2. 二进制包(rpm包,编译完成)
  3. 依赖性 包A-->包B-->包C

一、rpm

  1. 挂载镜像,从镜像文件中找到要安装的rpm包

    [root@hadoop09-linux ~]# mount /dev/cdrom1 /media/
    mount: block device /dev/sr0 is write-protected, mounting read-only

  2. 查询已安装的好的包

    [root@hadoop09-linux ~]# rpm -qa  # -a all -q query
    openssh-server-5.3p1-84.1.el6.x86_64
    poppler-0.12.4-3.el6_0.1.x86_64
    festvox-slt-arctic-hts-0.20061229-18.el6.noarch
    dejavu-fonts-common-2.30-2.el6.noarch

  3. 来安装一个,看看bind包是否被安装

    [root@hadoop09-linux Packages]# rpm -qa | grep "^bind$"

    [root@hadoop09-linux Packages]#                                        # 没有被安装

  4. 那么在/media/Package目录下查找到bind包,进行安装

    [root@hadoop09-linux Packages]# ll | grep "bind"
    -r--r--r--. 2 root root 4157992 Feb 23 2013 bind-9.8.2-0.17.rc1.el6.x86_64.rpm

  5. 使用rpm安装bind
    • [root@hadoop09-linux Packages]# rpm -ivh bind-9.8.2-0.30.rc1.el6.x86_64.rpm
    • Preparing... ########################################### [100%]
    •    1:bind ########################################### [100%]
  6. 查看安装的bind包会有那些文件(包括配置文件的目录位置)
    • [root@hadoop09-linux shell]# rpm -ql `rpm -qa | grep "bind-9.8.2-0.30.rc1.el6.x86_64"`
    • /etc/NetworkManager/dispatcher.d/13-named
    • /etc/logrotate.d/named
    • /etc/named
    • /etc/named.conf
    • /etc/named.iscdlv.key
    • /etc/named.rfc1912.zones
    • ...
  7. 查看某个文件来自于那个包

    [root@hadoop09-linux Packages]# rpm -qf /etc/ntp.conf
    ntp-4.2.6p5-10.el6.centos.1.x86_64

  8.  卸载

      [root@hadoop09-linux Packages]# rpm -e  文件名    # 不用带后缀

二、yum

  1. 优点:方便,快捷,自动找到并安装依赖的包
  2. 缺点:必须联网安装,yum源一定要正确
  3. 查看系统安装了哪些包

    [root@hadoop09-linux Packages]# yum list | grep "@"  #得到结果中base为仓库名,@代表已安装

  4. 使用yum安装httpd-devel
    • [root@hadoop09-linux Packages]# yum -y install httpd-devel
    • Loaded plugins: fastestmirror, refresh-packagekit, security
    • Loading mirror speeds from cached hostfile
    • * base: mirrors.btte.net
    • ...
  5. 查看httpd-devel是否已经安装好了
    • [root@hadoop09-linux Packages]# yum list | grep "httpd-devel" | grep "@"
    • httpd-devel.x86_64 2.2.15-54.el6.centos @updates
  6. 卸载安装过的rpm包

    [root@hadoop09-linux Packages]# yum -y remove httpd-devel

  7. yum仓库(源) :mirrors.163.com/mirrors.sohu.com
  8. yum仓库位置:/etc/yum.repos.d/

Linux_安装软件包