Linux学习笔记――程序包管理之yum

YUM

  yum 是rpm程序包管理器的前段管理器。yum 主要功能是更方便的添加/删除/更新RPM 包,自动解决包的倚赖性问题,便于管理大量系统的更新问题。

  yum 的操作是基于yum 仓库进行的

  yum repository: yum repo  yum仓库

存储了众多rpm包,以及包的相关的元数据文件(放置于特定目录下:repodata);


文件服务器:

ftp://

http://

nfs://

file:///

  yum 的配置

    配置文件

      /etc/yum.conf:为所有仓库提供公共配置

       wKioL1Xq4syTXJR5AAE7mw8yBZc829.jpg

      /etc/yum.repos.d/*.repo:为仓库的指向提供配置

        

仓库指向的定义:

[repositoryID]

name=Some name for this repository

baseurl=url://path/to/repository/

enabled={1|0}

gpgcheck={1|0}

gpgkey=URL

enablegroups={1|0}

failovermethod={roundrobin|priority}

默认为:roundrobin,意为随机挑选;

cost=

默认为1000


    yum命令的用法:

      yum [options] [command] [package ...]


       command is one of:

        * install package1 [package2] [...]

        * update [package1] [package2] [...]

        * update-to [package1] [package2] [...]

        * check-update

        * upgrade [package1] [package2] [...]

        * upgrade-to [package1] [package2] [...]

        * distribution-synchronization [package1] [package2] [...]

        * remove | erase package1 [package2] [...]

        * list [...]

        * info [...]

        * provides | whatprovides feature1 [feature2] [...]

        * clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]

        * makecache

        * groupinstall group1 [group2] [...]

        * groupupdate group1 [group2] [...]

        * grouplist [hidden] [groupwildcard] [...]

        * groupremove group1 [group2] [...]

        * groupinfo group1 [...]

        * search string1 [string2] [...]

        * shell [filename]

        * resolvedep dep1 [dep2] [...]

        * localinstall rpmfile1 [rpmfile2] [...]

           (maintained for legacy reasons only - use install)

        * localupdate rpmfile1 [rpmfile2] [...]

           (maintained for legacy reasons only - use update)

        * reinstall package1 [package2] [...]

        * downgrade package1 [package2] [...]

        * deplist package1 [package2] [...]

        * repolist [all|enabled|disabled]

        * version [ all | installed | available | group-* | nogroups* | grouplist | groupinfo ]

        * history [info|list|packages-list|packages-info|summary|addon-info|redo|undo|rollback|new|sync|stats]

        * check

        * help [command]


    显示仓库列表:

    repolist [all|enabled|disabled]

     wKiom1Xq5FHio_EpAAGhvtJqWVo668.jpg

    显示程序包:

    list

    # yum list [all | glob_exp1] [glob_exp2] [...]

    # yum list {available|installed|updates} [glob_exp1] [...]

    wKioL1Xq5yPiNS8mAAX8bxTeGmA718.jpg


    安装程序包:

    install package1 [package2] [...]

     wKioL1Xq8JCiGFcQAASXh481eik051.jpg

    reinstall package1 [package2] [...]  (重新安装)

    


    升级程序包:

    update [package1] [package2] [...]

    downgrade package1 [package2] [...] (降级)


    检查可用升级:

    check-update


    卸载程序包:

    remove | erase package1 [package2] [...]

    wKioL1Xq8YTQxwxIAALjHeFELfQ561.jpg


    查看程序包information:

    info [...]


    查看指定的特性(可以是某文件)是由哪个程序包所提供:

    provides | whatprovides feature1 [feature2] [...]


    清理本地缓存:

    clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]


    构建缓存:

    makecache


    搜索:

    search string1 [string2] [...]


    以指定的关键字搜索程序包名及summary信息;


    查看指定包所依赖的capabilities:

    deplist package1 [package2] [...]


    查看yum事务历史:

    history [info|list|packages-list|packages-info|summary|addon-info|redo|undo|rollback|new|sync|stats]

    wKioL1Xq81XxXpIxAAEHyMZbU00562.jpg

    安装及升级本地程序包:

  * localinstall rpmfile1 [rpmfile2] [...]

           (maintained for legacy reasons only - use install)

        * localupdate rpmfile1 [rpmfile2] [...]

           (maintained for legacy reasons only - use update)


    包组管理的相关命令:

        * groupinstall group1 [group2] [...]

        * groupupdate group1 [group2] [...]

        * grouplist [hidden] [groupwildcard] [...]

        * groupremove group1 [group2] [...]

        * groupinfo group1 [...]

    如何使用光盘当作本地yum仓库:

    (1) 挂载光盘至某目录,例如/media/cdrom

    # mount -r -t iso9660 /dev/cdrom /media/cdrom

    (2) 创建配置文件

    [CentOS7]

    name=

    baseurl=

    gpgcheck=

    enabled=


    yum的命令行选项:

    --nogpgcheck:禁止进行gpg check;

    -y: 自动回答为“yes”;

    -q:静默模式;

    --disablerepo=repoidglob:临时禁用此处指定的repo;

    --enablerepo=repoidglob:临时启用此处指定的repo;

    --noplugins:禁用所有插件;


    yum的repo配置文件中可用的变量:

    $releasever: 当前OS的发行版的主版本号;

    $arch: 平台;

    $basearch:基础平台;

    $YUM0-$YUM9


    例如:http://mirrors.magedu.com/centos/$releasever/$basearch/os


    创建yum仓库:

    createrepo [options] <directory>


你可能感兴趣的:(linux,yum,yum仓库,程序包管理)