yum [options] [command] [package …]
yum options
-y //自动回答为"yes"
-q //静默模式,安装时不输出信息至标准输出
--disablerepo=repoidglob //临时禁用此处指定的repo
--enablerepo=repoidglob //临时启用此处指定的repo
--noplugins //禁用所有插件
--nogpgcheck //如果从网上下载包有时会检查gpgkey,此时可以使用此命令跳过gpgkey的检查
all //默认项
installed //列出已经安装的包
updates //可用的升级安装包
available //列出仓库中有的,但尚未安装的所有可用的包
enabled //列出已经启用的仓库
disabled //列出未启用的仓库
all
packages
headers
metadata
dbcache
all
enabled //默认项
disabled
yum install packages […](可以一次性装多个包)
yum update packages […]
update_to //升级为指定版本
示例:
yum info vsftpd
示例:
yum remove httpd
yum erase vsftpd
downgrade package1 [package2 …] //降级
provides|whatprovides //查看指定的文件或特性是由哪个包安装生成的
search string1 [string2 …] //以指定的关键字搜索程序包名及summary信息
deplist package [package2 …] //显示指定包的依赖关系
history //查看yum的历史事务信息
localinstall //安装本地rpm包,自动解决依赖关系
grouplist //列出可用的组
groupinstall "group name" //安装一组软件
createrepo命令 //创建yum仓库的元数据信息
[root@localhost ~]# yum list all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:00:54 前,执行于 2020年08月13日 星期四 16时03分38秒。
已安装的软件包
NetworkManager.x86_64 1:1.20.0-3.el8 @anaconda
NetworkManager-libnm.x86_64 1:1.20.0-3.el8 @anaconda
NetworkManager-team.x86_64 1:1.20.0-3.el8 @anaconda
NetworkManager-tui.x86_64 1:1.20.0-3.el8 @anaconda
PackageKit.x86_64 1.1.12-3.el8 @AppStream
PackageKit-glib.x86_64 1.1.12-3.el8 @AppStream
abattis-cantarell-fonts.noarch 0.0.25-4.el8 @AppStream
………………
[root@localhost ~]# yum list |grep httpd
httpd.x86_64 2.4.37-16.module+el8.1.0+4134+e6bad0ed AppStream
httpd-devel.x86_64 2.4.37-16.module+el8.1.0+4134+e6bad0ed AppStream
httpd-filesystem.noarch 2.4.37-16.module+el8.1.0+4134+e6bad0ed AppStream
httpd-manual.noarch 2.4.37-16.module+el8.1.0+4134+e6bad0ed AppStream
httpd-tools.x86_64 2.4.37-16.module+el8.1.0+4134+e6bad0ed AppStream
keycloak-httpd-client-install.noarch 1.0-2.el8 AppStream
libmicrohttpd.i686 1:0.9.59-2.el8 BaseOS
libmicrohttpd.x86_64 1:0.9.59-2.el8 BaseOS
python3-keycloak-httpd-client-install.noarch 1.0-2.el8 AppStream
redhat-logos-httpd.noarch 81.1-1.el8 BaseOS
[root@localhost ~]# yum info httpd
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:03:05 前,执行于 2020年08月13日 星期四 16时03分38秒。
可安装的软件包
名称 : httpd
版本 : 2.4.37
发布 : 16.module+el8.1.0+4134+e6bad0ed
架构 : x86_64
大小 : 1.4 M
源 : httpd-2.4.37-16.module+el8.1.0+4134+e6bad0ed.src.rpm
仓库 : AppStream
概况 : Apache HTTP Server
URL : https://httpd.apache.org/
协议 : ASL 2.0
描述 : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
[root@localhost ~]# yum install -y httpd
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:05:00 前,执行于 2020年08月13日 星期四 16时03分38秒。
安装:
httpd x86_64 2.4.37-16.module+el8.1.0+4134+e6bad0ed AppStream 1.4 M
安装依赖关系:
redhat-logos-httpd noarch 81.1-1.el8 BaseOS 26 k
apr x86_64 1.6.3-9.el8 AppStream 125 k
apr-util x86_64 1.6.1-6.el8 AppStream 105 k
httpd-filesystem noarch 2.4.37-16.module+el8.1.0+4134+e6bad0ed AppStream 35 k
httpd-tools x86_64 2.4.37-16.module+el8.1.0+4134+e6bad0ed AppStream 103 k
mod_http2 x86_64 1.11.3-3.module+el8.1.0+4134+e6bad0ed AppStream 158 k
安装弱的依赖:
apr-util-bdb x86_64 1.6.1-6.el8 AppStream 25 k
apr-util-openssl x86_64 1.6.1-6.el8 AppStream 27 k
启用模块流:
httpd 2.4
……………
[root@localhost ~]# rpm -qa | grep httpd
httpd-tools-2.4.37-16.module+el8.1.0+4134+e6bad0ed.x86_64
httpd-2.4.37-16.module+el8.1.0+4134+e6bad0ed.x86_64
httpd-filesystem-2.4.37-16.module+el8.1.0+4134+e6bad0ed.noarch
redhat-logos-httpd-81.1-1.el8.noarch
[root@localhost ~]# yum remove httpd -y
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
移除:
httpd x86_64 2.4.37-16.module+el8.1.0+4134+e6bad0ed @AppStream 4.8 M
清除未被使用的依赖关系:
apr x86_64 1.6.3-9.el8 @AppStream 293 k
apr-util x86_64 1.6.1-6.el8 @AppStream 230 k
apr-util-bdb x86_64 1.6.1-6.el8 @AppStream 12 k
apr-util-openssl x86_64 1.6.1-6.el8 @AppStream 20 k
httpd-filesystem noarch 2.4.37-16.module+el8.1.0+4134+e6bad0ed @AppStream 400
httpd-tools x86_64 2.4.37-16.module+el8.1.0+4134+e6bad0ed @AppStream 238 k
mod_http2 x86_64 1.11.3-3.module+el8.1.0+4134+e6bad0ed @AppStream 479 k
redhat-logos-httpd noarch 81.1-1.el8 @BaseOS 3.3 k
……………
[root@localhost ~]# rpm -qa | grep httpd
一般在意外的情况下在会去使用
[root@localhost ~]# yum reinstall httpd
更新的话一般用的饿比较少
[root@localhost ~]# yum update httpd -y
//查看这个文件或命令属于哪个包
[root@localhost ~]# yum provides /etc/my.cnf
[root@localhost ~]# yum provides cd
[root@localhost ~]# yum provides *bin/pstree
//列出已经安装和所有可使用的软件组
[root@localhost ~]# yum groups list
//安装一整个组的软件
[root@localhost ~]# yum groups install Development tools \
Compatibility libraries \
Base Debugging Tools
//yum删除包组
[root@localhost ~]# yum groups remove -y Base
//缓存yum源软件仓库, xml元数据文件
[root@localhost ~]# yum makecache
//清除所有yum缓存
[root@localhost ~]# yum clean all
//只清除缓存的软件包
[root@localhost ~]# yum clean packages
//查看历史执行yum命令
[root@localhost ~]# yum history
//查询历史执行yum命令ID详细信息
[root@localhost ~]# yum history info N
//撤销历史执行过的yum命令
[root@localhost ~]# yum history undo N
[root@localhost ~]# vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@localhost ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@localhost ~]# vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
//不检查软件包的签名
[root@localhost ~]# yum install httpd --nogpgcheck
手机扫一扫
移动阅读更方便
你可能感兴趣的文章