RPM has five basic operations (excluding creation packages): Installation, uninstallation, upgrade, query, and verification. Let's explain one by one.
First, install the RPM package
The RPM package typically has a file name similar to FOO-1.0-1.i386.rpm. These include the name of the package (foo), version number (1.0),
Issue (1), and Hardware Platform (i386). Installing a package simply typing the following command:
$ rpm -ivh foo-1.0-1.i386.rpm
Foo ##################################################
The RPM will print the name of the package (not necessarily the same as the file name), and then print a series of ## to indicate the installation.
schedule. Although the installation of the package is designed to be simpler as possible, it is still possible to happen:
1, the package has been installed
If your package has been installed, the following information will appear:
$ rpm -ivh foo-1.0-1.i386.rpm
Foo package foo-1.0-1 is already installed
Error: foo-1.0-1.i386.rpm cannot be installed
If you still have to install the package, you can use the -replacepkgs option on the command line, and the RPM will ignore the error message forcibly installed.
2, file conflict
If you have a file you want to install, there is a file that is installed when you install additional packages, the following error message appears:
# rpm -ivh foo-1.0-1.i386.rpm
Foo / usr / bin / foo conflicts with file from bar-1.0-1
Error: foo-1.0-1.i386.rpm cannot be installed
To let RPM ignore the error message, use the - replacefiles command line option.
3, unresolved dependencies
The RPM package may rely on other packages, which means that the package can be installed after the specific package is installed.
If there is such an unresolved dependency when you install a package. Will produce the following information:
$ rpm -ivh bar-1.0-1.i386.rpm
Failed Dependencies: foo is needed by bar-1.0-1
You must install the depends on the package to solve this problem. If you want to force installation (this is a bad idea, because after the installation is installed
Packages may not be able to run normally, please use the --Nodeps command line option.
Second, uninstall the RPM package
Uninstalling packages are as simple as installing a package:
$ rpm -e foo
Note that the name of the package name Name `foo, not the name of the package file, File` `foo-1.0-1.i386.rpm.
If other packages rely on packages you want to uninstall, error messages are generated when uninstalling. Such as:
$ rpm -e foo
REMOVING THESE PACKAGES WOULD BREAK Dependencies: foo is needed by bar-1.0-1
If you let RPM ignore this error continue to uninstall (this is not a good idea, because the program depends on the package may not be able to run),
Please use the --Nodeps command line option.
Third, upgrade RPM package
Upgrade packages and installation packages are very similar:.
$ rpm -uvh foo-2.0-1.i386.rpm
Foo ##################################################
RPM will automatically uninstall the Foo package of the installed boss, you will not see the information. In fact, you may always use -U
Install the package, because it is not installed even in the past, it can be run. Because RPM performs intelligent package upgrade,
Automatically handle the configuration file, you will see the following information:
Saving /etc/foo.conf as /etc/foo.conf.rpmsave
This means that your changes to the configuration file are not necessarily compatible. Therefore, RPM will back up the old file and install new files. You should learn as soon as possible
Different from these two configuration files to make the system continue to run normally.
Since the upgrade actually includes the uninstall and installation of the package, you may encounter an error caused by these two operations. Another you
The problem that may come is: When you use the old version of the package to upgrade the new version of the software, RPM generates the following error message:
$ rpm -uvh foo-1.0-1.i386.rpm
Foo Package Foo-2.0-1 (Which is newer) is already installed
Error: foo-1.0-1.i386.rpm cannot be installed
If you do have the need to degrade the package, join the --oldpackage command option.
Fourth, query the installed package
Use the command rpm -q to query the database that has been installed. Simple Using Command RPM -Q Foo will print the package name of the Foo package,
Version number, and issued number:
$ rpm -q foo
FOO-2.0-1
In addition to specifying the software package name, you can use the following options to indicate which packages you want to query. These options are called
"Software Package Specify Options".
· -A query all installed packages
· -F will query the package containing files.
· -P query package file name package
You can also specify the information displayed when the package is queried. They are called information selection options:
· -I display package information, such as describes, issues, size, build dates, installation dates, platforms, and other information.
• -l Displays a list of files in the package.
· -S Displays the status of all files in the package.
· -D shows a list of files labeled as documents (MAN Manual, Info Manual, Readmes, etc).
· -C Displays a list of files labeled as profiles. These are files you want to make after installation (Sendmail.cf,
Passwd, inittab, etc).
For files to display a list of files, you can add the -v command line option to get the output as the LS -L format.
V. Verification package
The verification package is made by comparing the original file information in the installed file and package. Verification is mainly comparable to the size of the file,
MD5 check code, file privilege, type, home and user group, etc.
The rpm-v command is used to verify a package. You can use any package selection option to query the package you want to verify. Command rpm -v foo
Will be used to verify the FOO package. As another example:
· Verify packages containing specific files:
RPM -VF / BIN / VI
· Verify all installed packages:
RPM -VA
· Verify according to an RPM package:
RPM -VP FOO-1.0-1.i386.rpm
This approach can be used if you are worried that your RPM database has been destroyed.
If everything is verified, no output will be generated. If there is inconsistent place, it will be displayed. The output format is 8-bit long characters
Strings, `` `to refer to the configuration file, then the file name. Each of the 8-bit character is used to represent a comparison of the file and the RPM database.
Result. `` `(Point) indicates the test pass. The following characters indicate some test failure to the RPM package:
Display character error source
5 md5 check code
S file size
L symbol connection
T file modification date
D equipment
U user
G user group
M mode E (including permissions and file types)
If there is an error message output, you should consider that it is to solve the problem by deleting or reinstalling.
Six, teach you a trick
RPM is not only a tool for installing / uninstalling programs, but it is a good hand of system maintenance and diagnosis. I have seen the following examples you will teach it.
· If you accidentally delete some files, you can't definitely delete those files, what should I do? You can type:
RPM -VA
RPM will display the file deletion on the screen. If you find that some files are lost or have been damaged, you can reinstall or uninstall first.
Install the package again.
· If you have encountered a file you don't know, if you want to investigate which package it belongs to, you can enter the following command
RPM -QF / USR / X11R6 / BIN / XJEWEL
The result of the output will be:
xjewel-1.6-1
• If you have more than two examples of more than two examples, such as file / usr / bin / paste have problems. You want to know which package contains this article
For you, you can simply type:
RPM -VF / USR / BIN / PASTE
· If you want to know more information about the program being used, you can type the following command to get the document information about the program in the package:
RPM -QDF / USR / BIN / ISPELL
The output is:
/usr/man/man4/ispell.4
/usr/man/man4/ENGLISH.4
/usr/man/man1/unsq.1
/usr/man/man1/tryAffix.1
/usr/man/man1/sq.1
/usr/man/man1/munchlist.1
/usr/man/man1/ispell.1
/usr/man/man1/findaffix.1
/usr/man/man1/buildhash.1
/usr/info/ispell.info.gz
/usr/doc/ispell-3.1.18-1/readme
· You find a new Koules rpm, but you don't know what it is doing, you can type the following command:
Rpm -qip koules-1.2-2.i386.rpm
· Now you want to know which files have been installed in the system of the RPM package in the system, you can type:
RPM-QLP Koules-1.2-2.i386.rpm output is:
/usr/man/man6/koules.6
/usr/lib/games/kouleslib/start.raw
/usR/lib/games/kouleslib/end.raw
/usr/lib/games/kouleslib/destroy2.raw
/usr/lib/games/kouleslib/destroy1.raw
/usR/LIB/games/kouleslib/creator2.raw
/usr/lib/games/kouleslib/creator1.raw
/usr/lib/games/kouleslib/colize.raw
/ USR / LIB / GAMES / KOULESLIB
/ USR / GAMES / KOULES
The above is just a few common examples. With your further use of RPM, you will find that its various functional options can be more powerful.
RPM package management function.