Linux yum 命令

yum 全称为 Yellow dog Updater, Modified 是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。

yum 语法

yum [options] [command] [package ...]
  • options:可选
    • -h 帮助
    • -y 自动应答 YES
    • -q 静默执行
    • -t 忽略错误
    • -R[分钟] 设置等待时间
    • --skip-broken 忽略依赖问题
    • --nogpgcheck 忽略GPG验证
  • command:要进行的操作

       check-update 检查可更新的包
  clean all 清除全部
  clean packages 清除临时包文件(/var/cache/yum 下文件)
  clean headers 清除rpm头文件
  clean oldheaders 清除旧的rpm头文件
  deplist 列出包的依赖
  list 可安装和可更新的RPM包
  list installed 已安装的包
  list extras 已安装且不在资源库的包
  info 可安装和可更新的RPM包 信息
  info installed 已安装包的信息(-qa 参数相似)
  install[RPM包] 安装包
  localinstall 安装本地的 RPM包
  update[RPM包] 更新包
  upgrade 升级系统
  search[关键词] 搜索包
  provides[关键词] 搜索特定包文件名
  reinstall[RPM包] 重新安装包
  repolist 显示资源库的配置
  resolvedep 指定依赖
  remove[RPM包] 卸载包

  • package:操作的对象

yum源

网易(163)yum源是国内最好的yum源之一 ,无论是速度还是软件版本,都非常的不错。

将yum源设置为163 yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。

安装步骤

首先备份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载对应版本 repo 文件, 放入 /etc/yum.repos.d/ (操作前请做好相应备份)

  • CentOS5 :http://mirrors.163.com/.help/CentOS5-Base-163.repo
  • CentOS6 :http://mirrors.163.com/.help/CentOS6-Base-163.repo
  • CentOS7 :http://mirrors.163.com/.help/CentOS7-Base-163.repo
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS6-Base-163.repo CentOS-Base.repo

 

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

运行以下命令生成缓存

yum clean all
yum makecache

除了网易之外,国内还有其他不错的 yum 源,比如中科大和搜狐。

中科大的 yum 源,安装方法查看:https://lug.ustc.edu.cn/wiki/mirrors/help/centos

sohu 的 yum 源安装方法查看: http://mirrors.sohu.com/help/centos.html

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值