1. rpm package manager
rpm is a powerful package management tool that can be used to build, install, query, verify, update and uninstall packages.
usage:
rpm [OPTION...]
Example rpm -ivh + package name
Configuration file:
/var/lib/rpm/ Metadata of installed rpm packages
Options:
- -i: install
- --test: test installation
- --nodeps: ignore dependencies
- --replacepkgs | replacefiles 重装
- --nosignature: do not check source validity
- --nodigest: do not check package integrity
- --noscript: do not execute package scripts
- --nopre: do not execute preinstall scripts
- --nopost: do not execute post-install scripts
- --nopreun: do not execute pre-uninstall scripts
- --nopostun: do not execute post-uninstall scripts
- -v|-vv: show the process
- -h: show progress bar
- --force: force
- -e: uninstall
- --allmatches: uninstall all versions of the package
- -U: upgrade install
- -F: upgrade
- --oldpackage: downgrade
- -q: query
- -a: show all packages
- -f: which package generated the query file
- -p: query filenames that are not installed
- -c: only look at the configuration file
- -d: show documentation
- -i: package description information
- -l: see what files are provided by the package
- --scripts: Query package script information
- -R: The "capabilities" that the query package depends on
- --whatprovides CAPABILITY: Query which package provides the specified "capability"
- --whatrequires CAPABILITY: Query which package depends on the specified "capability"
- --changelog: Query the change log of the rpm package
- --provides: List the "capabilities" provided by the package
- -V: Check whether the package attributes have changed, the following is the changed information
- 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
- -K: Check package signature and integrity
- --import /etc/pki/rpm-gpg/KEY import public key
- --root=/path/ install to the specified "/"
- --initdb: initialize the rpm database
- --rebuilddb: rebuild the rpm database
Related commands:
ldconfig -p View all libraries in the system rpm2cpio FILE.rpm |cpio -tv Preview the files in the package rpm2cpio FILE.rpm |cpio -idv /path/file Unzip the specified file in the rpm package
ldconfig -p View all libraries in the system
rpm2cpio FILE.rpm |cpio -tv Preview the files in the package
rpm2cpio FILE.rpm |cpio -idv /path/file Unzip the specified file in the rpm package
2. yum package management
yum is a file that stores many rpm packages and related metadata files
Variables available in yum's repo configuration file:
$releasever: the major version number of the current OS release
$arch: platform, i386, i486, i586, x86_64, etc.
$basearch: base platform; i386, x86_64
$YUM0-$YUM9: custom variable
yum usage
yum [options] [command] [package ...]
Display the repository list:
yum repolist [all|enabled|disabled]
Display the package:
yum list
yum list [all | glob_exp1] [glob_exp2] [.. .]
yum list {available|installed|updates} [glob_exp1] [...]
Install packages:
yum install package1 [package2] [...]
yum reinstall package1 [package2] [...] (reinstall)
Upgrade packages:
yum update [package1] [package2] [...]
yum downgrade package1 [package2] [...] (downgrade) Check
for available upgrades:
yum check-update
Uninstall packages:
yum remove | erase package1 [package2] [...]
View package information:
yum info [...]
View which package provides a specified feature (which can be a file):
yum provides | whatprovides feature1 [feature2] [...] Clear
local cache:
clear /var/cache/yum/$basearch/$releasever cache
yum clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]
Build cache:
yum makecache
search
yum search string1 [string2] [...] 例如:yum search *app*
Configuration file:
/etc/yum.conf configuration file
- cachedir cache directory
- keepcache=0|1 Whether to keep cached rpm packages during installation
- logfile log file
- gpgcheck=0|1 Check signature and integrity
/var/log/yum.log log
/etc/yum.repos.d/FILE.repo yum source file
[base] name=base #description information baseurl=http|ftp|file #yum warehouse, the path points to the parent directory of repodata enabled=0|1 gpgcheck=0|1 gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 failovermethod={roundrobin|priority} #roundrobin:意为随机挑选,为默认值 #priority:按顺序访问 cost= #优先级,默认1000,值越小越优先 mirror=http|ftp|file #指向repo地址的文件