1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Linux学习-21-yum命令(查询 安装 升级和卸载软件包)和软件组管理

Linux学习-21-yum命令(查询 安装 升级和卸载软件包)和软件组管理

时间:2020-12-06 10:44:57

相关推荐

Linux学习-21-yum命令(查询 安装 升级和卸载软件包)和软件组管理

7.9 Linux yum命令(查询、安装、升级和卸载软件包)

yum 提供了查找、安装、删除某一个、一组甚至全部软件包的命令

yum 语法

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

**options:**可选,选项包括-h(帮助),-y(当安装过程提示选择全部为 “yes”),-q(不显示安装的过程)等等。**command:**要进行的操作。**package:**安装的包名。

7.9.1 yum查询命令
使用 yum 对软件包执行查询操作,常用命令可分为以下几种:yum list:查询所有已安装和可安装的软件包

[root@CncLucZK yum.repos.d]# yum list#查询所有可用软件包列表Installed Packages#已经安装的软件包ConsdeKit.i686 0.4.1-3.el6@anaconda-CentOS-07051201 J386/6.3ConsdeKit-libs.i686 0.4.1-3.el6 @anaconda-CentOS-07051201 J386/6.3……Available Packages#还可以安装的软件包389-ds-base.i686 1.2.10.2-15.el6 c6-media389-ds-base-devel.i686 1.2.10.2-15.el6 c6-media#软件名 版本 所在位置(光盘)……

yum list 包名:查询执行软件包的安装情况。

[root@CncLucZK etc]# yum list yumRepository epel is listed more than once in the configurationInstalled Packagesyum.noarch4.0.9.2-5.el8@anacondaAvailable Packagesyum.noarch4.7.0-4.el8

yum search 关键字:从 yum 源服务器上查找与关键字相关的所有软件包。例如:

[root@CncLucZK etc]# yum search redisRepository 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 databasehiredis-devel.x86_64 : Development files for hiredissyslog-ng-redis.x86_64 : Redis support for syslog-ngperl-RDF-Trine-redis.noarch : RDF::Trine store in Redishiredis.x86_64 : Minimalistic C client library for Redisuwsgi-logger-redis.x86_64 : uWSGI - redislog logger pluginredis-doc.noarch : Documentation for Redis including man pagesuwsgi-router-redis.x86_64 : uWSGI - Plugin for Redis router supportpcp-pmda-redis.x86_64 : Performance Co-Pilot (PCP) metrics for Redisredis-devel.x86_64 : Development header for Redis module developmentpython3-redis.noarch : Python 3 interface to the Redis key-value storeperl-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 IXFRlpf.noarch : Local package factory - build non-redistributable rpmspython3-django-rq.noarch : App that provides django integration for RQ (Redis: Queue)

yum info 包名:查询执行软件包的详细信息。例如:

[root@CncLucZK etc]# yum info redisRepository epel is listed more than once in the configurationAvailable 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.rpmRepo : AppStream<-仓库Summary: A persistent key-value databaseURL: http://redis.ioLicense: BSD and MITDescription : 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.

7.9.2 yum安装命令
yum 安装软件包的命令基本格式为:

[root@CncLucZK yum.repos.d]# yum install 包名[root@CncLucZK yum.repos.d]# yum -y install 包名

其中:

install:表示安装软件包。-y:自动回答 yes。如果不加 -y,那么每个安装的软件都需要手工回答 yes;

例如使用此 yum 命令安装 gcc:

[root@CncLucZK yum jepos.d]#yum -y install gcc#使用yum自动安装gcc,会先检查软件的属性相依问题

gcc 是 C 语言的编译器,鉴于该软件包涉及到的依赖包较多,建议使用 yum 命令安装。

对于 Linux 软件安装时提示缺失库的,可以使用 yum 的 provides 参数查看 redis的库文件包含在那个安装包中只需要执行以下命令,然后按查询到安装包包名,使用yum install安装即可。

[root@CncLucZK ~]# yum provides redisRepository epel is listed more than once in the configurationLast metadata expiration check: 0:48:40 ago on Mon 17 Oct 04:09:07 PM CST.redis-5.0.3-5.module_el8.4.0+955+7126e393.x86_64 : A persistent key-value databaseRepo : AppStreamMatched from:Provide : redis = 5.0.3-5.module_el8.4.0+955+7126e393

7.9.3 yum 升级命令

使用 yum 升级软件包,需确保 yum 源服务器中软件包的版本比本机安装的软件包版本高

yum 升级软件包常用命令如下:

yum check-update:列出所有可更新的软件清单命令yum -y update/yum update:升级所有软件包。不过考虑到服务器强调稳定性,因此该命令并不常用。yum -y update 包名/yum update 包名:升级特定的软件包。

7.9.4 yum 卸载命令

使用 yum 卸载软件包时,会同时卸载所有与该包有依赖关系的其他软件包,即便有依赖包属于系统运行必备文件,也会被 yum 无情卸载,带来的直接后果就是使系统崩溃。除非你能确定卸载此包以及它的所有依赖包不会对系统产生影响,否则不要使用 yum 卸载软件包。

yum 卸载命令的基本格式如下:

[root@CncLucZK yum.repos.d]# yum remove 包名#卸载指定的软件包

例如,使用 yum 卸载 redis软件包的命令如下:

[root@CncLucZK yum.repos.d]# yum remove redis #卸载redis软件包#同样的,先解决属性相依的问题#若没有属性相依的问题,单纯移除一个软件

7.9.5 清除缓存命令:
yum clean packages: 清除缓存目录下的软件包yum clean headers: 清除缓存目录下的 headersyum clean oldheaders: 清除缓存目录下旧的 headersyum clean, yum clean all (= yum clean packages; yum clean oldheaders):清除缓存目录下的软件包及旧的 headers

7.10 Linux yum管理软件组

在安装 Linux 系统时,我们可以根据需要自定义安装软件包

选择“Customize now”,会进入图页面

上图所示为 Linux 列出的许多软件包组,例如编辑器、系统工具、开发工具等。在此页面,我们可以根据需要选择要安装的软件包。除了这样在系统安装过程中自选软件包组进行安装之外,当系统安装完成后,我们也可以通过 yum 命令来管理上图的这些软件包组。yum 命令除了可以对软件包进行查询、安装、升级和卸载外,还可完成对软件包组的查询、安装和卸载操作。

7.10.1 yum查询软件组包含的软件
既然是软件包组,说明包含不只一个软件包,通过 yum 命令可以查询某软件包组中具体包含的软件包,命令格式如下:

[root@CncLucZK ~]#yum groupinfo 软件组名#查询软件组中包含的软件

可以用以下命令列出所有的软件包组

[root@CncLucZK ~]# yum grouplistRepository epel is listed more than once in the configurationLast metadata expiration check: 0:01:13 ago on Thu 13 Oct 05:25:38 PM CST.Available Environment Groups:Server with GUIServerMinimal InstallWorkstationKDE Plasma WorkspacesVirtualization HostCustom Operating SystemAvailable Groups:Container Core DevelopmentRPM Development ToolsDevelopment ToolsGraphical Administration ToolsHeadless ManagementLegacy UNIX CompatibilityNetwork ServersScientific SupportSecurity ToolsSmart Card SupportSystem ToolsFedora PackagerXfce

例如,查询 Server 软件包组中包含的软件包,可使用如下命令:

[root@CncLucZK ~]# yum groupinfo ServerRepository epel is listed more than once in the configurationLast metadata expiration check: 0:15:54 ago on Thu 13 Oct 05:25:38 PM CST.Environment Group: ServerDescription: An integrated, easy-to-manage server.Mandatory Groups:Container ManagementHeadless ManagementServer product corecorehardware-supportstandardOptional Groups:Basic Web ServerDNS Name ServerDebugging ToolsFTP ServerFile and Storage ServerGNOMEGuest AgentsHardware Monitoring UtilitiesInfiniband SupportMail ServerNetwork File System ClientNetwork ServersPerformance ToolsRemote Management for LinuxVirtualization HypervisorWindows File Server

7.10.2 yum安装软件组
使用 yum 安装软件包组的命令格式如下:

[root@CncLucZK ~]#yum groupinstall 软件组名#安装指定软件组,组名可以由grouplist查询出来

例如,安装 Web Server 软件包组可使用如下命令:

[root@CncLucZK ~]#yum groupinfo "System Tools“#安装系统工具

7.10.3 yum命令卸载软件组
yum 卸载软件包组的命令格式如下:

[root@CncLucZK ~]# yum groupremove 软件组名#卸载指定软件组

yum 软件包组管理命令更适合安装功能相对集中的软件包集合。例如,在初始安装 Linux 时没有安装图形界面,但后来发现需要图形界面的支持,这时可以手工安装图形界面软件组(X Window System 和 Desktop),就可以使用图形界面了。

参考文献:

Linux yum命令详解

Linux yum 命令

下一篇:Linux学习-22-源码包安装、卸载和升级

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。