Skip to content

Commit c6258b2

Browse files
author
YouMeek
committed
2015-12-19
1 parent 15bd1a8 commit c6258b2

5 files changed

Lines changed: 117 additions & 22 deletions

File tree

CentOS-Extra-Packages.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# CentOS 源设置
2+
3+
<h2 id="ubuntu">修改官方源</h2>
4+
5+
> 国内常用源配置方法(该源和官方源是一样的,只是因为服务器在国内会起到加速作用而已):
6+
7+
- 163 源:<http://mirrors.163.com/.help/centos.html>
8+
- 阿里源:<http://mirrors.aliyun.com/help/centos>
9+
- sohu:<http://mirrors.sohu.com/help/centos.html>
10+
11+
> 替换过程(这里以 163 源为例,系统 CentOS 6.7):
12+
13+
- 备份官网源:`sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.20151219.backup`
14+
- 删除官网源:`sudo rm -rf /etc/yum.repos.d/CentOS-Base.repo`
15+
- `cd /etc/yum.repos.d/`
16+
- 下载对应版本repo文件, 放入 **/etc/yum.repos.d/**
17+
- 下载源文件:
18+
- CentOS7:`sudo wget http://mirrors.163.com/.help/CentOS7-Base-163.repo`
19+
- CentOS6:`sudo wget http://mirrors.163.com/.help/CentOS6-Base-163.repo`
20+
- CentOS5:`sudo wget http://mirrors.163.com/.help/CentOS5-Base-163.repo`
21+
- `sudo mv CentOS6-Base-163.repo CentOS-Base.repo`
22+
- 导入key:`rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6`
23+
- `sudo yum clean all`
24+
- `sudo yum makecache`
25+
- `sudo yum update`
26+
27+
28+
<h2 id="ubuntu">第三方源</h2>
29+
30+
> 加入第三方源主要是为了 yum 下载到官方没有提供的软件,在其他社区、第三方源里面有很多的软件包,有些软件是很好用的。CentOS 可以加入多个源,所以就存在一个源的优先级问题了,设置优先级的可以使用 yum-plugin-priorities 工具。一般我是建议官方的优先级是最高的,然后才是第三方的。
31+
32+
- 安装 yum-plugin-priorities:
33+
- CentOS 4 或 CentOS 6:`sudo yum install -y yum-plugin-priorities`
34+
- CentOS 5:`sudo yum install -y yum-priorities`
35+
- 安装完 yum-plugin-priorities 插件后,默认是开启的,如果要关闭可以这样设置:
36+
- `sudo vim /etc/yum/pluginconf.d/priorities.conf`
37+
- 把 enabled=1 改为 enabled=0 即可
38+
- 设置默认源的优先级:
39+
- 一般默认的源配置里面 [base], [updates], [extras][CentOSplus] 的 priority=1, [contrib] 的 priority=2,其他第三的软件源为:priority=N (推荐 N > 10,N 可以为1到99的正整数,数值越小越优先)
40+
- `sudo vim /etc/yum.repos.d/CentOS-Base.repo`
41+
- 配置内容如下图
42+
- ![CentOS 默认源的级别设置](images/CentOS-Extra-Packages-a-1.jpg)
43+
44+
- 安装 EPEL 源:
45+
- 官网中文材料:<https://fedoraproject.org/wiki/EPEL/zh-cn>
46+
- 安装命令:`sudo yum install epel-release`
47+
- 导入 KEY:`rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6`
48+
- 设置 EPEL 源的级别:`vim /etc/yum.repos.d/epel.repo`,追加:priority=11
49+
- 卸载 EPEL 源
50+
- 如果你暂时不想使用 EPEL 源的话,把 epel.repo 里的 enabled=1 改成 enabled=0 即可,如果你完全不需要了,那就直接卸载掉 `sudo rpm -e epel-release`
51+
52+
- 安装 RepoForge 源:(旧的名字为 rpmforge)
53+
- 官网下载 RPM包:<http://repoforge.org/use/>
54+
- 我是 CentOS 6.7 64 位,所以下载 EL 6 x86_64,下载 RMP 安装文件大小:12.3 KB
55+
- 下载命令:`wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm`(我这边 wget 不下来,需要开 VPN,所以你最好有这个心理准备)
56+
- 安装 RPM 文件:`sudo rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm`
57+
- 导入 KEY:`sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag`
58+
- 设置 RepoForge 源的级别:`vim /etc/yum.repos.d/rpmforge.repo`,设置如下图
59+
- ![RepoForge 源的级别设置](images/CentOS-Extra-Packages-a-2.jpg)
60+
61+
- 更新包信息:
62+
- `sudo yum clean all`
63+
- `sudo yum makecache`
64+
- `sudo yum update`
65+
66+
- 测试:
67+
- 命令:`sudo yum check-update`
68+
- 看到显示的结果中包括 rpmforge 和 epel 的列表表示成功。
69+
- `sudo yum install -y htop`(htop 官方源是没有的,所以如果能下载下来就表示已经使用了第三方源)
70+
71+
72+
> 资料:
73+
74+
- <https://wiki.centos.org/zh/PackageManagement/Yum/Priorities>
75+
- <http://www.cnblogs.com/Security-Darren/p/3947952.html>
76+
- <http://freeloda.blog.51cto.com/2033581/1260824>
77+
- <http://www.centoscn.com/CentOS/config/2014/0920/3793.html>
78+
- <http://www.cnblogs.com/mchina/archive/2013/01/04/2842275.html>
79+
- <http://www.ha97.com/2626.html>

CentOS.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
# Linux-Tutorial
2-
3-
感谢在写这套教程过程中陪伴我的各个电子音乐

Ubuntu.md

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -167,52 +167,63 @@ find / -name 文件名(文件名可以用使用通配符)
167167

168168
文章的重点是页面最下面,每个版本的源地址都是不一样的,所以要懂得替换对应的版本英文名称,各个版本的英文名称大家自己找下,然后进行修改。
169169

170-
-
171170

172-
> 国内常用源:
171+
> 国内常用源配置方法:
172+
173173
- 163 源:<http://mirrors.163.com/.help/ubuntu.html>
174174
- 阿里源:<http://mirrors.aliyun.com/help/ubuntu>
175175
- sohu:<http://mirrors.sohu.com/help/ubuntu.html>
176176

177-
-
178-
179177
> 替换过程(更换之前最好备份一下 sources.list 配置文件):
180-
- 备份下:`sudo cp /etc/apt/sources.list /etc/apt/sources_20151128_back.list`
181-
- 用 gedit 编辑器打开配置文件:`sudo gedit /etc/apt/sources.list`
182178
183-
-
179+
- 我以 Ubuntu 14.04 为例,使用网易源:
180+
- 备份下:`sudo cp /etc/apt/sources.list /etc/apt/sources_20151128_back.list`
181+
- 用 gedit 编辑器打开配置文件:`sudo gedit /etc/apt/sources.list`,替换里面所有内容为下面这些内容:
182+
- deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
183+
- deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
184+
- deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
185+
- deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
186+
- deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
187+
- deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
188+
- deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
189+
- deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
190+
- deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
191+
- deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
192+
193+
> 更换源之后,需要在终端中执行,这是必须做的,不然你后面可能会遇到 apt-get 安装会提示:未发现软件包。
184194
185-
> 更换源之后,需要在终端中执行,这是必须做的,不然你后面怎么apt-get安装都是会提示:未发现软件包。
186195
- `sudo apt-get update`
187196

188197
<h2 id="ubuntu">安装软件基础</h2>
189198

190-
> - 取回更新的软件包列表信息:`sudo apt-get update`
191-
> - 查看已经安装了哪些包:`dpkg -l`
192-
> - 查看已安装列表中是否有vim软件,没有安装则没有数据显示:`dpkg -l | grep vim`
193-
> - 查看vim软件安装位置:`dpkg -L vim`
194-
> - 安装名为XXX的软件:`sudo apt-get install XXX`
195-
> - 卸载名为XXX的软件(保留配置文档):`sudo apt-get remove XXX`
196-
> - 卸载名为XXX的软件(删除配置文档):`sudo apt-get –purge remove XXX`
197-
> - 升级系统所有有新版本的软件:`sudo apt-get upgrade`
198-
> - 删除已下载的旧包文件:`sudo apt-get autoclean`
199-
> - 删除所有已下载的包文件:`sudo apt-get clean`
200-
> - 卸载所有自动安装且不再使用的软件包:`sudo apt-get autoremove`
199+
- 取回更新的软件包列表信息:`sudo apt-get update`
200+
- 查看已经安装了哪些包:`dpkg -l`
201+
- 查看已安装列表中是否有vim软件,没有安装则没有数据显示:`dpkg -l | grep vim`
202+
- 查看vim软件安装位置:`dpkg -L vim`
203+
- 安装名为XXX的软件:`sudo apt-get install XXX`
204+
- 卸载名为XXX的软件(保留配置文档):`sudo apt-get remove XXX`
205+
- 卸载名为XXX的软件(删除配置文档):`sudo apt-get –purge remove XXX`
206+
- 升级系统所有有新版本的软件:`sudo apt-get upgrade`
207+
- 删除已下载的旧包文件:`sudo apt-get autoclean`
208+
- 删除所有已下载的包文件:`sudo apt-get clean`
209+
- 卸载所有自动安装且不再使用的软件包:`sudo apt-get autoremove`
201210

202211
<h2 id="ubuntu">安装常用系统软件</h2>
203212

204-
> 安装各个软件之前的必须先执行的命令:`sudo apt-get update`
213+
- 安装各个软件之前的必须先执行的命令:`sudo apt-get update`
205214

206215
---
207216

208217
> VIM
218+
209219
- 介绍:
210220
- 安装:`sudo apt-get -y install vim`
211221
- 资料:
212222

213223
---
214224

215225
> Tmux
226+
216227
- 介绍:
217228
- 安装:`sudo apt-get -y install tmux`
218229
- 资料:
@@ -226,6 +237,7 @@ find / -name 文件名(文件名可以用使用通配符)
226237
---
227238

228239
> sysv-rc-conf
240+
229241
- 介绍:管理启动项,一般是用在 Ubuntu 系统上的,CentOS 一般大家用 chkconfig
230242
- 安装:`sudo apt-get install -y sysv-rc-conf `
231243
- 资料:
@@ -235,41 +247,47 @@ find / -name 文件名(文件名可以用使用通配符)
235247
---
236248

237249
> SSH(Secure Shell)
250+
238251
- 介绍:
239252
- 资料:
240253
- [SSH 常用功能](SSH.md)
241254

242255
---
243256

244257
> NFS(Network FileSystem)
258+
245259
- 介绍:
246260
- 资料:
247261
- [NFS 常用功能](NFS.md)
248262

249263
---
250264

251265
> NTP(Network Time Protocol)
266+
252267
- 介绍:
253268
- 资料:
254269
- [NTP 常用功能](NTP.md)
255270

256271
---
257272

258273
> FTP(File Transfer Protocol)
274+
259275
- 介绍:
260276
- 资料:
261277
- [FTP 常用功能](FTP.md)
262278

263279
---
264280

265281
> VPN(Virtual Private Network)
282+
266283
- 介绍:
267284
- 资料:
268285
- [VPN 常用功能](VPN.md)
269286

270287
---
271288

272289
> Samba
290+
273291
- 介绍:
274292
- 资料:
275293
- [Samba 常用功能](Samba.md)
222 KB
Loading
135 KB
Loading

0 commit comments

Comments
 (0)