rpm,Redhat Package Manager,即爲紅帽公司爲RHEL開發的專用包管理器,後來更改成RPM Package Manager,相似於GNU項目,使用遞歸命名,GNU's Not Unix.java
-v 顯示附加信息 -vv 顯示調試信息 --root 讓RPM將指定的路徑作爲"根目錄",這樣預安裝程序和後安 裝程序都會安裝到這個目錄下 --dbpath 設置RPM 資料庫存所在的路徑爲
1.查詢指定的包是否安裝,好比treenode
[root@localhost tmp]#rpm -q tree tree-1.5.3-3.el6.x86_64 #PKG爲包全名 rpm -q PKG
2.查詢指定文件來自於那個安裝包,以/bin/ls文件爲例c++
[root@localhost Packages]#rpm -qf /bin/ls coreutils-8.4-43.el6.x86_64 rpm -qf /PATH/TO/FILE
3.查詢包更新信息shell
[root@localhost Packages]#rpm -q --changelog tree * Thu Nov 27 2014 Tim Waugh <twaugh@redhat.com> - 1.5.3-3 - Handle large UID/GID values (bug #1110559). * Wed Mar 03 2010 Tim Waugh <twaugh@redhat.com> 1.5.3-2 - Added comments to all patches. ... rpm -q --changelog PKG
4.查詢包元數據centos
[root@localhost Packages]#rpm -qi tree 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: Sat 25 Mar 2017 04:17:05 AM CST Build Host: c6b9.bsys.dev.centos.org Group : Applications/File Source RPM: tree-1.5.3-3.el6.src.rpm ... rpm -qi PKG
5.查詢包生成的全部文件ruby
[root@localhost Packages]#rpm -ql tree /usr/bin/tree /usr/share/doc/tree-1.5.3 /usr/share/doc/tree-1.5.3/LICENSE /usr/share/doc/tree-1.5.3/README /usr/share/man/man1/tree.1.gz rpm -ql PKG
6.查詢包相關文檔bash
[root@localhost Packages]#rpm -qd tree /usr/share/doc/tree-1.5.3/LICENSE /usr/share/doc/tree-1.5.3/README /usr/share/man/man1/tree.1.gz rpm -qd PKG
7.查詢包配置文件post
[root@localhost Packages]#rpm -qc bash /etc/skel/.bash_logout /etc/skel/.bash_profile /etc/skel/.bashrc rpm -qc PKG
8.查詢安裝、卸載先後執行的腳本測試
[root@localhost Packages]#rpm -q --scripts bash postinstall scriptlet (using <lua>): bashfound = false; shfound = false; f = io.open("/etc/shells", "r"); if f == nil then ... #有四個時間點能夠執行腳本程序:包安裝前、安裝後、卸載前以及卸載後
1.安裝rpm程序包,在安裝過程,後面的PKG必須是文件路徑ui
[root@localhost Packages]#rpm -ivh gcc- ## 按兩次tab鍵 gcc-4.4.7-17.el6.x86_64.rpm gcc-java-4.4.7-17.el6.x86_64.rpm gcc-c++-4.4.7-17.el6.x86_64.rpm gcc-objc-4.4.7-17.el6.x86_64.rpm gcc-gfortran-4.4.7-17.el6.x86_64.rpm gcc-objc++-4.4.7-17.el6.x86_64.rpm gcc-gnat-4.4.7-17.el6.x86_64.rpm #安裝 [root@localhost Packages]#rpm -ivh gcc-4.4.7-17.el6.x86_64.rpm #/PATH/TO/PKG爲rpm包的路徑 rpm -ivh /PATH/TO/PKG
2.在安裝過程不執行腳本
[root@localhost Packages]#rpm -ivh --noscripts 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 Preparing... ########################################### [100%] 1:tree ########################################### [100%] rpm -ivh --noscripts PKG
3.覆蓋、替換安裝
[root@localhost Packages]#rpm -ivh --replacepkgs 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 Preparing... ########################################### [100%] 1:tree ########################################### [100%] rpm -ivh --replacepkgs PKG
在安裝過程可能出現以來錯誤,如A包依賴於B包,那麼在A包安裝以前,須要先安裝好B包
4.詳細選項
選項 | 含義 |
---|---|
-h | 安裝時以#顯示安裝進度 |
--percent | 以百分比的形式輸出安裝的進度 |
--test | 測試安裝 |
--replacepkgs | 替換屬於其它軟件包的文件 |
--force | 忽略軟件包及文件的衝突 |
--noscripts | 不運行預安裝和後安裝腳本 |
--ignorearch | 不校驗軟件包的結構 |
--ignoreos | 不檢查軟件包運行的操做系統 |
--nodeps | 不檢查依賴性關係 |
1.通常卸載
[root@localhost Packages]#rpm -e gcc rpm -e PKG
2.不執行腳本卸載
[root@localhost Packages]#rpm -e --noscripts tree rpm -e --noscripts PKG
[root@localhost Packages]#rpm -Uvh tree-1.5.3-3.el6.x86_64.rpm rpm -Uvh PKG 或 rpm -Fvh PKG
-U和-F選項都可以升級一個包.可是,舊包不存在時,-U選項會安裝新包,而-F選項不安裝新包。