Linux基础-软件管理

  • Linux软件管理

    RHEL/CentOS类型: windows *.exe

    rpm软件 *.rpm 源码软件 *.tar.gz, *.tar.bz2 灵活性强

      一、软件的类型 A. 源码包tarball    		    需要编译
    所有的包在初始的时候都是源码的,需先解压再编译,因此安装起来比较慢,但是灵活性高,可以自行配置,经过编译之后变成二进制包 B. 二进制包				   已编译
    
    • 可以直接拿过来就用的,适用于大批量的安装软件时,比如:qq.exe ========================================================== 小知识:常见的二进制包 系统平台 包类型 工具 在线安装(自动解决依赖关系)
      RedHat/Centos/Fedora/SUSE RPM rpm,rpmbuild yum
      Ubuntu/Debian DPKG dpkg apt 注意:
      不管是源码包,还是二进制包,安装时都可能会有依赖关系!

    • rpm包是一种已经编译好的二进制包,全名是redhat package standard,是红帽提出的包管理标准,在已编译好的包上面加了一层规则,规定了的指定文件的安装位置,且会将包的信息自动存放到本地的rpm数据库中,查询直接从数据库中查询,删除也是直接将数据库中文件删掉。实际上rpm已经成为了包管理的主流标准。

    ======================================================================================================

    二、RPM包管理 获得RPM包途径:

    1. RedHat光盘或官方网站提供最基础的包 ftp://ftp.redhat.com
    2. rpmfind.net寻找一些官方找不到的包
    3. 相应软件官方网站如www.mysql.org www.apache.org www.nginx.org
    4. 其他

    rpm软件安装包名称的组成

    zlib-1.2.7-15.el7.x86_64.rpm >>>软件安装包名称
    zlib:软件名称
    1.2.7:版本 el7.x86_64:软件的运行平台

      2) 互联网
    

    https://pkgs.org/ http://rpmfind.net/

    使用rpm命令管理rpm软件

    1) 安装rpm软件

    rpm -ivh <软件安装包名称>

    -i 安装
    -v 显示过程
    -h 显示#百分比 示例:安装dhcp软件

    [root@test01 ~]# rpm -ivh
    /mnt/Packages/dhcp-4.2.5-42.el7.centos.x86_64.rpm
    警告:/mnt/Packages/dhcp-4.2.5-42.el7.centos.x86_64.rpm: 头V3 RSA/SHA256
    Signature, 密钥 ID f4a80eb5: NOKEY 准备中…
    ################################# [100%] 正在升级/安装… 1:dhcp-12:4.2.5-42.el7.centos #################################
    [100%]

    示例:安装httpd软件

    [root@test01 ~]# rpm -ivh
    /mnt/Packages/httpd-2.4.6-40.el7.centos.x86_64.rpm
    警告:/mnt/Packages/httpd-2.4.6-40.el7.centos.x86_64.rpm: 头V3 RSA/SHA256
    Signature, 密钥 ID f4a80eb5: NOKEY 错误:依赖检测失败: /etc/mime.types 被
    httpd-2.4.6-40.el7.centos.x86_64 需要 httpd-tools =
    2.4.6-40.el7.centos 被 httpd-2.4.6-40.el7.centos.x86_64 需要 libapr-1.so.0()(64bit) 被 httpd-2.4.6-40.el7.centos.x86_64 需要
    libaprutil-1.so.0()(64bit) 被 httpd-2.4.6-40.el7.centos.x86_64 需要

    [root@test01 ~]# rpm -ivh --nodeps
    /mnt/Packages/httpd-2.4.6-40.el7.centos.x86_64.rpm
    警告:/mnt/Packages/httpd-2.4.6-40.el7.centos.x86_64.rpm: 头V3 RSA/SHA256
    Signature, 密钥 ID f4a80eb5: NOKEY 准备中…
    ################################# [100%] 正在升级/安装… 1:httpd-2.4.6-40.el7.centos #################################
    [100%]

     	选项: 			**--nodeps 	忽略依赖关系**
    
      示例:安装ntfs软件  
    

    [root@localhost ~]# rpm -ivh --force
    ntfs-3g-2013.1.13-5.el7.x86_64.rpm
    警告:ntfs-3g-2013.1.13-5.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥
    ID 352c64e5: NOKEY 准备中…
    ################################# [100%] 正在升级/安装… 1:ntfs-3g-2:2013.1.13-5.el7 #################################
    [100%]

       选项: 		**--force 	强制重新安装**  	
    

    [root@www /]# rpm -e ntfs-3g [root@www /]# [root@www /]# rpm -ivh
    ntfs-3g-2013.1.13-5.el7.x86_64.rpm
    警告:ntfs-3g-2013.1.13-5.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥
    ID 352c64e5: NOKEY 准备中…
    ################################# [100%] 正在升级/安装… 1:ntfs-3g-2:2013.1.13-5.el7 #################################
    [100%]

    (1) 查询httpd软件是否安装

    [root@test01 ~]# rpm -q httpd httpd-2.4.6-40.el7.centos.x86_64

    [root@test01 ~]# rpm -qa | grep vim vim-enhanced-7.4.160-1.el7.x86_64
    vim-minimal-7.4.160-1.el7.x86_64 vim-filesystem-7.4.160-1.el7.x86_64
    vim-common-7.4.160-1.el7.x86_64
    (2) 查询httpd软件生成的文件

    rpm -ql <软件名称>

    [root@test01 ~]# rpm -ql httpd | less
    (3) 查询某个文件由哪个软件生成
    [root@test01 ~]# which ifconfig /usr/sbin/ifconfig

    [root@test01 ~]# rpm -qf /usr/sbin/ifconfig
    net-tools-2.0-0.17.20131004git.el7.x86_64

    [root@www /]# which ls alias ls=‘ls --color=auto’ /usr/bin/ls
    [root@www /]# rpm -qf /usr/bin/ls coreutils-8.22-11.el7.x86_64
    [root@www /]# rpm -ql coreutils /etc/DIR_COLORS

    [root@www /]# which ip /usr/sbin/ip [root@www /]# rpm -qf
    /usr/sbin/ip iproute-3.10.0-13.el7.x86_64

     	 **(4) rpm -qc   查看软件包生成的配置文件**
    

    [root@localhost ~]# rpm -qc dhcp /etc/dhcp/dhcpd.conf
    /etc/dhcp/dhcpd6.conf /etc/openldap/schema/dhcp.schema
    /etc/sysconfig/dhcpd /var/lib/dhcpd/dhcpd.leases
    /var/lib/dhcpd/dhcpd6.leases

    3) 卸载软件

    rpm -e <软件名称>

    示例:卸载httpd软件

    [root@test01 ~]# rpm -e httpd 选项: --nodeps 忽略依赖关系

    4) 升级软件

    rpm -Uvh <软件包装包名称>

    U:update升级,更新 注意:同时卸载旧版本软件 [root@www /]# rpm -Uvh
    ntfs-3g-2013.1.13-5.el7.x86_64.rpm
    警告:ntfs-3g-2013.1.13-5.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥
    ID 352c64e5: NOKEY 准备中…
    ################################# [100%] 正在升级/安装… 1:ntfs-3g-2:2013.1.13-5.el7 #################################
    [ 50%] 正在清理/删除… 2:ntfs-3g-2:2010.5.22-1.el6
    ################################# [100%]

    使用yum的方式管理rpm软件

    优势:自动解决软件的依赖关系 前提:配置yum源仓库 yum源类型:

    本地源 baseurl=file:///software
    ftp源 baseurl=ftp://ftp服务器地址/centos7u2
    http源 baseurl=https://mirrors.aliyun.com/centos/7.3.1611/storage/x86_64/gluster-3.7/
    (联网的情况下)

    1) 备份自带的yum源配置文件

    • mkdir /etc/yum.repos.d/default # mv /etc/yum.repos.d/Cent* /etc/yum.repos.d/default

    2) 创建本地yum源配置文件

    [root@test01 ~]# cat /etc/yum.repos.d/local.repo [local]
    name=locaslrc baseurl=file:///mnt enabled=1 gpgcheck=0

    • mount /dev/cdrom /mnt

    3) 列出本机可用的yum源仓库

    [root@test01 ~]# yum repolist 已加载插件:fastestmirror, langpacks local
    | 3.6 kB 00:00:00 (1/2): local/group_gz
    | 155 kB 00:00:00 (2/2): local/primary_db
    | 2.8 MB 00:00:00 Loading mirror speeds from cached hostfile
    源标识 源名称
    状态 local
    locaslrc
    3,723 repolist: 3,723

    4) 生成yum缓存

    [root@test01 ~]# yum makecache 已加载插件:fastestmirror, langpacks local
    | 3.6 kB 00:00:00 (1/2): local/filelists_db
    | 2.9 MB 00:00:00 (2/2): local/other_db
    | 1.2 MB 00:00:00 Loading mirror speeds from cached hostfile
    元数据缓存已建立

    - 5) 使用yum安装httpd软件
    # yum install -y httpd
    常用的yum用法 :
    1) 安装软件
    # yum install -y <软件名称>
    2) 卸载软件
    # yum remove -y <软件名称>
    3) 升级软件
    # yum update -y <软件名称> (版本较高的文件)

       **4) 列出yum源仓库中所有软件** 
       # yum list all 	 	
       **5) 查询软件的信息** 
       [root@test01 ~]# yum info httpd
       已加载插件:fastestmirror, langpacks Loading mirror speeds from cached    hostfile 可安装的软件包 名称    :httpd 架构    :x86_64 版本    :2.4.6 发布
    

    :40.el7.centos 大小 :2.7 M 源 :local 简介 : Apache HTTP Server 网址
    :http://httpd.apache.org/ 协议 : ASL 2.0 描述 : The Apache HTTP
    Server is a powerful, efficient, and extensible
    : web server.

       **6) 查看某个文件由哪个软件生成**  
       [root@test01 ~]# yum provides "*/lftp" 已加载插件:fastestmirror, langpacks    Loading mirror speeds from cached hostfile
    

    lftp-4.4.8-7.el7.x86_64 : A sophisticated file transfer program 源
    :local 匹配来源: 文件名 :/usr/bin/lftp 文件名 :/usr/lib64/lftp

      	 使用yum管理软件组 
       **1) 列出软件组** 
       [root@test01 ~]# yum grouplist 	 2) 安装一组软件 
       # yum groupinstall -y <软件组名称>
    
    # yum groupremove -y <软件组名称>
    

源码软件安装

步骤:

  1. 解压缩 *.tar.gz, *.tar.bz2
  2. 配置软件的安装参数
  3. 编译,编译成计算机可执行的二进制程序
  4. 安装

前提:gcc编译环境

示例:安装htop软件

[root@localhost ~]# scp htop-1.0.3.tar.gz 192.168.122.105:/root

[root@test01 ~]# tar zxf htop-1.0.3.tar.gz
[root@test01 ~]# cd htop-1.0.3
[root@test01 htop-1.0.3]# ./configure --prefix=/usr/local/htop
[root@test01 htop-1.0.3]# make
[root@test01 htop-1.0.3]# make install

错误1:

checking for gcc… no
checking for cc… no
checking for cl.exe… no

解决办法:

*# yum install -y gcc

  • 错误2: configure: error: You may want to use --disable-unicode or
    install libncursesw. 解决办法:

    yum install -y ncurses-devel

      解决执行源码软件命令的方法: 1) 修改环境变量PATH的值  
    

    vim /etc/profile export PATH=$PATH:/usr/local/htop/bin

    source /etc/profile

    echo $PATH 2) 建立软链接

    ln -s /usr/local/htop/bin/htop /usr/local/bin**

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值