目录
YUM是Red Hat的包管理器,基于RPM包管理,能够从指定的服务器自动下载RPM包并安装,可以自动处理依赖关系,并且一次安装所有依赖的软件包。本篇将对YUM的命令进行介绍。
1 YUM语法
yum [options] [command] [package ...]
2 常用示例
2.1 查看YUM资源库信息
1)方法一
[root@strong ~]# yum repoinfo
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Repo-id : server
Repo-name : Red Hat Enterprise Linux 7.6
Repo-revision: 1539194633
Repo-updated : Thu Oct 11 02:03:53 2018
Repo-pkgs : 5,152
Repo-size : 3.4 G
Repo-baseurl : file:///mnt/
Repo-expire : 21,600 second(s) (last: Wed Sep 25 22:50:12 2019)
Filter : read-only:present
Repo-filename: /etc/yum.repos.d/server.repo
repolist: 5,152
2)方法二
[root@strong ~]# yum repolist
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repo id repo name status
server Red Hat Enterprise Linux 7.6 5,152
repolist: 5,152
可以指定-v 查看更详细的信息。
2.2 查看可用的更新
[root@strong ~]# yum check-update
2.3 更新软件
1)更新所有软件
[root@strong ~]# yum update
2)更新某一个软件
[root@strong ~]# yum update sshd
3)仅更新到最新版本
[root@strong ~]# yum update --security sshd
4)仅更新到安全更新的版本
[root@strong ~]# yum update-minimal --security sshd
2.4 搜索软件包
[root@strong ~]# yum search sshd
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
=========================================================== Matched: sshd ============================================================
openssh-server.x86_64 : An open source SSH server daemon
2.5 列出软件包
1)列出所有软件包,包括已安装的和可用的
[root@strong ~]# yum list all
2)列出已安装的软件包
[root@strong ~]# yum list installed
3)列出可用的软件包
[root@strong ~]# yum list available |grep ssh
fence-agents-ilo-ssh.x86_64 4.2.1-11.el7 server
libssh2.i686 1.4.3-12.el7 server
openssh-askpass.x86_64 7.4p1-16.el7 server
openssh-keycat.x86_64 7.4p1-16.el7 server
2.6 查看软件包信息
[root@strong ~]# yum info openssh-server
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Installed Packages
Name : openssh-server
Arch : x86_64
Version : 7.4p1
Release : 16.el7
Size : 971 k
Repo : installed
From repo : anaconda
Summary : An open source SSH server daemon
URL : http://www.openssh.com/portable.html
License : BSD
Description : OpenSSH is a free version of SSH (Secure SHell), a program for logging
: into and executing commands on a remote machine. This package contains
: the secure shell daemon (sshd). The sshd daemon allows SSH clients to
: securely connect to your SSH server.