• Linux之yum软件包管理


    一、yum软件包管理相关命令

    1.1 yum软件包管理方式说明 

    yum是一个在RedHat、CentOS中自动处理rpm包依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装;yum是由Python语言编写。

    1.2 yum 搜索rpm包

    [root@ping ~]# yum list | grep openssh-clients	#查看yum仓库中的可用的rpm包,并查看是否有openssh rpm包
    openssh-clients.x86_64     5.3p1-81.el6     @anaconda-CentOS-201207061011.x86_64/6.3      
    
    [root@ping ~]# yum info lftp 					#列出lftp软件包相关信息
    Loaded plugins: downloadonly, fastestmirror, security
    Loading mirror speeds from cached hostfile
    Available Packages
    Name        : lftp
    Arch        : i686
    Version     : 4.0.9
    Release     : 1.el6
    Size        : 735 k
    .............   
    yum search lftp 
    [root@ping ~]# yum search wget 					#在yum仓库中搜索有关lftp 的软件包
    Loaded plugins: downloadonly, fastestmirror, security
    Loading mirror speeds from cached hostfile
    ============================================== N/S Matched: wget =================================
    wget.x86_64 : A utility for retrieving files using the HTTP or FTP protocols
    

    1.3 yum 安装rpm包 

    [root@ping ~]# yum -y install nmap #安装nmap工具,无需询问是否安装
    [root@ping ~]# rpm -qa | grep nmap -i   #查看当前系统中安装的所有rpm包,并使用grep配置是否有nmap相关字符
    nmap-5.51-2.el6.x86_64
    
    [root@ping ~]# yum -y localinstall /mnt/Packages/wireshark-1.2.15-2.el6_2.1.x86_64.rpm   #安装本地的rpm包,需要的相关依赖包会从yum软件仓库中安装
    
    [root@ping ~]# yum install -y https://mirrors.aliyun.com/centos/7.4.1708/os/x86_64/Packages/netsniff-ng-0.5.8-10.el7.x86_64.rpm  #安装aliyun镜像网站上的rpm软件包
    

    1.4 yum 卸载rpm包

    [root@ping ~]# yum erase nmap -y  && yum remove nmap -y 	#卸载该软件包,但是不会删除该软件的相关依赖包
    

    1.5 查看linux shell命令,由什么rpm包安装的

    [root@ping ~]# yum provides /bin/rm #查看rm命令的软件包
    coreutils-8.4-19.el6.x86_64 : A set of basic GNU tools commonly used in shell
                                : scripts
    Repo        : mnt_
    Matched from:
    Filename    : /bin/rm
    
    [root@ping ~]# yum provides *bin/lsb_release 
    redhat-lsb-4.0-3.el6.centos.x86_64 : LSB base libraries support for CentOS
    Repo        : installed
    Matched from:
    Filename    : /usr/bin/lsb_release
    

      

    1.6 yum 包组

    [root@ping ~]# yum grouplist #列出当前系统安装的软件包组,可以安装的软件包组
    [root@ping ~]# yum groupinstall Development tools Base Compatibility libraries Debugging Tools virtualization-tools #安装软件包组
    [root@ping ~]# yum groupremove virtualization-tools #卸载软件包组
    

    1.7 查看yum仓库

    [root@ping ~]# yum repolist #列出当前系统可以使用yum仓库
    

    1.8 使用yum下载rpm包

    [root@ping ~]# yum install --downloadonly --downloaddir=/tmp   perl-Sys-Syslog  
    

      

    二、本地yum源仓库

    2.1 本地yum源需求说明

    当企业Linux服务器在内网中,不能与公网yum源镜像网站之间进行通信,这个时候就需要利用系统光盘镜像配置本地yum源,提供给用户下载软件包。

    2.2 搭建本地yum源

    2.2.1 将光盘镜像文件挂载到mnt目录下
    [root@ping tmp]# mount -o loop /tmp/CentOS-6.3-x86_64-bin-DVD1.iso /mnt/  
    2.2.2 使用yum-config-magager命令创建yum源文件
    [root@ping mnt]# yum-config-manager --add file:///mnt/
    Loaded plugins: fastestmirror
    adding repo from: file:///mnt/
    [mnt_]
    name=added from: file:///mnt/
    baseurl=file:///mnt/
    enabled=1
    
    2.2.3 配置yum源不进行签名验证
    [root@ping ~]# echo -e "gpgcheck=0
    " >> /etc/yum.repos.d/mnt_.repo && sed -i '$a gpgcheck=0' /etc/yum.repos.d/mnt_.repo
    
    2.2.4 查看yum源配置文件
    [root@ping ~]# cat /etc/yum.repos.d/mnt_.repo 
    [mnt_]	#仓库名称
    name=added from: file:///mnt/	#仓库描述信息
    baseurl=file:///mnt/	#YUM源url地址,如:[file:// ftp:// http://]
    enabled=1 #是否激活该YUM源(0代表禁用,1代表激活,默认为激活)
    gpgcheck=0 #安装软件时是否检查签名(0代表禁用,1代表激活)
    2.3 注意
    [root@ping ~]# rpm -qf $(which yum-config-manager)
    yum-utils-1.1.30-40.el6.noarch 
    有时我们的系统是最小化安装,没有yum-config-manager命令,所以我们需要安装该命令的软件包
    

      

    三、配置网络yum源

    3.1 配置aliyun centos yum源

    [root@ping ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

    3.2 配置内网网络yum源

    [root@ping ~]# yum-config-manager --add ftp://192.168.100.2/centos6.7/
    [root@ping ~]# cat /etc/yum.repos.d/192.168.100.2_centos6.7_.repo 
    [192.168.100.2_centos6.7_]
    name=added from: ftp://192.168.100.2/centos6.7/
    baseurl=ftp://192.168.100.2/centos6.7/
    enabled=1
    
     
    

      

     

      

  • 相关阅读:
    asp.net大文件断点续传
    JS大文件上传解决方案
    B/S大文件上传解决方案
    B/S上传整个文件夹
    网页上传整个文件夹
    POJ 1068 Parencodings
    74LS85 比較器 【数字电路】
    二叉树的建立与先序,后序,中序输出
    Android 学习之 开源项目PullToRefresh的使用
    理解矩阵及谱聚类小记
  • 原文地址:https://www.cnblogs.com/pingzhe/p/7082385.html
Copyright © 2020-2023  润新知