Linux yum源详解

软件包安装方式

    0.默认从官网下载包(国内,雅虎,网易,阿里云)
        cat /etc/yum.repos.d/rhel-source.repo  【yum文件目录–redhat6版】

【搜狐】http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
【网易】http://mirrors.163.com/.help/CentOS6-Base-163.repo
【阿里】https://mirrors.aliyun.com/help/centos   

   1.yum :  Linux包管理器 ,解决依赖问题,方便快捷

        yum install XXX -y 
        yum groupinstall XXX 包组的列表  -y
        yum grouplist 里面选择包组,然后yum groupinstall "包组" -y
        yum search  包名
        yum search all  查询所有
        yum remove tree -y  删除命令(不建议用,因为yum可以解决依赖问题,删除会删除所有包的依赖)
        yum update; 安装所有软件到最新版本

   2. rpm安装:

        rpm -ivh 包名  i==install h==human 人可读
        rpm -ivh 包名 安装软件
        rpm -qa  包名 查询包名
        最大的问题:就是安装包的依赖问题(a->b->c->d)

     3.源码安装:

 /configure; make; make install  源代码安装方式

在线安装配置yum源

# 查看操作系统版本
cat /etc/redhat-release
# 查看操作系统32/64位
uname -m
# 进入yum文件目录
cd /etc/yum.repos.d
# 备份源文件
cp CentOS-Base.repo CentOS-Base.repo.bak 
# 下载网易yum源
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo 【网易】
#【可选】下载阿里yum源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo  【阿里】
# 更改权限和属组
chmod 644 CentOS6-Base-163.repo
chown root.root CentOS6-Base-163.repo
附[可选]:如果还是用不了yum,可以替换文件内的版本信息为你当前操作系统的版本,一般没问题的
# 替换文件的版本信息
sed -i 's/$releasever/6/g' CentOS6-Base-163.repo  

 

配置yum安装保存安装包

# 更改配置文件
sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf 
# 进入路径下查看安装包
cd /var/cache/yum/*/6/base/packages/
# 查看更改后的文件信息

grep 'keep' /etc/yum.conf


附网易yum源:

 1 # CentOS-Base.repo
 2 #
 3 # The mirror system uses the connecting IP address of the client and the
 4 # update status of each mirror to pick mirrors that are updated to and
 5 # geographically close to the client.  You should use this for CentOS updates
 6 # unless you are manually picking other mirrors.
 7 #
 8 # If the mirrorlist= does not work for you, as a fall back you can try the 
 9 # remarked out baseurl= line instead.
10 #
11 #
12 
13 [base]
14 name=CentOS-$releasever - Base - 163.com
15 baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
16 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
17 gpgcheck=1
18 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
19 
20 #released updates 
21 [updates]
22 name=CentOS-$releasever - Updates - 163.com
23 baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
24 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
25 gpgcheck=1
26 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
27 
28 #additional packages that may be useful
29 [extras]
30 name=CentOS-$releasever - Extras - 163.com
31 baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
32 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
33 gpgcheck=1
34 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
35 
36 #additional packages that extend functionality of existing packages
37 [centosplus]
38 name=CentOS-$releasever - Plus - 163.com
39 baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
40 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
41 gpgcheck=1
42 enabled=
43 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
44 
45 #contrib - packages by Centos Users
46 [contrib]
47 name=CentOS-$releasever - Contrib - 163.com
48 baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/
49 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
50 gpgcheck=1
51 enabled=
52 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

View Code

相关阅读  Linux目录结构

附阿里配置文件

 1 # CentOS-Base.repo
 2 #
 3 # The mirror system uses the connecting IP address of the client and the
 4 # update status of each mirror to pick mirrors that are updated to and
 5 # geographically close to the client.  You should use this for CentOS updates
 6 # unless you are manually picking other mirrors.
 7 #
 8 # If the mirrorlist= does not work for you, as a fall back you can try the 
 9 # remarked out baseurl= line instead.
10 #
11 #
12  
13 [base]
14 name=CentOS-$releasever - Base - mirrors.aliyun.com
15 failovermethod=priority
16 baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
17         http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
18 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
19 gpgcheck=1
20 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
21  
22 #released updates 
23 [updates]
24 name=CentOS-$releasever - Updates - mirrors.aliyun.com
25 failovermethod=priority
26 baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
27         http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
28 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
29 gpgcheck=1
30 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
31  
32 #additional packages that may be useful
33 [extras]
34 name=CentOS-$releasever - Extras - mirrors.aliyun.com
35 failovermethod=priority
36 baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
37         http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
38 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
39 gpgcheck=1
40 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
41  
42 #additional packages that extend functionality of existing packages
43 [centosplus]
44 name=CentOS-$releasever - Plus - mirrors.aliyun.com
45 failovermethod=priority
46 baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
47         http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
48 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
49 gpgcheck=1
50 enabled=
51 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
52  
53 #contrib - packages by Centos Users
54 [contrib]
55 name=CentOS-$releasever - Contrib - mirrors.aliyun.com
56 failovermethod=priority
57 baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
58         http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
59 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
60 gpgcheck=1
61 enabled=
62 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

View Code

相关阅读  Linux wc命令详解

AD:【腾讯云服务器大降价】2核4G 222元/3年 1核2G 38元/年

本文来自一日成建站教程网https://www.yiricheng.cn/),为广大编程爱好者提供零基础快速搭建博客网站的方法,分享计算机网络、HTML、CSS、JavaScript、PHP、响应式设计以及Python自动化办公的博客文章,另有各类小工具、电子书、免费教程。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。