INSTALLING, UPGRADING, AND REMOVING PACKAGES: rpm {-i|--install} [install-options] PACKAGE_FILE ... rpm {-U|--upgrade} [install-options] PACKAGE_FILE ... rpm {-F|--freshen} [install-options] PACKAGE_FILE ... rpm {-e|--erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--repackage] [--test] PACKAGE_NAME ... QUERYING AND VERIFYING PACKAGES: rpm {-q|--query} [select-options] [query-options] rpm {-V|--verify} [select-options] [verify-options] rpm --import PUBKEY ... rpm {-K|--checksig} [--nosignature] [--nodigest] PACKAGE_FILE ...
-?, --help :列出輔助訊息 --version :列出 rpm 版本 --quiet :僅列出錯誤訊息 -v :察看更細部的安裝資訊 -vv :列出大量除錯訊息 --pipe CMD :將 rpm 的輸出以管線處理送到命令 CMD
rpm {-i|--install} [install-options] PACKAGE_FILE ... install-options: -h :以安裝資訊列顯示安裝進度 --nodeps:不要去檢查 rpm 套件的相依性。 --nomd5:不要檢查 rpm 套件的 MD5 資訊。 --noscripts:不想讓該套件自行啟用或者自行執行某些系統指令。 --replacefiles:直接覆蓋已存在的檔案。 --replacepkgs:重新安裝某個已經安裝過的套件。 --force:--replacefiles 與 --replacepkgs 。 --test:測試套件是否可以被安裝到使用者的 Linux 環境當中。 --prefix NEWPATH:安裝到新目錄 NEWPATH
[root@linux ~]# rpm -ivh rp-pppoe-3.1-5.i386.rpm Preparing... ####################################### [100%] 1:rp-pppoe ####################################### [100%]
[root@linux ~]# rpm -ivh a.i386.rpm b.i386.rpm *.rpm # 後面直接接上許多的套件檔案。
[root@dywHome2 ~]# rpm -ivh http://ftp.isu.edu.tw/pub/Linux/Mandriva\ >/official/2007.0/i586/media/main/release/logrotate-3.7.3-4mdk.i586.rpm
[root@dywHome2 ~]# rpm -ivh FlashPlayer-9.0.21.78-1.mdv2007.0.mde.i586.rpm --test Preparing... ########################################### [100%]
rpm {-U|--upgrade} [install-options] PACKAGE_FILE ... rpm {-F|--freshen} [install-options] PACKAGE_FILE ... install-options: 與安裝相同
[root@dywOffice rpm]# rpm -Uvh baghira-0.7-2.2006mcnl.i586.rpm Preparing... ########################################### [100%] 1:baghira ########################################### [100%]
[root@dywOffice rpm]# rpm -Fvh baghira-0.7-2.2006mcnl.i586.rpm [root@dywOffice rpm]# rpm -Fvh baghira-0.7-0arn.20060mdk.i586.rpm
[root@dywOffice rpm]# rpm -Fvh baghira-0.7-7arn.cvs20051211.20060mdk.i586.rpm Preparing... ########################################### [100%] 1:baghira ########################################### [100%]
rpm {-e|--erase} [--allmatches] [--nodeps] [--test] PACKAGE_NAME ... --nodeps:不要去檢查 rpm 套件的相依性。 --test:只是測試,不是真的移除套件。常與一般選項 -vv 一起使用來除錯
[root@dywHome2 rpm]# rpm -e mplayer --test error: Failed dependencies: mplayer is needed by (installed) kplayer-0.5.3-5mdv2007.0.i586
[root@dywHome2 rpm]# rpm -e mplayer --test --nodeps
[root@dywHome2 rpm]# rpm -e baghira
[root@linux ~]# rpm -qa [root@linux ~]# rpm -q[licdR] 已安裝的套件名稱 [root@linux ~]# rpm -qf 存在於系統上面的某個檔案 -q :僅查詢,後面接的套件名稱是否有安裝; -qa :列出所有已經安裝在本機 Linux 系統上面的套件名稱; -qi :列出該套件的詳細資訊 (information),包含開發商、版本與說明等; -ql :列出該套件所有的檔案與目錄所在完整檔名 (list); -qc :列出該套件的所有設定檔 (僅找出在 /etc/ 底下的檔名) -qd :列出該套件的所有說明檔 (僅找出與 man 有關的檔案) -qR :列出與該套件有關的相依套件所含的檔案 (Required ) -qf :由後面接的檔案名稱,找出該檔案屬於哪一個已安裝的套件;
[root@linux ~]# rpm -qp[licdR] 未安裝的某個檔案名稱 -qp[icdlR]:後面接的所有參數以上面的說明一致。
[root@linux ~]# rpm -q logrotate # 不必加上版本。 logrotate-3.7.1-10 [root@linux ~]# rpm -q logrotating package logrotating is not installed
[root@linux ~]# rpm -ql logrotate /etc/cron.daily/logrotate /etc/logrotate.conf ......以下省略......
[root@linux ~]# rpm -qi logrotate Name : logrotate Relocations: (not relocatable) Version : 3.7.1 Vendor: Red Hat, Inc. Release : 10 Build Date: Fri Apr 1 03:54:42 2005 Install Date: Sat Jun 25 08:28:26 2005 Build Host: tweety.build.redhat.com Group : 系統環境/基礎 Source RPM: logrotate-3.7.1-10.src.rpm Size : 47825 License: GPL Signature : DSA/SHA1, Sat May 21 01:34:11 2005, Key ID b44269d04f2a6fd2 Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> Summary : 循環、壓縮、移除以及郵寄系統紀錄檔案。 Description : The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files. Logrotate allows for the automatic rotation, compression, removal, and mailing of log files. Logrotate can be set to handle a log file daily, weekly, monthly, or when the log file gets to a certain size. Normally, logrotate runs as a daily cron job.
[root@dywHome2 ~]# rpm -qc mplayer /etc/mplayer/codecs.conf /etc/mplayer/input.conf /etc/mplayer/menu.conf /etc/mplayer/mplayer.conf
[root@dywHome2 ~]# rpm -qd mplayer /usr/share/doc/mplayer-1.0/AUTHORS /usr/share/doc/mplayer-1.0/ChangeLog /usr/share/doc/mplayer-1.0/Copyright /usr/share/doc/mplayer-1.0/HTML/cs/advaudio.html /usr/share/doc/mplayer-1.0/HTML/cs/aspect.html /usr/share/doc/mplayer-1.0/HTML/cs/audio-codecs.html /usr/share/doc/mplayer-1.0/HTML/cs/audio-formats.html ----以下省略----
[root@linux ~]# rpm -qR logrotate /bin/sh config(logrotate) = 3.7.1-10 libc.so.6 ----以下省略----
[root@linux ~]# rpm -qf /bin/sh bash-3.0-31 # 參數後面接的是『檔案』,不是接套件。
[root@dywHome2 rpm]# rpm -qpR kplayer-0.5.3-5mdv2007.0.i586.rpm mplayer kdelibs-common /bin/sh /bin/sh rpmlib(PayloadFilesHavePrefix) %*<== 4.0-1*) rpmlib(CompressedFileNames) %*<== 3.0.4-1*) libDCOP.so.4 libICE.so.6 ----以下省略----
[root@dywHome2 ~]# rpm -qc logrotate /etc/logrotate.conf /etc/logrotate.d/syslog
[root@dywHome2 ~]# rpm -ivh http://ftp.isu.edu.tw/pub/Linux/Mandriva\ >/official/2007.0/i586/media/main/release/logrotate-3.7.3-4mdk.i586.rpm\ > --replacepkgs
# 雖然檔案 /etc/crontab 已不存在,但 /var/lib/rpm 資料庫中有記錄: [root@dywHome2 ~]# rpm -qf /etc/crontab crontabs-1.10-6mdk
[root@dywHome2 rpm]# rpm -qa | grep player mplayer-1.0-1.pre8.13.2mdv2007.0 kplayer-0.5.3-5mdv2007.0
[root@dywHome2 rpm]# rpm -qa | grep ^c | wc -l 15
[root@linux ~]# rpm -Va [root@linux ~]# rpm -V 已安裝的套件名稱 [root@linux ~]# rpm -Vp 某 rpm 套件名稱 [root@linux ~]# rpm -Vf 在系統上面的某個檔案 選項: -V :後接套件名稱,若該套件所含的檔案被更動過,才會列出來; -Va :列出目前系統上面所有可能被更動過的檔案; -Vp :後接套件名稱,列出該套件內可能被更動過的檔案; -Vf :列出某個檔案是否被更動過。
[root@dywHome2 rpm]# rpm -V logrotate .M...... d /usr/share/man/man8/logrotate.8.bz2
[root@dywHome2 rpm]# rpm -Vf /etc/crontab .......T c /etc/crontab
[root@dywHome2 rpm]# rpm -Vp kplayer-0.5.3-5mdv2007.0.i586.rpm S.5....T /usr/bin/kplayer
S :file Size differs 檔案的容量大小被改變 M :Mode differs (includes permissions and file type) 檔案的類型或檔案的屬性(讀/寫/執行)已被改變 5 :MD5 sum differs MD5 加密防駭的屬性已被改變 D :Device major/minor number mis-match 裝置名稱已被改變 L :readLink(2) path mis-match Link 屬性已被改變 U :User ownership differs 檔案的所屬人已被改變 G :Group ownership differs 檔案的所屬群組已被改變 T :mTime differs 檔案的建立時間已被改變 #當檔案所有的資訊都被更動過會顯: SM5DLUGT c filename
c :設定檔(config file) d :文件資料檔(documentation) g :鬼檔案~通常是該檔案不被某個套件所包含,較少發生。(ghost file) l :授權檔案(license file) r :讀我檔案(read me)
[root@dywHome2 ~]# rpm -ivh http://ftp.isu.edu.tw/pub/Linux/Mandriva\ >/official/2007.0/i586/media/main/release/gnupg-1.4.5-1mdv2007.0
[root@dywHome2 ~]# find /etc /usr -name RPM-GPG-KEY* /etc/RPM-GPG-KEYS /usr/share/doc/rpm-4.4.6/RPM-GPG-KEY
[root@dywHome2 ~]# rpm --import /usr/share/doc/rpm-4.4.6/RPM-GPG-KEY
[root@dywHome2 ~]# rpm -qa gpg-pubkey* gpg-pubkey-78d019f5-3fd7504d gpg-pubkey-db42a60e-37ea5438 gpg-pubkey-22458a98-3969e7de gpg-pubkey-70771ff3-3c8f768f
[root@dywHome2 ~]# rpm -qi gpg-pubkey-78d019f5-3fd7504d Name : gpg-pubkey Relocations: (not relocatable) Version : 78d019f5 Vendor: (none) Release : 3fd7504d Build Date: Fri 28 Dec 2007 08:15:11 AM EST Install Date: Fri 28 Dec 2007 08:15:11 AM EST Build Host: localhost Group : Public Keys Source RPM: (none) Size : 0 License: pubkey Signature : (none) Summary : gpg(MandrakeContrib <cooker@linux-mandrake.com>) Description : -----BEGIN PGP PUBLIC KEY BLOCK----- Version: rpm-4.4.6 (beecrypt-4.1.2) mQGiBD/XUE0RBAC/sGlzkZ7WofaPgL2A7Vmi4aMLF9xNkIUzeekk2kxnZ+3P277i2wckvIox gGl13OvqWUf6+20jBPWrOGz6hs+MUve7k+A7sgmg3n2P6fa999nxWTK+7m7705x+2qXb+dxF ----中間省略---- 41trJiEWiEkEGBECAAkFAj/XUE4CGwwACgkQRFk1+HjQGfWi6wCeJPiCFBej0nfnBfaOWh98 aNq3XfUAoKIfvhoiijsRwjSNmygJtZbiKOWC =yJ39 -----END PGP PUBLIC KEY BLOCK-----
[root@dywHome2 rpm]# rpm -ivh baghira-0.8-1.fc6.i386.rpm warning: baghira-0.8-1.fc6.i386.rpm: Header V3 DSA signature: NOKEY, key ID ff6382fa error: Failed dependencies: rtld(GNU_HASH) is needed by baghira-0.8-1.fc6.i386
[root@dywHome2 ~]# rpm -e gpg-pubkey-78d019f5-3fd7504d
[root@dywHome2 ~]# rpm -qa gpg-pubkey* gpg-pubkey-db42a60e-37ea5438 gpg-pubkey-22458a98-3969e7de gpg-pubkey-70771ff3-3c8f768f
rpm {--initdb|--rebuilddb} [-v] --initdb :產生一個新的資料庫 --rebuilddb :重已安裝套件標頭 (headers)重建資料庫
[root@dywHome2 ~]# rpm --initdb -v
[root@dywHome2 ~]# rpm --rebuilddb -v
練習題
grep ^c
| wc -l