码迷,mamicode.com
首页 > 系统相关 > 详细

Linux中yum常用命令总结

时间:2019-05-24 17:19:16      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:oar   移除   安装软件   history   包含   space   fast   user   yum 安装包   

yum 功能说明

yum(Yellow dog Updater Modified)是多个Linux发行版的软件包管理器。如Redhat RHEL、CentOS和Fedora。yum主要用于自动安装、升级rpm软件包,它能自动查找并解决rpm包之间的依赖关系。

语法格式

yum [option/选项] [command/命令] [package/软件包]

yum常用命令

安装安装包

例如这里我们安装http服务

yum install -y httpd#<== 直接使用生产缓存中httpd包

yum install/localinstall -y httpd-2.4.6-80.el7.centos.x86_64.rpm#<== 使用本地RPM包,localinstall后面还可以接一个rpm包的下载地址

移除安装包

例如这里我们移除http安装包

yum remove -y httpd#<== 完全移除软件包,包括所有依赖项,此命令很危险,不建议使用!

更新软件包

yum update httpd#<== 更新指定的软件包

列出软件包

yum list httpd#<== 列出软件包安装信息

已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
已安装的软件包
httpd.x86_64                                            2.4.6-80.el7.centos                                             installed

等同于yum list |grep httpd#<==过滤出含有httpd字样的安装包,包含安装的及没有安装的

httpd.x86_64                            2.4.6-80.el7.centos            installed
httpd-tools.x86_64                      2.4.6-80.el7.centos            @centos7.5
httpd-devel.x86_64                      2.4.6-80.el7.centos            centos7.5
httpd-manual.noarch                     2.4.6-80.el7.centos            centos7.5
libmicrohttpd.x86_64                    0.9.33-2.el7                   centos7.5

搜索安装包

yum search httpd#<== 如果不记得软件包的确切名字,则可以使用search搜索与指定软件包的名称相匹配的所有可用的软件包

httpd.x86_64 : Apache HTTP Server
httpd-devel.x86_64 : Development interfaces for the Apache HTTP server
httpd-manual.noarch : Documentation for the Apache HTTP server
httpd-tools.x86_64 : Tools for use with the Apache HTTP Server
libmicrohttpd.x86_64 : Lightweight library for embedding a webserver in applications
mod_dav_svn.x86_64 : Apache httpd module for Subversion server

  名称和简介匹配 only,使用“search all”试试。

获取安装包信息

yum info httpd#<== 安装软件包前先知道它的信息

已安装的软件包
名称    :httpd
架构    :x86_64
版本    :2.4.6
发布    :80.el7.centos
大小    :9.4 M
源    :installed
简介    : Apache HTTP Server
网址    :http://httpd.apache.org/
协议    : ASL 2.0
描述    : The Apache HTTP Server is a powerful, efficient, and extensible
         : web server.

查看安装包的依赖

yum deplist httpd#<== 获取安装包依赖信息

软件包:httpd.x86_64 2.4.6-80.el7.centos
   依赖:/bin/sh
   provider: bash.x86_64 4.2.46-30.el7
   依赖:/etc/mime.types
   provider: mailcap.noarch 2.1.41-2.el7
   依赖:/usr/sbin/groupadd
   provider: shadow-utils.x86_64 2:4.1.5.1-24.el7
   依赖:/usr/sbin/useradd
   provider: shadow-utils.x86_64 2:4.1.5.1-24.el7
   依赖:httpd-tools = 2.4.6-80.el7.centos
   provider: httpd-tools.x86_64 2.4.6-80.el7.centos
   .....
   .....

列出已安装的包

yum list installed#<== 列出所有已经安装的包

yum list installed|grep httpd#<== 过滤列出指定已经安装的包

查找某个特定文件属于哪个软件包

yum provides /etc/nginx/nginx.conf

检查是否有可用的更新rpm包

yum check-update

更新系统

yum update#<== 更新系统,确保系统版本最新,upgrade命令已经废弃,统一使用update

列出所有可用的群组

yum grouplist

如下(系统使用zh_CN.UTF-8):

可用的环境分组:
   最小安装
   基础设施服务器
   计算节点
   文件及打印服务器
   基本网页服务器
   虚拟化主机
   带 GUI 的服务器
   GNOME 桌面
   KDE Plasma Workspaces
   开发及生成工作站
可用组:
   传统 UNIX 兼容性
   兼容性程序库
   图形管理工具
   安全性工具
   开发工具
   控制台互联网工具
   智能卡支持
   科学记数法支持
   系统管理
   系统管理工具
完成

如系统使用en_US.UTF-8:

Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Basic Web Server
   Virtualization Host
   Server with GUI
   GNOME Desktop
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Compatibility Libraries
   Console Internet Tools
   Development Tools
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
Done

如安装“开发工具”:yum -y groupinstall "Development Tools"

列出启用的 YUM 源

yum repolist

源标识                                                                          源名称                                                                                 状态
centos7.5                                                                       CentOS-$releaserver                                                                    3,971
nginx/x86_64                                                                    nginx repo

列出所有的 YUM 源

yum repolist all#<== 包括禁用的yum源也会列出

YUM 指定安装某个源下的包

yum install XXX --enablerepo=YYY

XXX是要安装的软件,YYY是repo源的名字

如:yum install httpd --enablerepo=centos7.5

下载 YUM 安装包到指定路径且不安装

yum install --downloadonly --downloaddir=/tmp/mysql mysql-community-server

清理所有 YUM 缓存内容

yum clean all

生成缓存

yum makecache

查看 YUM 历史记录

yum history

ID     | 登录用户                 | 日期和时间       | 操作           | 变更数
-------------------------------------------------------------------------------
    11 | root <root>              | 2019-05-24 14:33 | Install        |    1
    10 | root <root>              | 2019-05-24 14:32 | Erase          |    1 EE
     9 | root <root>              | 2019-05-24 14:28 | Install        |    5
     8 | root <root>              | 2019-05-24 14:13 | Erase          |    1
     7 | root <root>              | 2019-05-19 13:07 | Install        |   31
     6 | root <root>              | 2019-05-19 12:40 | I, U           |   17
     5 | root <root>              | 2019-05-19 12:29 | Install        |    1
     4 | root <root>              | 2019-05-19 11:17 | Install        |    1
     3 | root <root>              | 2019-05-19 11:16 | Install        |    1 E<
     2 | root <root>              | 2019-05-19 11:03 | I, U           |    5 >
     1 | 系统 <空>                | 2019-05-19 18:23 | Install        |  313
history list

Linux中yum常用命令总结

标签:oar   移除   安装软件   history   包含   space   fast   user   yum 安装包   

原文地址:https://blog.51cto.com/wutengfei/2399684

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!