yum基于RPM包管理,是一个 Fedora 和 RedHat 以及 SUSE 中的 Shell 前端软件包管理器。支持从指定服务器自动下载RPM包且安装,自动处理依赖性关系,并且一次性安装所有依赖的软件包,不用繁琐的下载安装。华纳云在本文为大家分享关于yum的应用。
yum实现查找、安装、删除某个、一组甚至全部软件包的命令,且简洁好记。yum语法:
yum [options] [command] [package ...]
options:可选,选项包括-h(帮助),-y(当安装过程提示选择全部为 "yes"),-q(不显示安装的过程)等等;command:要进行的操作;package:安装的包名。
日常Linux使用过程中,yum常用命令如下。
列出所有可更新的软件清单命令:
yum check-update
更新所有软件命令:
yum update
仅安装指定的软件命令:
yum install <package_name>
仅更新指定的软件命令:
yum update <package_name>
列出所有可安装的软件清单命令:
yum list
删除软件包命令:
yum remove <package_name>
查看软件包命令:
yum search <keyword>
清除缓存命令,清楚缓存目录下的软件包:
yum clean packages
清除目录下的headers:
yum clean headers
清除目录下旧的headers:
yum clean oldheaders
清楚缓存目录下的软件包及旧的headers:
yum clean, yum clean all (= yum clean packages; yum clean oldheaders)
如pam-devel的安装:
[root@www ~]# yum install pam-devel
Setting up Install Process
Parsing package install arguments
Resolving Dependencies <==先检查软件的属性相依问题
--> Running transaction check
---> Package pam-devel.i386 0:0.99.6.2-4.el5 set to be updated
--> Processing Dependency: pam = 0.99.6.2-4.el5 for package: pam-devel
--> Running transaction check
---> Package pam.i386 0:0.99.6.2-4.el5 set to be updated
filelists.xml.gz 100% |=========================| 1.6 MB 00:05
filelists.xml.gz 100% |=========================| 138 kB 00:00
-> Finished Dependency Resolution
……(省略)
移除pam-devel:
[root@www ~]# yum remove pam-devel
Setting up Remove Process
Resolving Dependencies <==同样的,先解决属性相依的问题
--> Running transaction check
---> Package pam-devel.i386 0:0.99.6.2-4.el5 set to be erased
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Removing:
pam-devel i386 0.99.6.2-4.el5 installed 495 k
Transaction Summary
=============================================================================
Install 0 Package(s)
Update 0 Package(s)
Remove 1 Package(s) <==还好,并没有属性相依的问题,单纯移除一个软件
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : pam-devel ######################### [1/1]
Removed: pam-devel.i386 0:0.99.6.2-4.el5
Complete!
利用yum来查找pam开头的软件名称有哪些:
[root@www ~]# yum list pam*
Installed Packages
pam.i386 0.99.6.2-3.27.el5 installed
pam_ccreds.i386 3-5 installed
pam_krb5.i386 2.2.14-1 installed
pam_passwdqc.i386 1.0.2-1.2.2 installed
pam_pkcs11.i386 0.5.3-23 installed
pam_smb.i386 1.1.7-7.2.1 installed
Available Packages <==底下则是『可升级』的或『未安装』的
pam.i386 0.99.6.2-4.el5 base
pam-devel.i386 0.99.6.2-4.el5 base
pam_krb5.i386 2.2.14-10 base
如果您需要更多关于yum服务器使用,请参考:《怎么在centos7中搭建yum服务器?》