yum
CentOS: yum, dnf
YUM: Yellowdog Update Modifier,rpm的前端程序,可解决软件包相关依赖性,可在多个库之间定位软件包,up2date的替代工具
yum repository: yum repo,存储了众多rpm包,以及包的相关的元数据文件(放置于特定目录repodata下)
文件服务器:
http://
https://
ftp://
file://
yum
配置文件
yum客户端配置文件:
/etc/yum.conf:为所有仓库提供公共配置
/etc/yum.repos.d/*.repo:为仓库的指向提供配置
仓库指向的定义:
[repositoryID]
name=Some name for this repository
baseurl=url://path/to/repository/
enabled={1|0}
gpgcheck={1|0}
gpgkey=URL
enablegroups={1|0}
failovermethod={roundrobin|priority}
roundrobin:意为随机挑选,默认值
priority:按顺序访问
cost= 默认为1000
yum的repo配置文件中可用的变量:
$releasever: 当前OS的发行版的主版本号
$arch: 平台,i386,i486,i586,x86_64等
$basearch:基础平台;i386, x86_64
$YUM0-$YUM9:自定义变量
实例:
http://server/centos/$releasever/$basearch/
http://server/centos/7/x86_64
http://server/centos/6/i384
yum
源
阿里云repo文件:
http://mirrors.aliyun.com/repo/
CentOS系统的yum源
阿里云:https://mirrors.aliyun.com/centos/$releasever/os/x86_64/
教学环境: http://172.20.0.1/cobbler/ks_mirror/$releasever/
EPEL的yum源:
阿里云: https://mirrors.aliyun.com/epel/$releasever/x86_64
教学环境: http://172.20.0.1/fedora-epel/$releasever/x86_64/
yum-config-manager
生成172.16.0.1_cobbler_ks_mirror_CentOS-X-x86_64_.repo
yum-config-manager --add-repo= http://172.16.0.1/cobbler/ks_mirror/7/
yum-config-manager --disable “仓库名" 禁用仓库
yum-config-manager --enable “仓库名” 启用仓库
yum命令
yum命令的用法:
yum [options] [command] [package ...]
显示仓库列表:
yum repolist [all|enabled|disabled]
显示程序包:
yum list
yum list [all | glob_exp1] [glob_exp2] [...]
yum list {available|installed|updates} [glob_exp1] [...]
安装程序包:
yum install package1 [package2] [...]
yum reinstall package1 [package2] [...] (重新安装)
升级程序包:
yum update [package1] [package2] [...]
yum downgrade package1 [package2] [...] (降级)
检查可用升级:
yum check-update
卸载程序包:
yum remove | erase package1 [package2] [...]
查看程序包information:
yum info [...]
查看指定的特性(可以是某文件)是由哪个程序包所提供:
yum provides | whatprovides feature1 [feature2] [...]
清理本地缓存:
清除/var/cache/yum/$basearch/$releasever缓存
yum clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]
构建缓存:
yum makecache
搜索:yum search string1 [string2] [...]
以指定的关键字搜索程序包名及summary信息
查看指定包所依赖的capabilities:
yum deplist package1 [package2] [...]
查看yum事务历史:
yum history [info|list|packages-list|packages-info|
summary|addon-info|redo|undo|
rollback|new|sync|stats]
yum history
yum history info 6
yum history undo 6
日志 :/var/log/yum.log
安装及升级本地程序包:
yum localinstall rpmfile1 [rpmfile2] [...]
(用install替代)
yum localupdate rpmfile1 [rpmfile2] [...]
(用update替代)
包组管理的相关命令:
yum groupinstall group1 [group2] [...]
yum groupupdate group1 [group2] [...]
yum grouplist [hidden] [groupwildcard] [...]
yum groupremove group1 [group2] [...]
yum groupinfo group1 [...]
yum的命令行选项:
--nogpgcheck:禁止进行gpg check
-y: 自动回答为“yes”
-q:静默模式
--disablerepo=repoidglob:临时禁用此处指定的repo
--enablerepo=repoidglob:临时启用此处指定的repo
--noplugins:禁用所有插件
系统光盘yum仓库
系统安装光盘作为本地yum仓库:
(1) 挂载光盘至某目录,例如/mnt/cdrom
mount /dev/cdrom /mnt/cdrom
(2) 创建配置文件(满足四项就可以使用yum安装)
[CentOS7]
name=
baseurl=
gpgcheck=
enabled=
创建yum仓库:
createrepo [options]
yum 安装神奇路径 autofs
安装好后需要启动后才能生效
然后cd到目录就可以实现光盘就可以自动挂载了