????yum,Yellowdog Update Modifier是redhat系列發行版的一個前端包管理器,可以有效的解決包依賴關系,然而其底層調用的是rpm這個后端程序 RPM ????包管理器? ????????程序包管理器:? ?????????????功能:將編譯好的應用程序的各組成文件打包一個或幾個程序包文件,從而方便快捷地實現程序包的安裝、卸載、查詢、升級和校驗等管理操作 ????????包文件組成 (每個包獨有)? ?????????????RPM包內的文件? ?????????????RPM的元數據,如名稱,版本,依賴性,描述等? ?????????????安裝或卸載時運行的腳本? ? ??????數據庫(公共):/var/lib/rpm? ?????????????程序包名稱及版本? ?????????????依賴關系? ?????????????功能說明? ?????????????包安裝后生成的各文件路徑及校驗碼信息???? [root@centos6 ~]# ll /var/lib/rpm total 77796 -rw-r--r--. 1 root root? 5521408 Apr 20 09:46 Basenames -rw-r--r--. 1 root root??? 12288 Apr 10 16:05 Conflictname -rw-r--r--? 1 root root??? 73728 Apr 20 09:59 __db.001 -rw-r--r--? 1 root root?? 237568 Apr 20 09:59 __db.002 -rw-r--r--? 1 root root? 1318912 Apr 20 09:59 __db.003 -rw-r--r--? 1 root root?? 753664 Apr 20 09:59 __db.004 -rw-r--r--. 1 root root? 1552384 Apr 20 09:46 Dirnames -rw-r--r--. 1 root root 10555392 Apr 20 09:46 Filedigests -rw-r--r--. 1 root root??? 20480 Apr 20 09:46 Group -rw-r--r--. 1 root root??? 20480 Apr 20 09:46 Installtid -rw-r--r--. 1 root root??? 86016 Apr 20 09:46 Name -rw-r--r--. 1 root root??? 24576 Apr 17 16:08 Obsoletename -rw-r--r--. 1 root root 60223488 Apr 20 09:46 Packages -rw-r--r--. 1 root root? 1327104 Apr 20 09:46 Providename -rw-r--r--. 1 root root?? 700416 Apr 20 09:46 Provideversion -rw-r--r--. 1 root root??? 12288 Mar 27 17:00 Pubkeys -rw-r--r--. 1 root root?? 516096 Apr 20 09:46 Requirename -rw-r--r--. 1 root root?? 303104 Apr 20 09:46 Requireversion -rw-r--r--. 1 root root?? 172032 Apr 20 09:46 Sha1header -rw-r--r--. 1 root root??? 86016 Apr 20 09:46 Sigmd5 -rw-r--r--. 1 root root??? 12288 Mar 27 17:10 Triggername ????程序包的來源? ????????管理程序包的方式:? ?????????????使用包管理器:rpm? ?????????????使用前端工具:yum ????????獲取程序包的途徑:? ?????????????(1) 系統發版的光盤或官方的服務器;? ? ????????????????CentOS鏡像:? ? ????????????????????https://www.centos.org/download/? ? ????????????????????http://mirrors.aliyun.com? ?????????????????? ? ?http://mirrors.sohu.com? ? ????????????????????http://mirrors.163.com? ?????????????(2) 項目官方站點? ????????? ? ?(3) 第三方組織:? ?????????????????Fedora-EPEL:? ????????????????????????Extra Packages for Enterprise Linux? ?????????????????Rpmforge:RHEL推薦,包很全? ?????????????????????????搜索引擎:? ????????????????????????????? http://pkgs.org? ? ?????????????????????? ??? ?http://rpmfind.net? ? ????????????????????????????http://rpm.pbone.net? ? ????????????????????????????https://sourceforge.net/? ????????? ? ?(4) 自己制作? ????????????????????注意:第三方包建議要檢查其合法性?來源合法性,程序包的完整性? ?? ????rpm包管理? ????????CentOS系統上使用rpm命令管理程序包:? ????????????安裝、卸載、升級、查詢、校驗、數據庫維護? ?????????安裝:? ????????????rpm {-i|--install} [install-options] PACKAGE_FILE…?? ?????????????????-v: verbose? ?????????????????-vv:?? ?????????????????-h: 以#顯示程序包管理執行進度? ?????????????常用搭配:rpm -ivh PACKAGE_FILE ...? [root@centos6 Packages]# rpm -ivh finger-0.17-40.el6.x86_64.rpm warning: finger-0.17-40.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing...??????????????? ########################################### [100%] ?? 1:finger???????????????? ########################################### [100%] ?注:rpm后面只能跟文件名,而不能跟finger包名,其不能識別finger整個文件名? ????rpm包安裝????? ????????[install-options]? ?????????????--test: 測試安裝,但不真正執行安裝,即dry run模式? ?????????????--nodeps:忽略依賴關系? ?????????????--replacepkgs | replacefiles? ?????????????--nosignature: 不檢查來源合法性? ?????????????--nodigest:不檢查包完整性? ?????????????--noscripts:不執行程序包腳本? ?????????? ? %pre: 安裝前腳本;? ? --nopre? ?????????????%post: 安裝后腳本;? ?--nopost? ? ???????????%preun: 卸載前腳本; --nopreun? ? ???????????%postun: 卸載后腳本;--nopostun? [root@centos6 Packages]# rpm -ivh --test kernel-2.6.32-696.el6.x86_64.rpm warning: kernel-2.6.32-696.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing...??????????????? ########################################### [100%] ???????? package kernel-3.18.12-11.el6.x86_64 (which is newer than kernel-2.6.32-696.el6.x86_64) is already installed ???????? package kernel-2.6.32-696.el6.x86_64 is already installed ?????rpm包升級??? ????????升級:? ? ? ? ?? ? ???rpm {-U|--upgrade} [install-options] PACKAGE_FILE...? ????????????rpm {-F|--freshen} [install-options] PACKAGE_FILE...? ?????????????????upgrade:安裝有舊版程序包,則“升級” ,如果不存在舊版程序包,則“安裝”? ?????????????????freshen:安裝有舊版程序包,則“升級” ,如果不存在舊版程序包,則不執行升級操作? ????????????? ? ????常用搭配: ????????????????????? ? ?rpm -Uvh PACKAGE_FILE ...? ?????????????????????????rpm -Fvh PACKAGE_FILE ...? ?????????????--oldpackage:降級? ?????????????--force: 強制安裝?? ????????升級注意項? ????????????注意:? ????????????????(1) 不要對內核做升級操作;Linux支持多內核版本并存,因此,對直接安裝新版本內核? ????????????????(2) 如果原程序包的配置文件安裝后曾被修改,升級時,新版本的提供的同一個配置文件并不會直接覆蓋老版本的配置文件,而把新版本的文件重命名(FILENAME.rpmnew)后保留 ? ??rpm包查詢 ????????????rpm {-q|--query} [select-options] [query-options]? ????????????????[select-options]? ?????????????????????-a: 所有包? ?????????????????????-f: 查看指定的文件由哪個程序包安裝生成? ?????????????????????-p rpmfile:針對尚未安裝的程序包文件做查詢操作? ?????????????????????--whatprovides CAPABILITY:查詢指定的CAPABILITY由哪個包所提供? ?????????????????????--whatrequires CAPABILITY:查詢指定的CAPABILITY被哪個包所依賴? ????????????????rpm2cpio 包文件|cpio –itv? 預覽包內文件? ????????????????rpm2cpio 包文件|cpio –id? “*.conf” 釋放包內文件?? ? ??????????????[query-options]? ?????????????????????--changelog:查詢rpm包的changelog? ?????????????????????-c: 查詢程序的配置文件? ?????????????????????-d: 查詢程序的文檔? ?????????????????????-i: information? ?????????????????????-l: 查看指定的程序包安裝后生成的所有文件? ?????????????????????--scripts:程序包自帶的腳本? ?????????????????????--provides: 列出指定程序包所提供的CAPABILITY? ?????????????????????-R: 查詢指定的程序包所依賴的CAPABILITY? ????????????????常用查詢用法:? ?????????????????????-qi PACKAGE, -qf FILE, -qc PACKAGE, -ql PACKAGE, -qd PACKAGE?-qpi PACKAGE_FILE, -qpl PACKAGE_FILE, ...?-qa? ?查看已安裝包信息 [root@centos6 ~]# rpm -qi bash Name??????? : bash???????????????????????? Relocations: (not relocatable) Version???? : 4.1.2???????????????????????????? Vendor: CentOS Release???? : 48.el6??????????????????????? Build Date: Thu 23 Mar 2017 08:17:20 AM CST Install Date: Tue 27 Mar 2018 05:00:50 PM CST????? Build Host: c1bm.rdu2.centos.org Group?????? : System Environment/Shells???? Source RPM: bash-4.1.2-48.el6.src.rpm Size??????? : 3142529????????????????????????? License: GPLv3+ Signature?? : RSA/SHA1, Thu 23 Mar 2017 10:59:39 PM CST, Key ID 0946fca2c105b9de Packager??? : CentOS BuildSystem <http://bugs.centos.org> URL??? ?????: http://www.gnu.org/software/bash Summary???? : The GNU Bourne Again shell Description : The GNU Bourne Again shell (Bash) is a shell or command language interpreter that is compatible with the Bourne shell (sh). Bash incorporates useful features from the Korn shell (ksh) and the C shell (csh). Most sh scripts can be run by bash without modification. 查詢生成的文件是由那個包提供 [root@centos6 ~]# rpm -qf /bin/ls coreutils-8.4-46.el6.x86_64 查看包生成的配置文件 [root@centos6 ~]# rpm -qc bash /etc/skel/.bash_logout /etc/skel/.bash_profile /etc/skel/.bashrc 查看包生成的所有文件 [root@centos6 ~]# rpm -ql finger /usr/bin/finger /usr/share/man/man1/finger.1.gz 查看問安裝包信息,后必須跟文件名 [root@centos6 Packages]# rpm -ivh finger-0.17-40.el6.x86_64.rpm warning: finger-0.17-40.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Preparing...??????????????? ########################################### [100%] ?? 1:finger???????????????? ########################################### [100%] [root@centos6 Packages]# rpm -qpi tree-1.5.3-3.el6.x86_64.rpm warning: tree-1.5.3-3.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY Name??????? : tree???????????????????????? Relocations: (not relocatable) Version???? : 1.5.3????????????? ???????????????Vendor: CentOS Release???? : 3.el6???????????????????????? Build Date: Wed 14 Jan 2015 08:21:02 PM CST Install Date: (not installed)?????????????? Build Host: c6b9.bsys.dev.centos.org Group?????? : Applications/File???????????? Source RPM: tree-1.5.3-3.el6.src.rpm Size??????? : 66687??????????????????????????? License: GPLv2+ Signature?? : RSA/SHA1, Wed 14 Jan 2015 10:12:21 PM CST, Key ID 0946fca2c105b9de Packager??? : CentOS BuildSystem <http://bugs.centos.org> URL???????? : http://mama.indstate.edu/users/ice/tree/ Summary???? : File system tree viewer Description : The tree utility recursively displays the contents of directories in a tree-like format.? Tree is basically a UNIX port of the DOS tree utility. ? ??包卸載:? ?????????rpm {-e|--erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers]?[--test] PACKAGE_NAME ...? ? ? 包校驗? ????????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? 已安裝包來源合法性驗正及完整性驗正 [root@centos6 Packages]# cat >> /usr/bin/zip [root@centos6 Packages]# rpm -V zip prelink: /usr/bin/zip: prelinked file size differs S.?....T.??? /usr/bin/zip ?????????????完整性驗正:SHA256? ?????????????來源合法性驗正:RSA? ?????????公鑰加密? ?????????????對稱加密:加密、解密使用同一密鑰? ?????????????非對稱加密:密鑰是成對兒的? ? ????????????????public key: 公鑰,公開所有人? ????????????????? secret key: 私鑰, 不能公開? ??????????????導入所需要公鑰? ?????????????????rpm? -K|checksig? rpmfile? 檢查包的完整性和簽名? ?????????????????rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7? ?????CentOS 7發行版光盤提供:RPM-GPG-KEY-CentOS-7? ?????????rpm -qa “gpg-pubkey*”?? 導入公鑰,檢查包完整性 [root@centos6 date]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 [root@centos6 date]# rpm -K /misc/cd/Packages/tree-1.5.3-3.el6.x86_64.rpm /misc/cd/Packages/tree-1.5.3-3.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK ????rpm數據庫? ???????????數據庫重建:??/var/lib/rpm? ????????????rpm {--initdb|--rebuilddb}? ?????????????????initdb: 初始化 ,如果事先不存在數據庫,則新建之?否則,不執行任何操作? ?????????????????rebuilddb:重建已安裝的包頭的數據庫索引目錄
本文來自投稿,不代表Linux運維部落立場,如若轉載,請注明出處:http://www.www58058.com/96602