Linux operating system RPM five basic operations sharing

Source: Internet
Author: User
Tags command line manual file size md5 file permissions

Linux operating system has become a popular operating system, many people have begun to learn, the Linux operating system includes a lot of expertise, today and you talk about the Linux operating system in the RPM basic operation. It would be helpful if you learned the five basics of RPM in this article. RPM has five basic modes of operation (excluding the creation of packages): Installation, uninstall, upgrades, queries, and validations. Let's go through each of these explanations.

First, install the RPM package

The RPM package usually has a file name similar to foo-1.0-1.i386.rpm. These include the package name (foo), the version number (1.0), the issue number (1), and the hardware platform (i386). Installing a package requires simply typing the following command:

The code is as follows:

$ RPM-IVH foo-1.0-1.i386.rpm

Foo ####################################

After the RPM is installed, the name of the package is printed (not necessarily the same as the filename), and a series of # numbers are printed 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, the package has been installed if your package has been installed, the following information will appear:

The code is as follows:

$ 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 to force the installation.

2. File conflicts if one of the packages you want to install is installed with a different package installed, you receive the following error message:

The code is as follows:

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 allow RPM to ignore this error message, use the ――replacefiles command-line option.

3. Unresolved dependencies The RPM package may depend on other packages, which means that the package will not be installed until a specific package is installed. This unresolved dependency exists when you install a package. Generates 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 package you depend on to resolve this issue. If you want to force the installation (this is a bad idea because the installed package may not work properly), use the ――nodeps command-line option.

Second, uninstall the RPM package

Uninstalling a package is as simple as installing a package: $ rpm-e foo Note that this uses the package name ' foo ' instead of the package file's name, ' foo-1.0-1.i386.rpm '. If other packages depend on the package that you want to uninstall, An error message is generated when uninstalling. such as: $ rpm-e foo Removing these packages would break Dependencies:foo are needed by bar-1.0-1 if RPM ignores this error continue uninstalling (this is not a good idea because depending on the The program for the package may not run), use the ――nodeps command-line option.

Third, upgrade the RPM package

upgrading packages and installing packages are very similar:

The code is as follows:

$ RPM-UVH foo-2.0-1.i386.rpm

Foo ####################################

RPM will automatically uninstall the installed owner of the Foo package, you will not see the information. In fact, you might always use-u to install the package because it works even if the package 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 are not necessarily compatible. Therefore, RPM will first back up old files and install new files. You should resolve the differences between the two profiles as soon as possible so that the system continues to function properly.

Because the upgrade actually includes two procedures for uninstalling and installing the package, you may encounter errors caused by both operations. Another problem you may encounter is that when you use an older version of the package to upgrade a new version of the software, RPM produces the following error message

The code is as follows:

$ 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 demote the package, add the ――oldpackage command option.

Iv. Querying installed Packages

Use command rpm-q to query the database of installed packages. Simple command rpm-q foo prints the package name, version number, and issue number of the Foo package:

$ rpm-q Foo

Foo-2.0-1

In addition to specifying the package name, you can also use the following options to indicate which packages you want to query for information. These options are referred to as "package-specific Options". -A query for all installed packages. -F contains a file for the query. The package. -P a package that is named for a query package file 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, distribution number, size, build date, installation date, platform, and other 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 labeled as Documents (man manual, info Manual, Readme ' s, etc). -C Displays a list of files that are labeled as profiles. These are the files that you want to customize after installation (SENDMAIL.CF, passwd, Inittab, etc).

For those files that want to display a list of files, you can add the-V command-line option to get output like ls-l format.

V. Verifying software packages

The validation package is performed by comparing the original file information in the installed files and packages. The main validation is to compare the file size, MD5 check code, file permissions, type, and user groups.

The RPM-V command is used to validate a package. You can use any of the package selection options to query the packages that you want to validate. Command rpm-v foo will be used to validate the Foo package. Another example:. Verifying packages that contain 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 You can use this approach if you are concerned about your RPM database being compromised.

If everything is checked correctly, no output will be generated. If there is any inconsistency, it will be shown. The output format is a 8-bit long string, and ' C ' is used to refer to the configuration file, followed by the filename.

Each of the 8-bit characters represents the result of a comparison between a file and an attribute in the RPM database. (point) indicates that the test passed. The following characters indicate a test failure for the RPM package: Display character error source 5 MD5 Check code s File size L symbol connection T file modification Date D device u user g user Group M mode e (includes permissions and file types)

If you have an error message output, you should seriously consider whether to resolve the problem by deleting or reinstalling.

Six, teach you a trick

RPM is not only a tool for installing/uninstalling programs, it is also a brilliant at publicity for system maintenance and diagnostics. Look at the following examples and you'll see how powerful it is. What if you accidentally delete some files, but you're not sure you deleted those files anyway? You can type: Rpm-va RPM Displays the file deletion on the screen. If you find that some files are missing or corrupted, you can reinstall them or uninstall them before installing the package. If you run into a file you don't know, to find out 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 combination of the above two examples, such as file/usr/bin/paste problems. You want to know which package contains the file, and 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 documentation information about the program in the package: Rpm-qdf/usr/bin/ispell output is:

The code is as follows:

/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 have found 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 what files are installed in the system by the Koules RPM package, you can type: RPM-QLP koules-1.2-2.i386.rpm output is:

The code is as follows:

/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

These are just a few common examples. As you further use RPM, you will find that its various combinations of functional options can achieve more powerful RPM package management capabilities. Through this article I hope you can firmly grasp the Linux operating system rpm five basic operating methods.

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.