yum工具的使用和源码包管理
1. yum的工作原理
-
工作原理
-
yum工作分为yum服务器端,客户端yum工具
-
软件仓库在
1.本机–本地仓库
2.另外一台虚拟机
3.阿里云上
-
客户端:虚拟机
-
-
服务器端:
1.发行者把所有的rpm包放在yum服务器上,yum服务器下载相应的文件2.yum服务器有个重要环节整理rpm包的信息(版本号,二进制信息,conf文件和依赖信息),把整理的rpm包信息做成清单
-
客户端:
1.每次安装软件都会解析/etc/yum/repos.d/文件下所有.repo的配置文件,这些文件指定了yum服务器的地址
2.yum会定期更新服务器上的清单,然后保存到客户端的cache里面,
3.每次调用,都会根据相应的文件清单进行安装
2. yum仓库管理
2.1 yum本地仓库的配置文件
1.配置文件有哪些:
-
/etc/yum.conf 作用:为所有仓库提供公共配置
-
vim /etc/yum.conf cachedir=/var/cache/yum/$basearch/$releasever //缓存目录 keepcache=0 //缓存软件包, 1启动 0 关闭 debuglevel=2 //调试级别 logfile=/var/log/yum.log //日志记录位置 exactarch=1 //检查平台是否兼容 obsoletes=1 //检查包是否废弃 gpgcheck=1 //检查来源是否合法,需要有制作者的公钥信息 plugins=1 //是否启用插件 tolerant={1|0} //容错功能,1为开启,0为关闭,当设为0时,如果用yum安装多个软件包且其中某个软件包已经安装过就会报错;当设为1时,当要安装的软件已经安装时自动忽略 installonly_limit=5 bugtracker_url # metadata_expire=90m //每小时手动检查元数据 # in /etc/yum.repos.d //包含repos.d目录
-
/etc/yum.repos.d/*.repo 作用:为仓库的指向提供配置
2.yum的repo配置文件中可用的变量:
- $releaseversion:当前OS的发行版的主版本号
- $arch:平台类型
- $basearch:基础平台
3.定义配置文件
-
[Repo_Name]:仓库名称 name:描述信息 baseurl:仓库的具体路径,接受以下三种类型 ftp:// http:// file:/// enabled:可选值{1|0},1为启用此仓库,0为禁用此仓库 gpgcheck:可选值{1|0},1为检查软件包来源合法性,0为不检查来源 如果gpgcheck设为1,则必须用gpgkey定义密钥文件的具体路径 gpgkey=/PATH/TO/KEY
2.2 本地仓库的配置
-
[root@SYL2 ~]# mount /dev/cdrom /mnt/ 挂载光盘 mount: /mnt: WARNING: device write-protected, mounted read-only. [root@SYL2 ~]# cd /etc/yum.repos.d/ [root@SYL2 yum.repos.d]# ls CentOS-Stream-AppStream.repo CentOS-Stream-HighAvailability.repo CentOS-Stream-RealTime.repo CentOS-Stream-BaseOS.repo CentOS-Stream-Media.repo CentOS-Stream-ResilientStorage.repo CentOS-Stream-Debuginfo.repo CentOS-Stream-NFV.repo CentOS-Stream-Sources.repo CentOS-Stream-Extras.repo CentOS-Stream-PowerTools.repo [root@SYL2 yum.repos.d]# rm -f * [root@SYL2 yum.repos.d]# ls [root@SYL2 yum.repos.d]# vi mushuang.repo [root@SYL2 yum.repos.d]# dnf clean all Failed to set locale, defaulting to C.UTF-8 21 files removed [root@SYL2 yum.repos.d]# cat mushuang.repo [BaseOS] name=baseos baseurl=file:///mnt/BaseOS enabled=1 gpgcheck=0 [AppStream] name=appstream baseurl=file:///mnt/AppStream enabled=1 gpgcheck=0 [root@SYL2 yum.repos.d]# dnf list all yum-utils.noarch 4.0.21-10.el8 BaseOS zenity.x86_64 3.28.1-1.el8 AppStream zip.x86_64 3.0-23.el8 BaseOS zlib.i686 1.2.11-17.el8 BaseOS zlib-devel.i686 1.2.11-17.el8 BaseOS zlib-devel.x86_64 1.2.11-17.el8 BaseOS zsh.x86_64 5.5.1-6.el8_1.2 BaseOS zsh-html.noarch 5.5.1-6.el8_1.2 AppStream zstd.x86_64 1.4.4-1.el8 AppStream zziplib.i686 0.13.68-9.el8 AppStream zziplib.x86_64 0.13.68-9.el8 AppStream zziplib-utils.x86_64 0.13.68-9.el8 AppStream
-
配置好了之后退出安装软件,显示本地库配置完成
-
[root@SYL2 yum.repos.d]# ls /mnt/ AppStream BaseOS EFI LICENSE TRANS.TBL images isolinux media.repo [root@SYL2 yum.repos.d]# [root@SYL2 ~]# yum -y install vim Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:02:37 ago on Thu Apr 7 14:46:20 2022. Dependencies resolved. ============================================================= Package Arch Version Repo Size ============================================================= Installing: vim-enhanced x86_64 2:8.0.1763-16.el8_5.12 AppStream 1.4 M Installing dependencies: gpm-libs x86_64 1.20.7-17.el8 AppStream 39 k vim-common x86_64 2:8.0.1763-16.el8_5.12 AppStream 6.3 M vim-filesystem noarch 2:8.0.1763-16.el8_5.12 AppStream 50 k Transaction Summary ============================================================= Install 4 Packages Total size: 7.8 M Installed size: 30 M Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : vim-filesystem-2:8.0.1763-16.el8_ 1/4 Installing : vim-common-2:8.0.1763-16.el8_5.12 2/4 Installing : gpm-libs-1.20.7-17.el8.x86_64 3/4 Running scriptlet: gpm-libs-1.20.7-17.el8.x86_64 3/4 Installing : vim-enhanced-2:8.0.1763-16.el8_5. 4/4 Running scriptlet: vim-enhanced-2:8.0.1763-16.el8_5. 4/4 Running scriptlet: vim-common-2:8.0.1763-16.el8_5.12 4/4 Verifying : gpm-libs-1.20.7-17.el8.x86_64 1/4 Verifying : vim-common-2:8.0.1763-16.el8_5.12 2/4 Verifying : vim-enhanced-2:8.0.1763-16.el8_5. 3/4 Verifying : vim-filesystem-2:8.0.1763-16.el8_ 4/4 Installed: gpm-libs-1.20.7-17.el8.x86_64 vim-common-2:8.0.1763-16.el8_5.12.x86_64 vim-enhanced-2:8.0.1763-16.el8_5.12.x86_64 vim-filesystem-2:8.0.1763-16.el8_5.12.noarch Complete! [root@SYL2 ~]#
2.3 阿里云仓库配置
-
[root@SYL2 yum.repos.d]# rm -f * [root@SYL2 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:100 2495 100 2495 0 0 12537 0 --:--:-- --:--:-- --:--:-- 12537 [root@SYL2 yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo [root@SYL2 yum.repos.d]# yum clean all Failed to set locale, defaulting to C.UTF-8 29 files removed [root@SYL2 yum.repos.d]# yum makecache Failed to set locale, defaulting to C.UTF-8 CentOS-8.5.2111 - Base - mir 2.3 MB/s | 4.6 MB 00:01 CentOS-8.5.2111 - Extras - m 95 kB/s | 10 kB 00:00 CentOS-8.5.2111 - AppStream 2.7 MB/s | 8.4 MB 00:03 Metadata cache created. [root@SYL2 yum.repos.d]# yum list all Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:02:13 ago on Thu Apr 7 14:53:18 2022. Installed Packages NetworkManager.x86_64 1:1.36.0-0.9.el8 @anaconda NetworkManager-initscripts-updown.noarch
2.4 epel源的配置
-
[root@SYL2 yum.repos.d]# ls CentOS-Base.repo [root@SYL2 yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:04:06 ago on Thu Apr 7 14:53:18 2022. epel-release-latest-8.noarch 162 kB/s | 23 kB 00:00 Dependencies resolved. ============================================================= Package Arch Version Repository Size ============================================================= Installing: epel-release noarch 8-15.el8 @commandline 23 k Transaction Summary ============================================================= Install 1 Package Total size: 23 k Installed size: 32 k Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : epel-release-8-15.el8.noarch 1/1 Running scriptlet: epel-release-8-15.el8.noarch 1/1 Verifying : epel-release-8-15.el8.noarch 1/1 Installed: epel-release-8-15.el8.noarch Complete! [root@SYL2 yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel* [root@SYL2 yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel* [root@SYL2 yum.repos.d]# [root@SYL2 yum.repos.d]# yum clean all Failed to set locale, defaulting to C.UTF-8 36 files removed [root@SYL2 yum.repos.d]# yum makecache Failed to set locale, defaulting to C.UTF-8 CentOS-8.5.2111 - Base - mir 2.3 MB/s | 4.6 MB 00:02 CentOS-8.5.2111 - Extras - m 52 kB/s | 10 kB 00:00 CentOS-8.5.2111 - AppStream 2.6 MB/s | 8.4 MB 00:03 Extra Packages for Enterpris 2.4 MB/s | 11 MB 00:04 Extra Packages for Enterpris 1.1 MB/s | 1.0 MB 00:00 Metadata cache created. [root@SYL2 yum.repos.d]# yum list all [root@SYL2 yum.repos.d]# ls CentOS-Base.repo epel-testing-modular.repo epel.repo epel-modular.repo epel-testing.repo [root@SYL2 yum.repos.d]#
-
配置好了之后退出安装软件,显示配置完成
-
[root@SYL2 ~]# yum -y install zsh Failed to set locale, defaulting to C.UTF-8 Last metadata expiration check: 0:00:15 ago on Thu Apr 7 15:06:58 2022. Dependencies resolved. ============================================================= Package Arch Version Repo Size ============================================================= Installing: zsh x86_64 5.5.1-6.el8_1.2 base 2.9 M Transaction Summary ============================================================= Install 1 Package Total download size: 2.9 M Installed size: 7.2 M Downloading Packages: zsh-5.5.1-6.el8_1.2.x86_64.r 1.3 MB/s | 2.9 MB 00:02 ------------------------------------------------------------- Total 1.3 MB/s | 2.9 MB 00:02 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : zsh-5.5.1-6.el8_1.2.x86_64 1/1 Running scriptlet: zsh-5.5.1-6.el8_1.2.x86_64 1/1 Verifying : zsh-5.5.1-6.el8_1.2.x86_64 1/1 Installed: zsh-5.5.1-6.el8_1.2.x86_64 Complete! [root@SYL2 ~]#
2.5 yum网络仓库
3. yum管理软件
3.1 安装软件包
--nogpgcheck //如果从网上下载包有时会检查gpgkey,此时可以使用此命令跳过gpgkey的检查
-y //自动回答为"yes"
-q //静默模式,安装时不输出信息至标准输出
--disablerepo=repoidglob //临时禁用此处指定的repo
--enablerepo=repoidglob //临时启用此处指定的repo
--noplugins //禁用所有插件
3.1.1 搜索安装包
-
列出软件仓库中可用的软件
-
[root@SYL3 ~]# yum list all|grep yum Failed to set locale, defaulting to C.UTF-8 yum.noarch 4.7.0-4.el8 @anaconda yum-utils.noarch 4.0.21-3.el8 base [root@SYL3 ~]#
-
查询wget是否安装
-
[root@SYL3 ~]# rpm -qa|grep wget [root@SYL3 ~]#
3.1.2 安装软件 yum -y install wget
[root@SYL3 ~]# yum -y install wget
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:57:01 ago on Thu Apr 7 16:46:13 2022.
Dependencies resolved.
=============================================================
Package Arch Version Repository Size
=============================================================
Installing:
wget x86_64 1.19.5-10.el8 AppStream 734 k
Installing dependencies:
libmetalink x86_64 0.1.3-7.el8 base 32 k
Transaction Summary
=============================================================
Install 2 Packages
Total download size: 766 k
Installed size: 2.8 M
Downloading Packages:
(1/2): libmetalink-0.1.3-7.e 50 kB/s | 32 kB 00:00
(2/2): wget-1.19.5-10.el8.x8 430 kB/s | 734 kB 00:01
-------------------------------------------------------------
Total 448 kB/s | 766 kB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : libmetalink-0.1.3-7.el8.x86_64 1/2
Installing : wget-1.19.5-10.el8.x86_64 2/2
Running scriptlet: wget-1.19.5-10.el8.x86_64 2/2
Verifying : libmetalink-0.1.3-7.el8.x86_64 1/2
Verifying : wget-1.19.5-10.el8.x86_64 2/2
Installed products updated.
Installed:
libmetalink-0.1.3-7.el8.x86_64 wget-1.19.5-10.el8.x86_64
Complete!
[root@SYL3 ~]#
3.2 常用的命令
- list 列表
list //列表
all //默认项
[root@SYL3 ~]# yum list all|grep yum
Failed to set locale, defaulting to C.UTF-8
yum.noarch 4.7.0-4.el8 @anaconda
yum-utils.noarch 4.0.21-3.el8 base
[root@SYL3 ~]#
available //列出仓库中有的,但尚未安装的所有可用的包
installed //列出已经安装的包
[root@SYL3 ~]# dnf list installed|grep zsh
Failed to set locale, defaulting to C.UTF-8
zsh.x86_64 5.5.1-6.el8_1.2 @base
[root@SYL3 ~]#
updates //可用的升级
- clean 清理缓存
clean //清理缓存
packages
headers
metadata
dbcache
all
[root@SYL3 ~]# yum clean all //清理缓存
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
18 files removed
[root@SYL3 ~]#
[root@SYL3 ~]# yum makecache //建立缓存
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
CentOS-8.5.2111 - Base - mir 1.5 MB/s | 4.6 MB 00:03
CentOS-8.5.2111 - Extras - m 34 kB/s | 10 kB 00:00
CentOS-8.5.2111 - AppStream 2.5 MB/s | 8.4 MB 00:03
Metadata cache created.
[root@SYL3 ~]#
- 显示
repo
列表及其简要信息 —repolis
repolist //显示repo列表及其简要信息
all
enabled //默认项,启用
disabled //禁用
[root@SYL3 ~]# yum repolist
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
repo id repo name
AppStream CentOS-8.5.2111 - AppStream - mirrors.aliyun.com
base CentOS-8.5.2111 - Base - mirrors.aliyun.com
extras CentOS-8.5.2111 - Extras - mirrors.aliyun.com
[root@SYL3 ~]#
-
升级某一个包
yum update
+包名 -
列出软件包详情
yum info wget
=rpm -qi
+包名
[root@SYL3 ~]# yum info wget
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:02:54 ago on Thu Apr 7 17:47:06 2022.
Installed Packages
Name : wget
Version : 1.19.5
Release : 10.el8
Architecture : x86_64
Size : 2.8 M
Source : wget-1.19.5-10.el8.src.rpm
Repository : @System
From repo : AppStream
Summary : A utility for retrieving files using the HTTP
: or FTP protocols
URL : http://www.gnu.org/software/wget/
License : GPLv3+
Description : GNU Wget is a file retrieval utility which can
: use either the HTTP or FTP protocols. Wget
: features include the ability to work in the
: background while you are logged out, recursive
: retrieval of directories, file name wildcard
: matching, remote file timestamp storage and
: comparison, use of Rest with FTP servers and
: Range with HTTP servers to retrieve files over
: slow or unstable connections, support for
: Proxy servers, and configurability.
[root@SYL3 ~]#
- 查看指定的文件或特性是由哪个包安装生成的
yum provides|whatprovides +绝对路径
=rpm -qf
+绝对路径
[root@SYL3 ~]# rpm -qf /usr/bin/ls
coreutils-8.30-12.el8.x86_64
[root@SYL3 ~]# yum provides /usr/bin/ls //=yum provides *bin/ls
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:23:16 ago on Thu Apr 7 18:12:46 2022.
coreutils-8.30-12.el8.x86_64 : A set of basic GNU tools
: commonly used in shell scripts
Repo : @System
Matched from:
Filename : /usr/bin/ls
coreutils-8.30-12.el8.x86_64 : A set of basic GNU tools
: commonly used in shell scripts
Repo : base
Matched from:
Filename : /usr/bin/ls
coreutils-single-8.30-12.el8.x86_64 : coreutils multicall
: binary
Repo : base
Matched from:
Filename : /usr/bin/ls
[root@SYL3 ~]#
-
以指定的关键字搜索程序包名及summary信息 —
yum search
+包名 -
[root@SYL3 ~]# yum search wget [root@SYL3 ~]# yum list all|grep zsh Failed to set locale, defaulting to C.UTF-8 zsh.x86_64 5.5.1-6.el8_1.2 @base zsh-html.noarch 5.5.1-6.el8_1.2 AppStream [root@SYL3 ~]#
-
显示指定包的依赖关系 —
yum deplist
+包名
[root@SYL3 ~]# yum deplist httpd
-
查看yum的历史事务信息—
yum history
-
[root@SYL3 ~]# yum history Failed to set locale, defaulting to C.UTF-8 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. ID | Command line | Date and time | Action(s) | Altered ------------------------------------------------------------------------------------------------------------------------------------ 18 | -y install wget | 2022-04-07 18:30 | Install | 2 17 | -yq remove wget | 2022-04-07 18:22 | Removed | 2 16 | -y install wget | 2022-04-07 18:21 | Install | 2 15 | -y remove wget | 2022-04-07 18:21 | Removed | 2 14 | -y install wget | 2022-04-07 17:48 | Install | 2 13 | -y remove wget | 2022-04-07 17:48 | Removed | 2 12 | -y install wget | 2022-04-07 17:43 | Install | 2 11 | -y remove wget | 2022-04-07 17:42 | Removed | 2 10 | -y install net-tools | 2022-04-07 17:05 | Install | 1 9 | -y install vim | 2022-04-07 16:33 | Install | 4 8 | -y install zsh | 2022-04-07 15:19 | Install | 1 7 | -y install wget | 2022-04-07 15:15 | Install | 2 6 | -y remove wget | 2022-04-07 15:14 | Removed | 2 5 | -y remove zsh | 2022-04-07 15:14 | Removed | 1 4 | -y install wget | 2022-04-07 15:05 | Install | 2 3 | install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm | 2022-04-07 15:00 | Install | 1 2 | -y install zsh | 2022-04-07 14:52 | Install | 1 1 | | 2022-03-22 16:22 | Install | 401 EE [root@SYL3 ~]#
-
查看历史某一条的信息
[root@SYL3 ~]# yum history info 18
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Transaction ID : 18
Begin time : Thu Apr 7 18:30:50 2022
Begin rpmdb : 405:01d8db73496a1c6f252710e44508dba46719ee5c
End time : Thu Apr 7 18:30:51 2022 (1 seconds)
End rpmdb : 407:22590430e821446f2f07030e07318da6a25c4834
User : root <root>
Return-Code : Success
Releasever : 8
Command Line : -y install wget
Comment :
Packages Altered:
Install libmetalink-0.1.3-7.el8.x86_64 @base
Install wget-1.19.5-10.el8.x86_64 @AppStream
[root@SYL3 ~]#
- 安装本地rpm自动解决依赖关系
[root@SYL3 ~]# ls
1.1.txt anaconda-ks.cfg zsh-5.5.1-6.el8_1.2.x86_64.rpm
[root@SYL3 ~]# yum -y install zsh-5.5.1-6.el8_1.2.x86_64.rpm
- 列出可用包组 –
yum grouplist
[root@SYL3 ~]# yum grouplist
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
CentOS-8.5.2111 - Base - mir 1.7 MB/s | 4.6 MB 00:02
CentOS-8.5.2111 - Extras - m 31 kB/s | 10 kB 00:00
CentOS-8.5.2111 - AppStream 3.0 MB/s | 8.4 MB 00:02
Available Environment Groups:
Server with GUI
Server
Workstation
Custom Operating System
Virtualization Host
Installed Environment Groups:
Minimal Install
Available Groups:
Legacy UNIX Compatibility
Container Management
Development Tools
.NET Core Development
Graphical Administration Tools
Headless Management
Network Servers
RPM Development Tools
Scientific Support
Security Tools
Smart Card Support
System Tools
[root@SYL3 ~]#
- 安装一组软件 —
yum -y groups mark install "Smart Card Support"
[root@SYL3 ~]# yum -y groups mark install "Smart Card Support"
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Last metadata expiration check: 0:05:30 ago on Thu Apr 7 18:52:03 2022.
Dependencies resolved.
=============================================================
Package Arch Version Repository Size
=============================================================
Installing Groups:
Smart Card Support
Transaction Summary
=============================================================
Complete!
[root@SYL3 ~]#
createrepo命令 //创建yum仓库的元数据信息
[root@localhost ~]# yum install createrepo -y
[root@localhost ~]# createrepo [options] <directory>
3.3 重装软件包
-
删除某个文件
-
[root@SYL3 ~]# cd /etc/vsftpd/ [root@SYL3 vsftpd]# ls ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh [root@SYL3 vsftpd]# rm -f vsftpd.conf [root@SYL3 vsftpd]# ls ftpusers user_list vsftpd_conf_migrate.sh [root@SYL3 vsftpd]# yum -y reinstall vsftpd Failed to set locale, defaulting to C.UTF-8 Updating Subscription Management repositories. Unable to read consumer identity [root@SYL3 vsftpd]# ls ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh [root@SYL3 vsftpd]#
3.4 查询软件包
3.4.1 与仓库有关
//列出yum源可用的软件仓库
[root@localhost ~]# yum repolist
//列出全部yum源可用和禁用的仓库
[root@localhost ~]# yum repolist all
//查看这个文件或命令属于哪个包
[root@localhost ~]# yum provides /etc/my.cnf
[root@localhost ~]# yum provides cd
[root@localhost ~]# yum provides *bin/pstree
3.4.2 与缓存有关
//建立缓存
[root@localhost ~]# yum makecache
//缓存软件包, 修改yum全局配置文件
[root@localhost ~]# vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1 //启动缓存
//查看缓存的xml文件
[root@localhost ~]# ls /var/cache/yum/x86_64/7/base/
//查看缓存软件包路径
[root@localhost ~]# ls /var/cache/yum/x86_64/7/
//清除所有缓存
[root@localhost ~]# yum clean all
//只清除缓存的软件包
[root@localhost ~]# yum clean packages
-
将软件下载至指定目录
yum -y install --downloadonly --downloaddir=/tmp/ vsftpd
-
[root@SYL3 ~]# yum -y install --downloadonly --downloaddir=/tmp/ vsftpd Failed to set locale, defaulting to C.UTF-8 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:45:32 ago on Thu Apr 7 18:52:03 2022. Dependencies resolved. ============================================================= Package Arch Version Repository Size ============================================================= Installing: vsftpd x86_64 3.0.3-34.el8 AppStream 181 k Transaction Summary ============================================================= Install 1 Package Total download size: 181 k Installed size: 347 k YUM will only download packages for the transaction. Downloading Packages: vsftpd-3.0.3-34.el8.x86_64.r 124 kB/s | 181 kB 00:01 ------------------------------------------------------------- Total 124 kB/s | 181 kB 00:01 Complete! The downloaded packages were saved in cache until the next successful transaction. You can remove cached packages by executing 'yum clean packages'. [root@SYL3 ~]# rpm -qa|grep vsftpd [root@SYL3 ~]# ls /tmp/ vmware-root_1022-2999133054 vmware-root_1027-4290232097 vmware-root_1023-4248090784 vsftpd-3.0.3-34.el8.x86_64.rpm [root@SYL3 ~]#
3.4.3 与包组成
//列出已经安装和所有可使用的软件组
[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
3.4.4 与历史记录相关
//查看历史执行yum命令
[root@localhost ~]# yum history
//查询历史执行yum命令ID详细信息
[root@localhost ~]# yum history info N
//撤销历史执行过的yum命令
[root@localhost ~]# yum history undo N
-
[root@SYL3 ~]# yum history info 18 Failed to set locale, defaulting to C.UTF-8 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Transaction ID : 18 Begin time : Thu Apr 7 18:30:50 2022 Begin rpmdb : 405:01d8db73496a1c6f252710e44508dba46719ee5c End time : Thu Apr 7 18:30:51 2022 (1 seconds) End rpmdb : 407:22590430e821446f2f07030e07318da6a25c4834 User : root <root> Return-Code : Success Releasever : 8 Command Line : -y install wget Comment : Packages Altered: Install libmetalink-0.1.3-7.el8.x86_64 @base Install wget-1.19.5-10.el8.x86_64 @AppStream [root@SYL3 ~]#
3.4.4
3.4.5 yum检查机制
- rpm软件提供组织redhat在构建rpm包时, 使用其私钥private key对 rpm进行签名
- 客户端在使用rpm为了验证其合法性, 可以使用redhat提供的公钥public key进行签名检查
1.指定公钥位置
[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
2.提前导入
[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
3.不进行签证
//不检查软件包的签名
[root@localhost ~]# yum install httpd --nogpgcheck
3.5 更新软件包
//对比Linux已安装的软件和yum仓库中的软件, 有哪些需要升级
[root@localhost ~]# yum check-update
//更新软件
[root@localhost ~]# yum update acl -y
3.6 卸载软件包 — yum -y install wget
-
[root@SYL3 ~]# rpm -q wget wget-1.19.5-10.el8.x86_64 [root@SYL3 ~]# yum -yq remove wget Failed to set locale, defaulting to C.UTF-8 Removed: libmetalink-0.1.3-7.el8.x86_64 wget-1.19.5-10.el8.x86_64 [root@SYL3 ~]#
4.源码包管理
4.1简述
-
安装一个源码包,是需要我们自己把源代码编译成二进制的可执行文件
-
源码包的编译用到了linux系统里的编译器,利用gcc就可以把C语言变成可执行的二进制文件
4.2 源码包的好处
- 自定义修改源代码
- 定制需要的相关功能
- 新版软件优先更新源码
4.3 源码包的获取
到官方网站
4.4 源码包分类
- 源码格式(需要编译安装)
3.不进行签证
//不检查软件包的签名
[root@localhost ~]# yum install httpd --nogpgcheck
3.5 更新软件包
//对比Linux已安装的软件和yum仓库中的软件, 有哪些需要升级
[root@localhost ~]# yum check-update
//更新软件
[root@localhost ~]# yum update acl -y
3.6 卸载软件包 — yum -y install wget
-
[root@SYL3 ~]# rpm -q wget wget-1.19.5-10.el8.x86_64 [root@SYL3 ~]# yum -yq remove wget Failed to set locale, defaulting to C.UTF-8 Removed: libmetalink-0.1.3-7.el8.x86_64 wget-1.19.5-10.el8.x86_64 [root@SYL3 ~]#
4.源码包管理
4.1简述
-
安装一个源码包,是需要我们自己把源代码编译成二进制的可执行文件
-
源码包的编译用到了linux系统里的编译器,利用gcc就可以把C语言变成可执行的二进制文件
4.2 源码包的好处
- 自定义修改源代码
- 定制需要的相关功能
- 新版软件优先更新源码
4.3 源码包的获取
到官方网站
4.4 源码包分类
- 源码格式(需要编译安装)
- 二进制格式(解压后可以直接使用)