yum 提供了查找、安装、删除某一个、一组甚至全部软件包的命令
yum 语法
yum [options] [command] [package ...]
[root@CncLucZK yum.repos.d]# yum list
#查询所有可用软件包列表
Installed Packages
#已经安装的软件包
ConsdeKit.i686 0.4.1-3.el6
@anaconda-CentOS-201207051201 J386/6.3
ConsdeKit-libs.i686 0.4.1-3.el6 @anaconda-CentOS-201207051201 J386/6.3
……
Available Packages
#还可以安装的软件包
389-ds-base.i686 1.2.10.2-15.el6 c6-media
389-ds-base-devel.i686 1.2.10.2-15.el6 c6-media
#软件名 版本 所在位置(光盘)
……
[root@CncLucZK etc]# yum list yum
Repository epel is listed more than once in the configuration
Installed Packages
yum.noarch 4.0.9.2-5.el8 @anaconda
Available Packages
yum.noarch 4.7.0-4.el8
[root@CncLucZK etc]# yum search redis
Repository epel is listed more than once in the configuration
=========================== Name Exactly Matched: redis ===========================
redis.x86_64 : A persistent key-value database
========================== Summary & Name Matched: redis ==========================
perl-Redis.noarch : Perl binding for Redis database
hiredis-devel.x86_64 : Development files for hiredis
syslog-ng-redis.x86_64 : Redis support for syslog-ng
perl-RDF-Trine-redis.noarch : RDF::Trine store in Redis
hiredis.x86_64 : Minimalistic C client library for Redis
uwsgi-logger-redis.x86_64 : uWSGI - redislog logger plugin
redis-doc.noarch : Documentation for Redis including man pages
uwsgi-router-redis.x86_64 : uWSGI - Plugin for Redis router support
pcp-pmda-redis.x86_64 : Performance Co-Pilot (PCP) metrics for Redis
redis-devel.x86_64 : Development header for Redis module development
python3-redis.noarch : Python 3 interface to the Redis key-value store
perl-Apache-Session-Redis.noarch : Redis driver for Apache::Session::NoSQL
============================= Summary Matched: redis ==============================
pdns-ixfrdist.x86_64 : A program to redistribute zones over AXFR and IXFR
lpf.noarch : Local package factory - build non-redistributable rpms
python3-django-rq.noarch : App that provides django integration for RQ (Redis
: Queue)
[root@CncLucZK etc]# yum info redis
Repository epel is listed more than once in the configuration
Available Packages <-没有安装
Name : redis <-包名
Version : 5.0.3 <-版本
Release : 5.module_el8.4.0+955+7126e393 <—发布版本
Arch : x86_64 <-适合的硬件平台
Size : 927 k <—大小
Source : redis-5.0.3-5.module_el8.4.0+955+7126e393.src.rpm
Repo : AppStream <-仓库
Summary : A persistent key-value database
URL : http://redis.io
License : BSD and MIT
Description : Redis is an advanced key-value store. It is often referred to as a
: data structure server since keys can contain strings, hashes, lists,
: sets and sorted sets.
:
: You can run atomic operations on these types, like appending to a
: string; incrementing the value in a hash; pushing to a list;
: computing set intersection, union and difference; or getting the
: member with highest ranking in a sorted set.
:
: In order to achieve its outstanding performance, Redis works with an
: in-memory dataset. Depending on your use case, you can persist it
: either by dumping the dataset to disk every once in a while, or by
: appending each command to a log.
:
: Redis also supports trivial-to-setup master-slave replication, with
: very fast non-blocking first synchronization, auto-reconnection on
: net split and so forth.
:
: Other features include Transactions, Pub/Sub, Lua scripting, Keys
: with a limited time-to-live, and configuration settings to make
: Redis behave like a cache.
:
: You can use Redis from most programming languages also.
[root@CncLucZK yum.repos.d]# yum install 包名
[root@CncLucZK yum.repos.d]# yum -y install 包名
其中:
例如使用此 yum 命令安装 gcc:
[root@CncLucZK yum jepos.d]#yum -y install gcc
#使用yum自动安装gcc,会先检查软件的属性相依问题
对于 Linux 软件安装时提示缺失库的,可以使用 yum 的 provides 参数查看 redis的库文件包含在那个安装包中只需要执行以下命令,然后按查询到安装包包名,使用 yum install 安装即可。
[root@CncLucZK ~]# yum provides redis
Repository epel is listed more than once in the configuration
Last metadata expiration check: 0:48:40 ago on Mon 17 Oct 2022 04:09:07 PM CST.
redis-5.0.3-5.module_el8.4.0+955+7126e393.x86_64 : A persistent key-value database
Repo : AppStream
Matched from:
Provide : redis = 5.0.3-5.module_el8.4.0+955+7126e393
使用 yum 升级软件包,需确保 yum 源服务器中软件包的版本比本机安装的软件包版本高
yum 升级软件包常用命令如下:
yum check-update:列出所有可更新的软件清单命令yum -y update/yum update:升级所有软件包。不过考虑到服务器强调稳定性,因此该命令并不常用。yum -y update 包名/yum update 包名:升级特定的软件包。使用 yum 卸载软件包时,会同时卸载所有与该包有依赖关系的其他软件包,即便有依赖包属于系统运行必备文件,也会被 yum 无情卸载,带来的直接后果就是使系统崩溃。除非你能确定卸载此包以及它的所有依赖包不会对系统产生影响,否则不要使用 yum 卸载软件包。
yum 卸载命令的基本格式如下:
[root@CncLucZK yum.repos.d]# yum remove 包名
#卸载指定的软件包
[root@CncLucZK yum.repos.d]# yum remove redis #卸载redis软件包
#同样的,先解决属性相依的问题
#若没有属性相依的问题,单纯移除一个软件


[root@CncLucZK ~]#yum groupinfo 软件组名
#查询软件组中包含的软件
[root@CncLucZK ~]# yum grouplist
Repository epel is listed more than once in the configuration
Last metadata expiration check: 0:01:13 ago on Thu 13 Oct 2022 05:25:38 PM CST.
Available Environment Groups:
Server with GUI
Server
Minimal Install
Workstation
KDE Plasma Workspaces
Virtualization Host
Custom Operating System
Available Groups:
Container Management
.NET Core Development
RPM Development Tools
Development Tools
Graphical Administration Tools
Headless Management
Legacy UNIX Compatibility
Network Servers
Scientific Support
Security Tools
Smart Card Support
System Tools
Fedora Packager
Xfce
[root@CncLucZK ~]# yum groupinfo Server
Repository epel is listed more than once in the configuration
Last metadata expiration check: 0:15:54 ago on Thu 13 Oct 2022 05:25:38 PM CST.
Environment Group: Server
Description: An integrated, easy-to-manage server.
Mandatory Groups:
Container Management
Headless Management
Server product core
core
hardware-support
standard
Optional Groups:
Basic Web Server
DNS Name Server
Debugging Tools
FTP Server
File and Storage Server
GNOME
Guest Agents
Hardware Monitoring Utilities
Infiniband Support
Mail Server
Network File System Client
Network Servers
Performance Tools
Remote Management for Linux
Virtualization Hypervisor
Windows File Server
[root@CncLucZK ~]#yum groupinstall 软件组名
#安装指定软件组,组名可以由grouplist查询出来
[root@CncLucZK ~]#yum groupinfo "System Tools“
#安装系统工具
[root@CncLucZK ~]# yum groupremove 软件组名
#卸载指定软件组
参考文献:
Linux yum命令详解
Linux yum 命令