lsb_release -a查看操作系统发行信息:
cat /etc/*release查看操作系统位数:
getconf LONG_BIT
在 linux 系统上,软件包之间的依赖关系是一件很让人头疼的事情。很多工作无法实现可能就是因为缺少一个软件包,而当你千方百计找到这个软件包的时候,却发现它跟当前系统不兼容,这真是一件令人抓狂的事情。所以,我拿到盖机器后,要做的非常重要的一件事情就是给系统添加软件仓库,以确保我能顺利的安装上大部分软件包。
删除系统自带的 yum 服务:
rpm -qa | grep yum | xargs rpm -e --nodeps
然后去镜像网站下载 yum 的安装包重新安装。我选择的是 163 的镜像(http://mirrors.163.com/centos/),然后下载下列软件包:
wget http://mirrors.163.com/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm wget http://mirrors.163.com/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm wget http://mirrors.163.com/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm
下载完成后将它们全部安装上:
rpm -ivh *.rpm
安装完 yum 后,我去 163 的官方网站(http://mirrors.163.com/.help/centos.html?1304848825)下载了一个配置文件放到 /etc/yum.repos.d 目录下,然后运行以下命令,以清除缓存并下载新的镜像缓存:
yum clean all yum makecache
问题出现了,运行 yum makecache 时提示镜像地址不对。我手动打开该地址,发现该地址确实不存在。然后我将镜像地址的目录一级一级的向前退,终于发现了一个 readme 文件,该文件内容如下:
wget This directory (and version of CentOS) is deprecated. For normal users, you should use /5/ and not /5.6/ in your path. Please see this FAQ concerning the CentOS release scheme: https://wiki.centos.org/FAQ/General If you know what you are doing, and absolutely want to remain at the 5.6 level, go to http://vault.centos.org/ for packages. Please keep in mind that 5.6 no longer gets any updates
原来是地址发生了变化,按照提示,在浏览器中找到了对应的镜像地址,于是修改配置文件:
gedit /etc/yum.repos.d/CentOS5-Base-163.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 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://mirrors.163.com/centos/5/os/i386/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/5/updates/i386/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/5/extras/i386/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus baseurl=http://mirrors.163.com/centos/5/centosplus/i386/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib baseurl=http://mirrors.163.com/centos/5/contrib/i386/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/5/os/i386/RPM-GPG-KEY-CentOS-5
保存后再次执行以下命令:
yum clean all yum makecache
到此,添加软件仓库成功。
yum install yum-priorities
安装完后需要设置/etc/yum.repos.d/ 目录下的.repo相关文件(如CentOS-Base.repo),在这些文件中插入顺序指令:priority=N (N为1到99的正整数,数值越小越优先),例如:
[epel] name=Extra Packages for Enterprise Linux 5 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL priority=2 [epel-debuginfo] name=Extra Packages for Enterprise Linux 5 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch/debug mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL gpgcheck=1 priority=2 [epel-source] name=Extra Packages for Enterprise Linux 5 - $basearch - Source #baseurl=http://download.fedoraproject.org/pub/epel/5/SRPMS mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL gpgcheck=1 priority=2
wget http://mirrors.yun-idc.com/epel/5/i386/epel-release-5-4.noarch.rpm rpm -ivh epel-release-5-4.noarch.rpm yum clean all yum makecache
再次尝试安装 git,成功了。
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.i386.rpm rpm -ivh rpmforge-release-0.5.3-1.el5.rf.i386.rpm yum clean all yum makecache
wget http://download1.rpmfusion.org/free/el/updates/5/i386/rpmfusion-free-release-5-1.noarch.rpm wget http://download1.rpmfusion.org/nonfree/el/updates/5/i386/rpmfusion-nonfree-release-5-1.noarch.rpm
下载完成之后同上安装即可。安装完后记得在配置文件中修改 priority=N,以修改软件仓库的加载顺序。
yum install -y bash-completion
安装完成之后执行以下命令:
echo '. /etc/bash_completion' >> /etc/bashrc source /etc/bashrc
这样,在你输入 yum install lib 之后,再按 Tab 键,便会列出所有的可安装的软件包。bash-completion 的补全功能是通过配置文件实现的,配置文件放在 /etc/bash_completion.d/ 下。如果发现有软件工具无法自动补全,可以安装相应的配置文件试试。