1、yum repolist
获取当前系统有效的repolist,如下图
2、yum list,列出所有可安装的软件包
获取当前有效repolist中所能安装的所有rpm包列表,(很长,慎重),可以结合grep命令,搜索需要安装的软件包具体名称,如yum list |grep smnp,见下图
2.1 yum list updates,列出所有可更新的软件包
2.2 yum list installed,列出所有已安装的软件包
2.3 yum list extras,列出所有已经安装但不在repository的包
3、更换阿里云作为yum源
a)备份当前yum源:mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
b)下载新的CentOS-Base.repo 到/etc/yum.repos.d/
[CentOS 5]
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
[CentOS 6]
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
[CentOS 7]
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
c、运行以下命令生成缓存
yum clean all
d、生成缓存
yum makecache
4、更换阿里元作为EPEL源 (扩展源) EPEL 是yum的一个软件源,里面包含了许多基本源里没有的软件。
a)备份epel源:mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
b)下载新repo 到/etc/yum.repos.d/
epel(RHEL 7)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
epel(RHEL 6)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
epel(RHEL 5)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo
c、运行以下命令生成缓存
yum clean all
d、生成缓存
yum makecache
5、更换网易云为yum源
a) 首先备份/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
b)下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)
http://mirrors.163.com/.help/CentOS5-Base-163.repo
http://mirrors.163.com/.help/CentOS6-Base-163.repo
c)运行以下命令生成缓存
yum clean all
yum makecache
6、yum查询想要安装的包
yum search snmp
7、另有命令查看软件包的详细信息
yum info net-snmp
8、加快yun速度,使用yum-plugin-fastestmirror
yum -y install yum-plugin-fastestmirror
9、yum安装卸载命令,
yum install ‘package_name’
yum remove ‘package_name’
最新评论