1、进入到/etc/yum.repos.d/目录下,备份之前的CentOS-Base.repo地址。
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
2、下载阿里云yum源,对应系统版本
centos7:
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O CentOS-Base.repo
centos6:
wget http://mirrors.aliyun.com/repo/Centos-6.repo -O CentOS-Base.repo
centot5:
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O CentOS-Base.repo
3、将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度
yum clean all
yum makecache
如果你在执行上面这边命令时,报错:
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
建议用如下方法解决:检查/etc/yum.repos.d/下是否有epel.repo文件,如果有,重命名为epel.repo_bak 千万不能以.repo格式备份,然后在执行一次上面的命令即可!
由于ubuntu 官方的源下载很慢,我们可以替换为国内的源提高下载速度更换为阿里云的源
首先备份本地的源
cp /etc/apt/sources.list /etc/apt/sources.list.bak
编辑源文件
vim /etc/apt/sources.list
#删除原有内容,添加下面内容
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
更新源
apt-get update
讲讲Ubuntu中的高级包管理方法apt-get
配置文件/etc/apt/sources.list
对于Server版, 推荐使用aptitude来查看,安装、删除deb包
sudo apt-get install aptitude
然后执行 sudo aptitude 进入管 理
也可以使用命令:
aptitude update 更新可用的包列表
aptitude upgrade 升级可用的包
aptitude dist-upgrade 将系统升级到新的发行版
aptitude install pkgname 安装包
aptitude remove pkgname 删除包
aptitude purge pkgname 删除包及其配置文件
aptitude search string 搜索包
aptitude show pkgname 显示包的详细信息
aptitude clean 删除下载的包文件
aptitude autoclean 仅删除过期的包文件
考虑到系统的兼容性,并且上面的东东比较都大,不找最新版本了,直接用apt-get install XXX 来安装.因为我们的Ubuntu是dailyBulid的,所以光盘的内容基本上都是最新的了,无需重新下载.一定要最新版本的话,不妨先apt-get update 来更新一下软件的仓库,然后再 apt-get install.
常用的APT命令参数:
apt-cache search package 搜索包
apt-cache show package 获取包的相关信息,如说明、大小、版本等
sudo apt-get install package 安装包
sudo apt-get install package - - reinstall 重新安装包
sudo apt-get -f install 修复安装"-f = ——fix-missing"
sudo apt-get remove package 删除包
sudo apt-get remove package - - purge 删除包,包括删除配置文件等
sudo apt-get update 更新源
sudo apt-get upgrade 更新已安装的包
sudo apt-get dist-upgrade 升级系统
sudo apt-get dselect-upgrade 使用 dselect 升级
apt-cache depends package 了解使用依赖
apt-cache rdepends package 是查看该包被哪些包依赖
sudo apt-get build-dep package 安装相关的编译环境
apt-get source package 下载该包的源代码
sudo apt-get clean && sudo apt-get autoclean 清理无用的包
sudo apt-get check 检查是否有损坏的依赖