yum命令应用

news/2024/6/18 1:56:29 标签: yum, yum install, Linux, CentOS, 运维

记录: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支持全部命令和选项,在实际工作中,查看这个手册应该是必备之选。

Loaded plugins: fastestmirror
Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package
erase          Remove a package or packages from your system
fs             Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         Display, or use, the groups information
help           Display a helpful usage message
history        Display, or use, the transaction history
info           Display details about a package or group of packages
install        Install a package or packages on your system
list           List a package or groups of packages
load-transaction load a saved transaction from filename
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package
repo-pkgs      Treat a repo. as a group of packages, so we can install/remove all of them
repolist       Display the configured software repositories
search         Search package details for the given string
shell          Run an interactive yum shell
swap           Simple way to swap packages, instead of using shell
update         Update a package or packages on your system
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        Update packages taking obsoletes into account
version        Display a version for the machine and/or available repos.


Options:
  -h, --help            show this help message and exit
  -t, --tolerant        be tolerant of errors
  -C, --cacheonly       run entirely from system cache, don't update cache
  -c [config file], --config=[config file]
                        config file location
  -R [minutes], --randomwait=[minutes]
                        maximum command wait time
  -d [debug level], --debuglevel=[debug level]
                        debugging output level
  --showduplicates      show duplicates, in repos, in list/search commands
  -e [error level], --errorlevel=[error level]
                        error output level
  --rpmverbosity=[debug level name]
                        debugging output level for rpm
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  -y, --assumeyes       answer yes for all questions
  --assumeno            answer no for all questions
  --version             show Yum version and exit
  --installroot=[path]  set install root
  --enablerepo=[repo]   enable one or more repositories (wildcards allowed)
  --disablerepo=[repo]  disable one or more repositories (wildcards allowed)
  -x [package], --exclude=[package]
                        exclude package(s) by name or glob
  --disableexcludes=[repo]
                        disable exclude from main, for a repo or for
                        everything
  --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
  --obsoletes           enable obsoletes processing during updates
  --noplugins           disable Yum plugins
  --nogpgcheck          disable gpg signature checking
  --disableplugin=[plugin]
                        disable plugins by name
  --enableplugin=[plugin]
                        enable plugins by name
  --skip-broken         skip packages with depsolving problems
  --color=COLOR         control whether color is used
  --releasever=RELEASEVER
                        set value of $releasever in yum config and repo files
  --downloadonly        don't update, just download
  --downloaddir=DLDIR   specifies an alternate directory to store packages
  --setopt=SETOPTS      set arbitrary config and repo options
  --bugfix              Include bugfix relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
  --bzs=BZS             Include packages needed to fix the given BZ, in
                        updates
  --cves=CVES           Include packages needed to fix the given CVE, in
                        updates
  --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

以上,感谢。

2022年11月18日


http://www.niftyadmin.cn/n/1248707.html

相关文章

佛教界siri,AI佛法无边:“阿弥陀佛” ?| Mixlab 跨学科

你不一定听说过龙泉寺,也不一定知道贤超法师,但你大概率应该看过,口头禅是:我去问问我师父,满载人性温暖的机器人贤二。或者,你刚好听过贤二聊天机器人的智慧箴言:贤二:佛教界的 sir…

rpm命令应用

记录:323 场景:在CentOS 7.9操作系统上,使用rpm命令安装、卸载、查看软件包。 版本: 操作系统:CentOS 7.9 名词: RPM:Red-Hat Package Manager的简称。一个命令行驱动的软件包管理工具&…

你是否会被人工智能哭泣的声音所打动?| Mixlab 技术前沿

#音频工程#、#AI语音技术#、#AI Deepfake#AI 语音—— 语音识别技术,与语音合成语音识别技术是指机器自动将人的语音,转成文字的技术,即ASR技术:Automatic Speech Recognition。语音合成是计算机将机器内部的文字信息转变为&#…

JPA基础(二)Spring Data JPA

接上篇 接下篇 1、Spring Data JPA的概述 Spring Data JPA 是 Spring 基于 ORM 框架、JPA 规范的基础上封装的一套JPA应用框架,可使开发者用极简的代码即可实现对数据库的访问和操作。它提供了包括增删改查等在内的常用功能,且易于扩展!学习…

posenet怎么玩?真人录制火柴人,骚气起来! | Mixlab 技术前沿

#PoseNet#、#动画简笔画#一键生成骚气的火柴人—— 真人录制使用 Google 的 PoseNet 从摄像头图像计算您的姿势,并渲染简笔画,然后将其导出为动画gif,看起来是不是很简单!摆一个帅气的POSE然后得到:除了录制火柴人&…

Linux查看磁盘、文件系统、文件夹、文件大小的命令(lsblk、df、du、ll)

记录:325 场景:在CentOS 7.9操作系统上,使用lsblk命令查看磁盘大小和磁盘挂载情况;使用df查看文件系统大小和挂载情况;使用du命令查看文件夹(目录)大小;使用ll和ls查看文件大小。 版本: 操作…

AR lab Design AI lab

更新下本实验室的两款开源工具箱的进展:‍1 -AR lab 效果演示‍‍我一直有关注AR领域的创新,尤其是多屏联动、实时互动、图像分割算法等技术。加上之前的创业经验,对于AR我有着任何既有软件功能都可以使用AR来实现一遍的想法,比如…

JPA基础(三)Spring Data JPA

接上篇 1、Specifications动态查询 有时我们在查询某个实体的时候,给定的条件是不固定的,这时就需要动态构建相应的查询语句,在Spring Data JPA中可以通过JpaSpecificationExecutor接口查询。相比JPQL,其优势是类型安全,更加的面向对象。 …