• yum命令应用


    记录:322

    场景:在CentOS 7.9操作系统上,使用yum命令安装、卸载、下载、更新、查看软件包;使用yum命令查看镜像仓库信息、创建镜像元数据等。

    版本:

    操作系统:CentOS 7.9

    名词:

    YUM,Yellow dog Updater Modified的简称。一个在线软件安装工具。在Fedora和RedHat以及CentOS操作系统中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

    1.yum基础环境

    1.1配置yum源

    使用yum命令安装软件前提基础,需配置一个正确的yum源,可以是本地镜像仓库,也可以是远程镜像仓库。本例使用阿里云镜像仓库。

    阿里云镜像地址:https://mirrors.aliyun.com/

    (1)yum源配置文件目录

    目录:/etc/yum.repo.d

    (2)下载Centos-7的yum源配置文件到本地

     命令:curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

    (3)下载epel-7.repo的yum源配置文件到本地

    命令:curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

    (4)清空并刷新缓存

    命令:yum clean all && yum makecache

    1.2安装基础包

    安装yum-utils命令:yum install -y yum-utils

    安装net-tools命令:yum install -y net-tools.x86_64

    安装perl命令:yum install -y perl

    2.yum常用命令

    (1)查看帮助

    命令:yum --help

    功能:查看yum支持全部命令和选项,在实际工作中,查看这个手册应该是必备之选。

    (2)安装软件

    安装命令:yum install -y yum-utils

    安装指定版本:yum install -y yum-utils-1.1.31

    功能:安装指定名称的软件包。-y,安装过程中交互的提出的问题都同意。不加-y,交互过程中国需要手动输入yes,继续下一步;输入no,立即终止安装。软件包后不带版本,默认是安装镜像仓库中最新的包,带版本就按照指定版本安装,如果版本不存在就提示,没有包和Error: Nothing to do。

    (3)重新安装软件

    安装命令:yum reinstall -y yum-utils

    功能:重装软件包。

    (4)卸载软件

    命令:yum erase -y yum-utils

    命令:yum remove -y yum-utils

    功能:卸载已安装的软件包。

    (5)清空缓存数据和创建元数据缓存

    命令:yum clean all && yum makecache

    命令:yum clean all

    命令:yum makecache

    功能:yum clean all,清空缓存数据。yum makecache,创建元数据缓存。

    (6)搜索软件包

    命令:yum search yum-utils

    功能:根据包名或者关键字在yum镜像仓库搜索包。

    (7)查看镜像仓库软件包清单

    命令:yum list yum-util

    功能:列出镜像仓库中所有包名称和对应版本以及隶属仓库。

    (8)在仓库列表和搜索列表中显示重复的包名

    仓库列表:yum list --showduplicates yum-utils

    搜索列表:yum search --showduplicates yum-utils

    功能:yum list和yum search命令,使用--showduplicates选项时,把重复的包都列出。

    (9)查看已安装包列表

    查看已安装包列表:yum list installed

    在已安装包列表搜索指定包:yum list installed | grep yum-utils

    功能:查看系统中全量已经安装的软件包;使用grep查看指定包是否在已安装列表中。

    (10)下载包

    命令:yum install --downloadonly --downloaddir /home/mirror/ yum-utils

    功能:使用yum install命令,只下载安装包rpm包到本地目录,不安装软件包。使用这种方式可以下载包,离线安装软件。

    (11)列出镜像仓库

    命令:yum repolist

    功能:列出yum源配置的镜像仓库名称和仓库中软件包数量。

    (12)查软件包详细信息

    查看指定软件包信息:yum info yum-utils

    查看全部软件包信息:yum info

    功能:查看软件包信息,比如软件包名称、架构、版本、大小、仓库、摘要、URL、许可证描述等。英文:Name、Arch、Version、Release、Size、Repo、From repo、Summary 、URL、License、Description。

    (13)查看使用记录

    命令:yum history

    功能:查看使用记录,主要包括Install、Reinstall、Erase等命令的使用。

    (14)查看组信息

    命令:yum groups

    功能;查看可使用组信息。

    (15)更新包

    命令:yum update

    功能:对比系统已经安装的包和仓库中包版本,系统中包版本低于仓库包,就会更新。

    3.yum命令和选项

    命令:yum --help

    功能:查看yum支持全部命令和选项,在实际工作中,查看这个手册应该是必备之选。

    1. Loaded plugins: fastestmirror
    2. Usage: yum [options] COMMAND
    3. List of Commands:
    4. check Check for problems in the rpmdb
    5. check-update Check for available package updates
    6. clean Remove cached data
    7. deplist List a package's dependencies
    8. distribution-synchronization Synchronize installed packages to the latest available versions
    9. downgrade downgrade a package
    10. erase Remove a package or packages from your system
    11. fs Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
    12. fssnapshot Creates filesystem snapshots, or lists/deletes current snapshots.
    13. groups Display, or use, the groups information
    14. help Display a helpful usage message
    15. history Display, or use, the transaction history
    16. info Display details about a package or group of packages
    17. install Install a package or packages on your system
    18. list List a package or groups of packages
    19. load-transaction load a saved transaction from filename
    20. makecache Generate the metadata cache
    21. provides Find what package provides the given value
    22. reinstall reinstall a package
    23. repo-pkgs Treat a repo. as a group of packages, so we can install/remove all of them
    24. repolist Display the configured software repositories
    25. search Search package details for the given string
    26. shell Run an interactive yum shell
    27. swap Simple way to swap packages, instead of using shell
    28. update Update a package or packages on your system
    29. update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
    30. updateinfo Acts on repository update information
    31. upgrade Update packages taking obsoletes into account
    32. version Display a version for the machine and/or available repos.
    33. Options:
    34. -h, --help show this help message and exit
    35. -t, --tolerant be tolerant of errors
    36. -C, --cacheonly run entirely from system cache, don't update cache
    37. -c [config file], --config=[config file]
    38. config file location
    39. -R [minutes], --randomwait=[minutes]
    40. maximum command wait time
    41. -d [debug level], --debuglevel=[debug level]
    42. debugging output level
    43. --showduplicates show duplicates, in repos, in list/search commands
    44. -e [error level], --errorlevel=[error level]
    45. error output level
    46. --rpmverbosity=[debug level name]
    47. debugging output level for rpm
    48. -q, --quiet quiet operation
    49. -v, --verbose verbose operation
    50. -y, --assumeyes answer yes for all questions
    51. --assumeno answer no for all questions
    52. --version show Yum version and exit
    53. --installroot=[path] set install root
    54. --enablerepo=[repo] enable one or more repositories (wildcards allowed)
    55. --disablerepo=[repo] disable one or more repositories (wildcards allowed)
    56. -x [package], --exclude=[package]
    57. exclude package(s) by name or glob
    58. --disableexcludes=[repo]
    59. disable exclude from main, for a repo or for
    60. everything
    61. --disableincludes=[repo]
    62. disable includepkgs for a repo or for everything
    63. --obsoletes enable obsoletes processing during updates
    64. --noplugins disable Yum plugins
    65. --nogpgcheck disable gpg signature checking
    66. --disableplugin=[plugin]
    67. disable plugins by name
    68. --enableplugin=[plugin]
    69. enable plugins by name
    70. --skip-broken skip packages with depsolving problems
    71. --color=COLOR control whether color is used
    72. --releasever=RELEASEVER
    73. set value of $releasever in yum config and repo files
    74. --downloadonly don't update, just download
    75. --downloaddir=DLDIR specifies an alternate directory to store packages
    76. --setopt=SETOPTS set arbitrary config and repo options
    77. --bugfix Include bugfix relevant packages, in updates
    78. --security Include security relevant packages, in updates
    79. --advisory=ADVS, --advisories=ADVS
    80. Include packages needed to fix the given advisory, in
    81. updates
    82. --bzs=BZS Include packages needed to fix the given BZ, in
    83. updates
    84. --cves=CVES Include packages needed to fix the given CVE, in
    85. updates
    86. --sec-severity=SEVS, --secseverity=SEVS
    87. Include security relevant packages matching the
    88. severity, in updates

    以上,感谢。

    2022年11月18日

  • 相关阅读:
    微软官方发布的C#开源、免费、实用的Windows工具箱
    【无标题】
    Web-其他功能
    Java Scanner类:用户输入
    Worthington 胆碱酯酶,丁酰相关说明书
    Hive学习笔记1
    Linux安装python显示“软件包python没有可安装候选”
    java tcp 发送日志
    【Mysql】Mysql中的B+树索引(六)
    多维数组求和函数
  • 原文地址:https://blog.csdn.net/zhangbeizhen18/article/details/127931240