Linux rpm Command Details

Source: Internet
Author: User

RPM Daquan

RPM has five basic modes of operation (not including creating packages): Install, uninstall, upgrade, query, and verify.

Let's explain each of them.

First, install the RPM package

RPM packages typically have file names similar to foo-1.0-1.i386.rpm.

This includes the package name (foo), the version number (1.0), the release number (1), and the hardware platform (i386).

To install a package, simply type the following command: $ RPM-IVH foo-1.0-1.i386.rpm foo #################################### rpm The package name will be printed after installation (not necessarily with the file Name), and then print a series of # numbers to indicate the installation progress.

Although the installation of the package is designed to be as simple as possible, the following error may occur:

1, 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 want to install the package, you can use the--replacepkgs option on the command line, and RPM will ignore the error message and install it forcibly.

2. File conflicts if one of the packages you are installing is already installed when you install another package, you receive the following error message: # RPM-IVH foo-1.0-1.i386.rpm foo/usr/bin/foo conflicts with a file from Bar-1.0-1 error:foo-1.0-1.i386.rpm cannot be installed to let RPM ignore this error message, use the--replacefiles command-line option.

3. Unresolved dependencies The RPM package may depend on other packages, which means that a specific package is installed before the package can be installed. If there is an unresolved dependency when you install a package. The following information is generated: $ RPM-IVH bar-1.0-1.i386.rpm failed Dependencies:foo is needed by bar-1.0-1 you must install the dependent packages to resolve this issue. Use the--nodeps command-line option if you want to force the installation (this is a bad idea because the installed package does not necessarily work correctly).

Second, unload the RPM package

Uninstalling a package is as simple as installing a package: $ rpm-e foo Note here that the package name ' foo ' is used instead of the package file name ' foo-1.0-1.i386.rpm '. If other packages depend on the package you are uninstalling, an error message will be generated when uninstalling.

such as: $ rpm-e foo Removing these packages would break Dependencies:foo was needed by bar-1.0-1 if you let rpm ignore this error continue unloading (This is not a good idea because dependent program may not run), use the--nodeps command-line option.

Third, upgrade RPM package

The upgrade package is similar to the installation package:. $ RPM-UVH foo-2.0-1.i386.rpm Foo #################################### rpm will automatically uninstall the installed owner's Foo package and you will not see the information. In fact, you may always use-U to install the package, because it will work even if it has not been installed before.

Because RPM performs an intelligent package upgrade and automatically processes the configuration file, you will see the following information: saving/etc/foo.conf As/etc/foo.conf.rpmsave This means that your modifications to the configuration file may not necessarily be compatible.

As a result, RPM backs up old files before installing new files. You should resolve the differences between the two configuration files as soon as possible so that the system can continue to function properly.

Because the upgrade actually includes two procedures for uninstalling and installing the package, you may encounter errors caused by these two operations.

Another problem you might encounter is that when you use an older version of the package to upgrade a 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 need to downgrade the package, add the--oldpackage command option.

Iv. querying the installed packages

Use the command rpm-q to query the database of installed packages.

Simply use the command rpm-q foo to print out the package name, version number, and release number of the Foo package: $ rpm-q foo foo-2.0-1 In addition to specifying the package name, you can use the following options to indicate which packages you want to query for information.

These options are referred to as "package-specific Options".

· -A queries all installed packages
· -F to include the query with the file. The package
· The-P query package file name package can also specify the information that is displayed when the package is queried. They are called information selection options:
· -I displays package information such as description, issue number, size, build date, installation date, platform, and other types of information.
· -L displays a list of files in the package.
· -S displays the status of all files in the package.
· -D displays a list of files that are labeled as documents (man manual, Info manual, Readmes, etc).
· -C Displays a list of files that are labeled as profiles. These are the files you want to customize after installation (SENDMAIL.CF, passwd, Inittab, etc).

For those files that you want to display a list of files, you can increase the-v command-line option to obtain output as in ls-l format.

V. Verifying packages

Verify that the package is performed by comparing the original file information in the installed files and packages. Verification is mainly compared to the size of files, MD5 check code, file permissions, type, owner and user group.

The RPM-V command is used to validate a package. You can use any Package selection option to query the package you want to validate.

The command rpm-v foo will be used to verify the Foo package.

Another example:

· To verify a package that contains a specific file: Rpm-vf/bin/vi
· To verify all installed packages: Rpm-va
· Verify according to a RPM package: RPM-VP foo-1.0-1.i386.rpm

If you are concerned that your RPM database has been compromised, you can use this method. If everything checks properly, no output will be produced. If there is inconsistency, it will be displayed. The output format is a 8-bit long string, and "C" refers to the configuration file followed by the file name. Each of the 8-bit characters represents a comparison between a file and an attribute in the RPM database. ``. (point) indicates that the test passed:

The following characters indicate some kind of test failure for the RPM package:

Display character error source 5 MD5

Check code
S File Size
L Symbolic Connection
T File Modified Date
D Equipment
U User
G User Group
M mode e (including permissions and file types) if you have an error message output, you should carefully consider whether the problem is resolved by removing or reinstalling it.

Six, teach you a trick

RPM is not only a tool for installing/uninstalling programs, it is also a hooping for system maintenance and diagnostics.

Look at the following examples and you'll see how bad it is.

· If you delete some files by mistake, but you are not sure that you have deleted the files, what should I do?
You can type: Rpm-va rpm shows the deletion of files on the screen. If you find that some files are missing or damaged, you can reinstall or uninstall them before installing the package.
· If you encounter a file you do not know, to investigate which package it belongs to, you can enter the following command Rpm-qf/usr/x11r6/bin/xjewel output will be: xjewel-1.6-1
· If there is a case of synthesizing more than two examples, such as file/usr/bin/paste, there is a problem. You want to know which package contains the file, you can simply type: rpm-vf/usr/bin/paste
· If you want to know more about the program you are using, you can type the following command to obtain the documentation information about the program in the package: Rpm-qdf/usr/bin/ispell 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 found a new koules RPM, but you don't know what it does, you can type the following command: RPM-QIP koules-1.2-2.i386.rpm
· Now you want to know what files koules RPM packages have installed on your system, and 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 above are just a few common examples. As you further use RPM, you will find a combination of various functional options to enable more powerful RPM package management capabilities.

Linux rpm Command Details

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.