您的位置:首页 > 其它

yum 命令详解

2013-09-25 15:16 381 查看
一、安装YUM工具包1、删除redhat原有的yum源# rpm -aq | grep yum|xargs rpm -e --nodeps2、下载新的yum安装包这里我们使用CentOS的yum源#wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm#wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm#wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm有些包的版本号可能已经改变,如果下载不了,直接上网站查找rpm列表。3.下载并导入KEY# cd /etc/pki/rpm-gpg/# wget http://mirrors.sohu.com/centos/RPM-GPG-KEY-CentOS-5# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*3、安装yum软件包# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm# rpm -ivh yum-metadata-parser-1.1.2-14.1.el6.i686.rpm# rpm -ivh yum-3.2.27-14.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.26-11.el6.noarch.rpm注意:最后两个安装包要放在一起同时安装,否则会提示相互依赖,安装失败。rpm -ivh yum-3.2.22-33.el5.centos.noarch.rpm \yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm \yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm4、更改yum源 #我们使用网易的CentOS镜像源# cd /etc/yum.repos.d/# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo 5. 修改配置文件Vi /etc/yum.repos.d/rhel-debuginfo.repo[base]name=Red Hat Enterprise Linux $releasever -Basebaseurl=http://mirrors.sohu.com/centos/5.5/os/$basearch/gpgcheck=1[update]name=Red Hat Enterprise Linux $releasever -Updatesbaseurl=http://mirrors.sohu.com/centos/5.5/updates/$basearch/gpgcheck=1[extras]name=Red Hat Enterprise Linux $releasever -Extrasbaseurl=http://mirrors.sohu.com/centos/5.5/extras/$basearch/gpgcheck=1[addons]name=Red Hat Enterprise Linux $releasever -Addonsbaseurl=http://mirrors.sohu.com/centos/5.5/addons/$basearch/gpgcheck=1至此yum安装完成,可以 yum install 安装程序了二、使用1、安装、卸载、升级A、安装安装一个软件时:yum -y install httpd安装多个相类似的软件时:yum -y install httpd*安装多个非类似软件时:yum -y install httpd php php-gd mysqlB、卸载卸载一个软件时:yum -y remove httpd卸载多个相类似的软件时:yum -y remove httpd*卸载多个非类似软件时:yum -y remove httpd php php-gd mysqlC、升级升级软件:yum -y update firefox(-y 代表要不要出现安装提示)2、查询A、假如你要使用iostat命令,却发现系统没有这个命令此时,你可以 yum search iostat[root@localhost ~]# yum search iostatLoaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfile* base: mirrors.163.com* extras: centos.ustc.edu.cn* updates: mirrors.163.com=============================== Matched: iostat ================================dstat.noarch : Versatile resource statistics toolsysstat.x86_64 : sar 和 iostat 系统监视命令。然后你就可以找到和iostat相关的安装包了B、查询软件信息:yum info sysstat如果Repo : freshrpms是这样的,表示您的系统没有安装这个软件,如果显示的是:Repo : installed,表示已经安装了。C、列出已经安装的包:yum list installed 列出符合条件的包:yum list mp* |more列出某个软件包:yum list firefox查找某个包是否已安装:yum list installed | grep logwatch统计已经安装包数量:yum list installed |wc -l统计所有可安装包数量:yum list |wc lD、查询yum安装日志:tail /var/log/yum.log
查看yum使用的历史记录的方法:yum history info
==============================================================================================List of Commands:install:Install a package or packages on your systemupdate:Update a package or packages on your systemremove:移出某个软件,后跟软件名称search:Search package details for the given string 搜索某个软件或重要关键字list:List a package or groups of packages列出yum所管理的软件名称与版本,www.linuxidc.com类似于rpm –qainfo:Display details about a package or group of packages,类似于rpm –qaiclean:Remove cached data 下载文件被放置在/var/cache/yum中,可以使用clean清除。check-update:Check for available package updatesGroupinfo:Display details about a package groupgroupinstall   Install the packages in a group on your systemgrouplist:List available package groupsgroupremove:Remove the packages in a group from your systemgroupupdate:升级整个软件群组help:Display a helpful usage messageDeplist:List a package's dependencies    列出软件包的依赖关系,在使用本地源软件包进行安装时,可以查看依赖关系Downgrade:downgrade a packageErase:Remove a package or packages from your systemlocalinstall:Install a local RPM安装本地的rpm软件包makecache:Generate the metadata cache 生成数据缓存provides:Find what package provides the given value 找到包提供的给定值reinstall:reinstall a package 重装软件包repolist:Display the configured software repositoriesresolvedep:Determine which package provides the given dependencyshell:Run an interactive yum shellupgrade:Update packages taking obsoletes into account
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: