Linux Command Tips: RPM

xiaoxiao2021-03-19  186

8.2 Using RPM

RPM has five basic operations (excluding creation packages): Installation, uninstallation, upgrade, query, and verification. This is a brief description of these five operations. Use the command rpm --help, or check Section 8.4 to get more comprehensive information.

8.2.1 Installation

The RPM package typically has a file name similar to FOO-1.0-1.i386.rpm. These include the name (foo), version number (1.0), issue number (1), and hardware platform (i386). Installing a package simply type:

$ RPM -IVH FOO-1.0-1.i386.rpmfoo ######################################################################################################################################################################################################################################################################

As you can see, RPM will print out the name of the package (not necessarily the same as the file name), and then print a series of ## to indicate the installation progress.

The installation of the package is designed as simple as possible, but several errors may occur:

8.2.1.1 Package has been installed If your package has been installed, the following information will appear:

$ rpm -ivh foo-1.0-1.i386.rpmfoo package foo-1.0-1 is already installederror: 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, which will ignore the error message.

8.2.1.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.rpmfoo / 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. .

8.2.1.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 dependendencies: foo is neededed 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 the installed package is not necessarily running normally), use the --Node Pro command line option.

8.2.2 Uninstall

Uninstalling packages are as simple as installing a package:

$ rpm -e foo

Note that this name name `` foo '' uses the package, not the name File `` foo-1.0-1.i386.rpm '' of the package file.

If other packages rely on packages you want to uninstall, error messages are generated when uninstalling. Such as:

$ rpm -e fooremoving these packages Would Break dependencies: foo is needed by bar-1.0-1

If you want RPM to ignore the error message to 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.

8.2.3 Upgrade

Upgrade packages and installation packages are very similar:.

$ rpm -uvh foo-2.0-1.i386.rpmfoo #######################################################################################################################################################################################################################################################

RPM will automatically uninstall the Foo package of the installed boss, you will not see the information. In fact, you may always use -U to install the package, because even if the package is not installed, you can run it normally. Because RPM performs intelligent packages upgrade, automatically handle the configuration file, you will see the following information:

Saving /etc/foo.conf as /etc/foo.conf.rpmsave This means that you do not necessarily compatibility with the configuration files in the configuration file. Therefore, RPM will back up old files and install new files. You should resolve the differences between these two configuration files as soon as possible so that the system can run normally.

Because the upgrade is actually a comprehensive package of uninstall and installation, you may meet the errors that may occur in those operations. There is a difference, that is, when you use the old version of the package to upgrade the new version of the software, you will generate the following error message:

$ rpm -uvh foo-1.0-1.i386.rpmfoo package foo-2.0-1 (Which is newer) is already installederror: foo-1.0-1.i386.rpm cannot be installed

To keep rpm to use the "upgrade", use the --oldpackage command line parameters.

8.2.4 query

Use the command rpm -q to query the database that has been installed. Simple Using Command RPM -Q Foo will print the package name, version number, and issue number of the Foo package:

$ rpm -q foofoo-2.0-1

In addition to specifying the software package name, you can specify which packages you want to query together with the following options. These options are called "software package specified options":

-f The package containing the package query package file name is . There are several ways to include the package file . Specifies the information displayed when the query package is queried. The following options are used to select the information you are interested in to display. They are called information selection options:

-i display package information, such as description, issue number, size, build date, installation date, platform, and other various 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 a document (MAN Manual, INFO Manual, ReadMe's, etc). -c Displays a list of files labeled as profiles. These are files you want to make up in installation (sendmail.cf, passwd, inittab, etc). For files to display file list, you can add the -v command line option to get the output as the LS -L format . .

8.2.5 Verify that the verification package is performed by comparing the original file information in the package installed from the package from the package. In addition to some other things, the verification is mainly comparable to the size, MD5 check code, file privileges, type, home owners, and user groups.

The rpm-v command is used to verify a package. You can use any package selection option to query the package command rpm -v foo you want to verify will be used to verify the Foo package. As another example:

Verify package containing specific files: rpm -vf / bin / vi

Verify all installed packages: rpm -va

Verify a package according to an RPM: 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 an 8-bit long string, `` `'' is used to refer to the configuration file, then the file name. 8-bit character's comparison result for indicating a file and the RPM database. ``. '' (Point) indicates the test. The following characters indicate a failure of some test: 5 MD5 check code S File size L Symbol connection T file modification date D Device U User G User Group M Mode E (including permissions and file type) If there is information output, you should be careful Considering that it is deleted, reinstall, or fix the problem.

转载请注明原文地址:https://www.9cbs.com/read-130262.html

New Post(0)