1、总结rpm和yum实现程序包的管理功能.
RPM
RPM解释:
RPM全称为RedhatPackageManager,最早由RedHat公司制定实施,随后被GNU开源操作系统接受并成为很多Linux系统(RHEL)的既定软件标准.
RPM的特点就是将你要安装的软件先编译过,并且打包成RPM机制的安装包。
优点:(1)已经编译好了,所以软件安装方便。
(2)在被安装,会先检查系统的硬盘容量,操作系统版本等,避免文件被错误安装。
(3)rpm本身提供软件版本信息,依赖属性软件名称,软件用途说明,软件所含文件等信息。
程序包的组成部分:
二进制程序:/bin, /sbin,/ /usr/bin, /usr/sbin,
库文件:/lib64, /usr/lib64
配置文件:/etc
帮助文件:manual, info,
命名规则:
以 zsh-4.3.11-4.el6.centos.x86_64.rpm来说明:
zsh:是软件的名字
4.3.11-4:这是软件的版本号
e16:基于该版本的软件包的发行版本号,有软件打包商设置,不一定是原始软件开发商.
x86_64:编译的软件包可以运行的处理器架构(x86_64)
特殊说明:
1、fcXX,elXX:表示这个软件包的发行商版本,就像这里的fc18,说明这个软件包是在Fedora 18下使用的。而openssl-1.0.0-20.el6.x86_64.rpm表示这个软件包是在RHEL 6.x(Red Hat Enterprise Linux)/CentOS 6.x下使用。
2、devel:表示这个RPM包是软件的开发包,例如mysql-devel-5.1.52-1.el6_0.1.i686.rpm。
3、noarch:说明这样的软件包可以在任何平台上安装,不需要特定的硬件平台。在任何硬件平台上都可以运行。
安装,卸载类:
-i:install的意思。
-v:更详细的安装信息画面
-h:显示安装进度
--nodeps:忽略依赖关系
--replacepkgs 重装软件包
-e:卸载软件包
1.安装rpm -ivh zsh-4.3.11-4.el6.centos.x86_64.rpm 安装软件包:
2安装rpm -ivh qt3-MySQL-3.3.8b-30.el6.x86_64.rpm 出现依赖包错误显示:
如果要强制安装此rpm包就需要 --nodeps 参数:
4.如果一个软件已经安装过但是想要重装的话就需要--replacepkgs
5.如果要卸载一个软件:rpm -e
查询类:
-q:仅查询,后面的软件名称是否安装。
-qa:列出系统上已经安装的所有软件名称。
-ql:列出该软件所有的文件与目录所在的完整文件名。
-qi:列出软件的详细信息,包含开发商版本说明。
-qf:查询软件由那个包生成的。
-qc:查看当前程序生成了哪些配置文件。
-p: 查询针对是未安装的程序包文件
1.查询软件包是否安装:rpm -q name:
2.查询已安装的软件:rpm -qa(我这里一共安装了454个软件)
3.查询zsh所有的文件目录:rpm -ql
4.查询zsh包含有的信息:rpm -qi
5.查询软件由哪个包生成的:rpm -qf
6.查询当前软件生成了哪些配置文件:rpm -qc
7.查询针对未安装的程序文件:rpm -qpi ,rpm -qpl
软件更新:
-Uvh:后面跟的软件如果没有安装过,则直接安装,如果有安装旧版,则系统自动更新。
-Fvh:后面跟的软件如果没有安装过,则不会安装,只有安装到系统内部的软件会被升级。
校验:
rpm {-V|--verify} [select-options] [verify-options]
S file Size differs
M Mode differs (includes permissions and file type)
5 digest (formerly MD5 sum) differs
D Device major/minor number mismatch
L readLink(2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs
P caPabilities differ
实例:修改一个程序文件然后在校验:rpm -V zsh
[[email protected] Packages]# rpm -V zsh S.5....T. /usr/share/zsh/4.3.11/functions/zrecompile [[email protected] Packages]#
包校验:
来源合法性验正:非对称加密
完整性验正:单向加密
导入密钥:rpm -ivh RPM-GPG-KEY-CentOS-6
校验:rpm -K /PATH/TO/RPM_FILE
[[email protected] Packages]# rpm -K zsh-4.3.11-4.el6.centos.x86_64.rpm zsh-4.3.11-4.el6.centos.x86_64.rpm: rsa sha1 (md5) pgp md5 OK
YUM
YUM命令的解释:
yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器。基於RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。
yum程序的配置文件:
/etc/yum.conf
定义全局配置:对所有仓库都适用的配置
/etc/yum.repos.d/*.repo
一个文件通常用于一个或一组功能相近或相关的仓库
定义一个仓库指向:
[REPO_ID] name= baseurl= # mirrorlist=SCHEME://HOSTNAME/PATH/TO/MIRROR_LIST_FILE enabled={1|0} gpgcheck={1|0} gpgkey= cost=
比如创建阿里源和epel源:
[centos] name=Centos aliyun baseurl=http://mirrors.aliyun.com/centos/6/os/x86_64/ enabled=1 gpgcheck=0 [Fedora-epel] name=Fedora-epel baseurl=http://mirrors.aliyun.com/epel/6Server/x86_64/ enabled=1 gpgcheck=0
1.安装类
yum install 安装:yum install wget
[[email protected] Packages]# yum install wget 省略: Running Transaction Installing : wget-1.12-5.el6_6.1.x86_64 1/1 Verifying : wget-1.12-5.el6_6.1.x86_64 1/1 Installed: wget.x86_64 0:1.12-5.el6_6.1 Complete! [[email protected] Packages]#
yum remove 卸载软件包:yum remove wget
[[email protected] Packages]# yum remove wget 省略: Warning: RPMDB altered outside of yum. Erasing : wget-1.12-5.el6_6.1.x86_64 1/1 Verifying : wget-1.12-5.el6_6.1.x86_64 1/1 Removed: wget.x86_64 0:1.12-5.el6_6.1 Complete! [[email protected] Packages]#
2 更新和升级
yum update 全部更新
[[email protected] Packages]# yum update Loaded plugins: fastestmirror Setting up Update Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package ibus-table-cangjie.noarch 0:1.2.0.20100210-1.el6 will be obsoleted ---> Package ibus-table-chinese-cangjie.noarch 0:1.4.6-1.el6 will be obsoleting 省略 . . Complete! [[email protected] Packages]#
yum update 包名 指定软件包更新
[[email protected] Packages]# yum update wget Loaded plugins: fastestmirror Setting up Update Process Loading mirror speeds from cached hostfile No Packages marked for Update [[email protected] Packages]#
yum check-update检查可更新的程序
[[email protected] Packages]# yum check-update
3 查找和显示
yum info 显示包的信息
[[email protected] Packages]# yum info zsh Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Installed Packages Name : zsh Arch : x86_64 Version : 4.3.11 Release : 4.el6.centos Size : 5.0 M Repo : installed Summary : A powerful interactive shell URL : http://zsh.sunsite.dk/ License : BSD Description : The zsh shell is a command interpreter usable as an interactive login : shell and as a shell script command processor. Zsh resembles the ksh : shell (the Korn shell), but includes many enhancements. Zsh supports : command line editing, built-in spelling correction, programmable : command completion, shell functions (with autoloading), a history : mechanism, and more. [[email protected] Packages]#
yum list 显示指定程序包安装情况
[[email protected] Packages]# yum list zsh Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Installed Packages zsh.x86_64 4.3.11-4.el6.centos installed [[email protected] Packages]#
yum serach all 查看所有包的信息
[[email protected] Packages]# yum search all Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile ====================================================================================== N/S Matched: all ======================================================================================= PackageKit-debug-install.x86_64 : Facility to install debugging packages using PackageKit alliance-doc.x86_64 : Alliance VLSI CAD Sytem - Documentations alliance-libs.i686 : Alliance VLSI CAD Sytem - multilibs alliance-libs.x86_64 : Alliance VLSI CAD Sytem - multilibs ctan-kerkis-calligraphic-fonts.noarch : Kerkis Calligraphic Type1 fonts eclipse-callgraph.x86_64 : C/C++ Call Graph Visualization Tool yum.noarch : RPM package installer/updater/manager yum-plugin-auto-update-debug-info.noarch : Yum plugin to enable automatic updates to installed debuginfo packages yum-plugin-fs-snapshot.noarch : Yum plugin to automatically snapshot your filesystems during updates yum-plugin-local.noarch : Yum plugin to automatically manage a local repo. of downloaded packages yum-plugin-merge-conf.noarch : Yum plugin to merge configuration changes when installing packages yum-plugin-show-leaves.noarch : Yum plugin which shows newly installed leaf packages Name and summary matches only, use "search all" for everything. [[email protected] Packages]#
yum search 查看zsh包的详细信息:
[[email protected] Packages]# yum search zsh Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile ====================================================================================== N/S Matched: zsh ======================================================================================= autojump-zsh.noarch : Autojump for zsh docker-io-zsh-completion.x86_64 : zsh completion files for docker gromacs-zsh.noarch : GROMACS zsh support python-twisted-core-zsh.x86_64 : Tab completion for Zsh and Twisted Core zsh-html.x86_64 : Zsh shell manual in html format zsh.x86_64 : A powerful interactive shell zsh-lovers.noarch : A collection of tips, tricks and examples for the Z shell Name and summary matches only, use "search all" for everything. [[email protected] Packages]#
yum repolist 显示系统配置源的情况
[[email protected] ~]# yum repolist all Loaded plugins: aliases, auto-update-debuginfo, changelog, dellsysid, fastestmirror, filter-data, fs-snapshot, keys, list-data, local, merge-conf, post-transaction-actions, presto, : priorities, protectbase, ps, remove-with-leaves, rpm-warm-cache, security, show-leaves, tmprepo, tsflags, upgrade-helper, verify, versionlock Loading mirror speeds from cached hostfile 0 packages excluded due to repository protections repo id repo name status C6.0-base CentOS-6.0 - Base disabled C6.0-centosplus CentOS-6.0 - CentOSPlus disabled C6.0-contrib CentOS-6.0 - Contrib disabled C6.0-extras CentOS-6.0 - Extras disabled C6.0-updates CentOS-6.0 - Updates disabled C6.1-base CentOS-6.1 - Base disabled C6.1-centosplus CentOS-6.1 - CentOSPlus disabled C6.1-contrib CentOS-6.1 - Contrib disabled C6.1-extras CentOS-6.1 - Extras disabled C6.1-updates CentOS-6.1 - Updates disabled C6.2-base CentOS-6.2 - Base disabled C6.2-centosplus CentOS-6.2 - CentOSPlus disabled C6.2-contrib CentOS-6.2 - Contrib disabled C6.2-extras CentOS-6.2 - Extras disabled C6.2-updates CentOS-6.2 - Updates disabled C6.3-base CentOS-6.3 - Base disabled C6.3-centosplus CentOS-6.3 - CentOSPlus disabled C6.3-contrib CentOS-6.3 - Contrib disabled C6.3-extras CentOS-6.3 - Extras disabled C6.3-updates CentOS-6.3 - Updates disabled C6.4-base CentOS-6.4 - Base disabled C6.4-centosplus CentOS-6.4 - CentOSPlus disabled C6.4-contrib CentOS-6.4 - Contrib disabled C6.4-extras CentOS-6.4 - Extras disabled C6.4-updates CentOS-6.4 - Updates disabled C6.5-base CentOS-6.5 - Base disabled C6.5-centosplus CentOS-6.5 - CentOSPlus disabled C6.5-contrib CentOS-6.5 - Contrib disabled C6.5-extras CentOS-6.5 - Extras disabled C6.5-updates CentOS-6.5 - Updates disabled C6.6-base CentOS-6.6 - Base disabled C6.6-centosplus CentOS-6.6 - CentOSPlus disabled C6.6-contrib CentOS-6.6 - Contrib disabled C6.6-extras CentOS-6.6 - Extras disabled C6.6-updates CentOS-6.6 - Updates disabled Fedora-epel Fedora-epel enabled: 11,765 base-debuginfo CentOS-6 - Debuginfo disabled c6-media CentOS-6 - Media disabled centos Centos aliyun enabled: 6,575 fasttrack CentOS-6 - fasttrack disabled repolist: 18,340 [[email protected] ~]#
4.删除程序
yum remove
[[email protected] Packages]# yum remove wget Loaded plugins: fastestmirror Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package wget.x86_64 0:1.12-5.el6_6.1 will be erased --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================================== Removing: wget x86_64 1.12-5.el6_6.1 @centos 1.8 M Transaction Summary =============================================================================================================================================================================================== Remove 1 Package(s) Installed size: 1.8 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : wget-1.12-5.el6_6.1.x86_64 1/1 Verifying : wget-1.12-5.el6_6.1.x86_64 1/1 Removed: wget.x86_64 0:1.12-5.el6_6.1 Complete!
yum deplist 查看程序依赖情况
5.清除缓存
yum clean all 清除缓存目录下的软件包
[[email protected] Packages]# yum clean all Loaded plugins: fastestmirror Cleaning repos: Fedora-epel centos Cleaning up Everything Cleaning up list of fastest mirrors [[email protected] Packages]#
yum makecache 建立缓存
[[email protected] Packages]# yum makecache
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Fedora-epel | 4.3 kB 00:00 centos | 3.7 kB 00:00 Metadata Cache Created [[email protected] Packages]#
6.包组管理
yum grouplist 列出所有的包组
[[email protected] Packages]# yum grouplist Loaded plugins: fastestmirror Setting up Group Process Loading mirror speeds from cached hostfile Installed Groups: Additional Development Development tools E-mail server Fonts General Purpose Desktop Graphical Administration Tools Input Methods Legacy X Window System compatibility Milkymist Networking Tools Perl Support Security Tools Installed Language Groups: Chinese Support [zh] Available Groups: 省略 . . Upper Sorbian Support [hsb] Urdu Support [ur] Uzbek Support [uz] Venda Support [ve] Vietnamese Support [vi] Walloon Support [wa] Welsh Support [cy] Xhosa Support [xh] Zulu Support [zu] Done [[email protected] Packages]#
yum groupinfo 显示包组内具体信息
[[email protected] Packages]# yum groupinfo "Development tools" Loaded plugins: fastestmirror Setting up Group Process Loading mirror speeds from cached hostfile Group: Development tools Description: A basic development environment. Mandatory Packages: autoconf automake binutils bison flex gcc gcc-c++ gettext libtool make patch pkgconfig redhat-rpm-config rpm-build Default Packages: trac-git-plugin trac-mercurial-plugin trac-webadmin translate-toolkit [[email protected] Packages]#
yum groupinstall 安装包组
[[email protected] Packages]# yum groupinstall ‘Development tools‘ Loaded plugins: fastestmirror Setting up Group Process Loading mirror speeds from cached hostfile Package flex-2.5.35-9.el6.x86_64 already installed and latest version Package gcc-4.4.7-16.el6.x86_64 already installed and latest version Package autoconf-2.63-5.1.el6.noarch already installed and latest version Package redhat-rpm-config-9.0.3-44.el6.centos.noarch already installed and latest version Package rpm-build-4.8.0-47.el6.x86_64 already installed and latest version Package git-1.7.1-3.el6_4.1.x86_64 already installed and latest version Package cscope-15.6-6.el6.x86_64 already installed and latest version Package swig-1.3.40-6.el6.x86_64 already installed and latest version Warning: Group development does not have any packages. No packages in any requested group available to install or update [[email protected] Packages]#
yum groupremove 卸载包组
[[email protected] Packages]# yum groupremove "Development tools" Loaded plugins: fastestmirror Setting up Group Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package autoconf.noarch 0:2.63-5.1.el6 will be erased ---> Package automake.noarch 0:1.11.1-4.el6 will be erased ---> Package binutils.x86_64 0:2.20.51.0.2-5.43.el6 will be erased --> Processing Dependency: binutils for package: module-init-tools-3.9-25.el6.x86_64 ---> Package bison.x86_64 0:2.4.1-5.el6 will be erased ---> Package byacc.x86_64 0:1.9.20070509-7.el6 will be erased 省略 . . ---> Package libselinux-devel.x86_64 0:2.0.94-5.8.el6 will be erased ---> Package libsepol-devel.x86_64 0:2.0.41-4.el6 will be erased ---> Package pcre-devel.x86_64 0:7.8-7.el6 will be erased ---> Package rsyslog.x86_64 0:5.8.10-10.el6_6 will be erased ---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be erased --> Processing Dependency: /sbin/new-kernel-pkg for package: kernel-2.6.32-573.el6.x86_64 Skipping the running kernel: kernel-2.6.32-573.el6.x86_64 --> Restarting Dependency Resolution with new changes. --> Running transaction check --> Finished Dependency Resolution Error: Trying to remove "yum", which is protected [[email protected] Packages]#