Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Commands for installation, deletion, validation and query of rpm package under linux system

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains the "linux system rpm package installation, deletion, validation, query commands", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "linux system rpm package installation, deletion, effectiveness, query commands" it!

Install the package

Rpm-I package full name

Delete

Rpm-e name (not package name)

Parameters.

-ivh gets a detailed installation process

-- nodeps ignores dependencies

-- force forced installation

-U package name: upgrade installation

-F update no matter what it is directly overwritten

-- replacepkgs so that RPM will ignore the error message-- vih-- replacepkgs

-Q name: query

-qa queries all installed RPM

-qi name queries the details of this software

-ql display list

-qf path: query which package a file belongs to

-qp package name: find out what the file is

-qpl package name: for a package that has not been installed

Rpm-qc configuration file

Validate rpm-Va

Rpm-Vf / bin/ls

Rpm-Vp package name

5-MD5 checksum

S-File length

L-symbolic link

T-date the file was modified

D-equipment

U-user

G-user group

M-mode (including license and file type)

?-unreadable files

Use RPM

RPM has five basic modes of operation (excluding package compilation): install, uninstall, upgrade, query, and verify. They are described one by one in this section. For complete details and options, you can use rpm-- help, or go to other RPM resources in the section called for more information about RPM.

1 installation

A typical RPM has a name like foo-1.0-1.i386.rpm, which indicates the package name (foo), version number (1.0), release number (1), and hardware platform (i386). To install a package, simply type the following command:

# rpm-ivh foo-1.0-1.i386.rpm

Foo # #

#

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

Attention please

Although packages are usually installed using rpm-ivh foo-1.0-1.i386.rpm, you can also use rpm-Uvh foo-1.0-1.i386.rpm instead. -U is a package upgrade parameter and can also be used to install new packages. See the upgrade for detailed usage of the-U parameter in RPM.

The installation design of the package is very simple, but the following errors can occur:

The package has been installed

If the package has been installed, the following message appears:

# 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 so that RPM ignores the error message:

# rpm-ivh-replacepkgs foo-1.0-1.i386.rpm

Foo # #

#

File conflict

If a file in the package to be installed has already been installed while installing other packages, the following message is displayed:

# 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 have RPM ignore the error message, use the-- replacefiles command line option:

# rpm-ivh-replacefiles foo-1.0-1.i386.rpm

Foo # #

#

Unresolved dependencies

A RPM package may be "dependent" on other packages, which means that a specific package cannot be installed until it has been installed. If this existing dependency is not resolved when installing this package, you will see:

# rpm-ivh bar-1.0-1.i386.rpm

Failed dependencies:

Foo is needed by bar-1.0-1

#

This problem can only be solved by installing the dependent software package first. If you want to force the installation (which is not a good idea, because the installed package may not work properly), you can use the-- nodeps command line option.

3.2.2 Uninstall

Uninstalling a package is as simple as installing a package:

# rpm-e foo

#

Attention please

Note that the name of the package "foo" is used here instead of the file name "foo-1.0-1.i386.rpm" of the original package. When you uninstall the package, you need to replace the foo package name with the actual file name of the original package.

Dependency errors may occur when uninstalling a package, indicating that there are installation dependencies between other packages and this package. For example:

# rpm-e foo

Removing these packages would break dependencies:

Foo is needed by bar-1.0-1

#

To make RPM ignore this error when uninstalling this package (which is not a good idea, because packages that have dependencies on it may not work properly after uninstallation), use the-- nodeps command line option.

3.2.3 upgrade

The upgrade package is very similar to the installation package.

# rpm-Uvh foo-2.0-1.i386.rpm

Foo # #

#

RPM will automatically uninstall the older version of the foo package that has been installed, and users will not be able to see the information. In fact, users may always use-U to install the package, because it works even if it has not been installed before.

Because RPM performs an intelligent package upgrade and automatically processes the configuration file, the following message is displayed:

Saving / etc/foo.conf as / etc/foo.conf.rpmsave

This means that the user's changes to the configuration file may not necessarily be "upward compatible" with the configuration file in the package. Therefore, RPM backs up the original files before installing the new ones. Users should resolve the differences between the two profiles as soon as possible so that the system can continue to function normally.

Because the upgrade is actually a combination of uninstalling and installing the package, you may also encounter errors that may occur in those operations. Then there is the following message when upgrading a new version of the software using the old version of the RPM package:

# 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

#

To force an "upgrade" using RPM, use the-- oldpackage command line argument:

# rpm-Uvh-oldpackage foo-1.0-1.i386.rpm

Foo # #

#

3.2.4 Update

Package updates are similar to package upgrades:

# rpm-Fvh foo-1.2-1.i386.rpm

Foo # #

#

The RPM update option is to check that the package version specified on the command line is consistent with the package version installed on the system. When the RPM update option finishes processing a new version of the installed package, the package is upgraded to the new version. However, the RPM update option cannot install packages that are not currently available on the system. This is different from the RPM upgrade, which allows you to install the package, regardless of whether the older version of the package has been installed.

The RPM update option is a good way to update a package or set of packages. The RPM update option is useful if users download a large number of packages but only want to upgrade existing packages on the system. Using the RPM update option means you don't have to pick and choose from downloaded packages, and you don't have to delete unwanted packages in advance.

In this case, simply type:

# rpm-Fvh * .rpm

The RPM tool automatically upgrades packages that are already installed.

3.2.5 query

Use the command rpm-Q to query the database of the installed package. 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, the user can also use the following options with-Q to indicate which software packages to query for information. These options are called package specification options.

-a query for all installed software packages.

-f will query the software package that contains the file.

-p query the package file named package.

There are several ways to specify the information displayed when querying the package. The following options can display the information you are interested in. Such options are called information selection options.

-I displays package information, such as description, release number, size, compilation date, installation date, hardware platform, and other types of information.

-l lists the files contained in the package.

-s displays the status of all files in the package.

-d lists the files marked as documents (for example, man manuals, info information, README, and so on).

-c lists the files marked as configuration files. These files need to be customized after installation, such as (sendmail.cf, passwd, inittab, etc.).

If you want to display a list of files while performing the above options, you can use the-v command line option at the same time to get output similar to the ls-l format.

3.2.6 check

The package check compares the same information of the files installed from the package with the original files in the package. Like other checks, the package check compares the file length, MD5 checksum, license, type, file owner, and group.

Use the rpm-V command for packet verification. Users can use each package selection option to list the query results of the check package. Simply use rpm-V foo to verify all the files in the foo package at the time of the original installation. For example:

Verify the software package containing a specific file: rpm-Vf / bin/vi

Verify all installed software packages: rpm-Va

Use the RPM package file to verify the installed package: rpm-Vp foo-1.0-1.i386.rpm

If you are worried about the corruption of the RPM database, you can verify it in this way.

If the verification result is normal, no output will be produced. If there is any inconsistency, it will be shown. The output format is an 8-bit long string, and "c" is used to refer to the configuration file, followed by the file name. 8-bit long characters, each representing the result of a file attribute compared to the attribute recorded in the RPM database. "." (dot) indicates that the test passed. The following characters represent the failure of a test:

5-MD5 checksum

S-File length

L-symbolic link

T-date the file was modified

D-equipment

U-user

G-user group

M-mode (including license and file type)

?-unreadable files

If there is information output, the user should seriously consider whether to delete, reinstall, or fix the problem.

3.2Using RPM

RPM has five basic modes of operation (excluding package compilation): install, uninstall, upgrade, query, and verify. They are described one by one in this section. For complete details and options, you can use rpm-- help, or go to other RPM resources in the section called for more information about RPM.

3.2.1 installation

A typical RPM has a name like foo-1.0-1.i386.rpm, which indicates the package name (foo), version number (1.0), release number (1), and hardware platform (i386). To install a package, simply type the following command:

# rpm-ivh foo-1.0-1.i386.rpm

Foo # #

#

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

Attention please

Although packages are usually installed using rpm-ivh foo-1.0-1.i386.rpm, you can also use rpm-Uvh foo-1.0-1.i386.rpm instead. -U is a package upgrade parameter and can also be used to install new packages. See the upgrade section for detailed usage of the-U parameter in RPM.

The installation design of the package is very simple, but the following errors can occur:

The package has been installed

If the package has been installed, the following message appears:

# 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 so that RPM ignores the error message:

# rpm-ivh-replacepkgs foo-1.0-1.i386.rpm

Foo # #

#

File conflict

If a file in the package to be installed has already been installed while installing other packages, the following message is displayed:

# 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 have RPM ignore the error message, use the-- replacefiles command line option:

# rpm-ivh-replacefiles foo-1.0-1.i386.rpm

Foo # #

#

Unresolved dependencies

A RPM package may be "dependent" on other packages, which means that a specific package cannot be installed until it has been installed. If this existing dependency is not resolved when installing this package, you will see:

# rpm-ivh bar-1.0-1.i386.rpm

Failed dependencies:

Foo is needed by bar-1.0-1

#

This problem can only be solved by installing the dependent software package first. If you want to force the installation (which is not a good idea, because the installed package may not work properly), you can use the-- nodeps command line option.

3.2.2 Uninstall

Uninstalling a package is as simple as installing a package:

# rpm-e foo

#

Attention please

Note that the name of the package "foo" is used here instead of the file name "foo-1.0-1.i386.rpm" of the original package. When you uninstall the package, you need to replace the foo package name with the actual file name of the original package.

Dependency errors may occur when uninstalling a package, indicating that there are installation dependencies between other packages and this package. For example:

# rpm-e foo

Removing these packages would break dependencies:

Foo is needed by bar-1.0-1

#

To make RPM ignore this error when uninstalling this package (which is not a good idea, because packages that have dependencies on it may not work properly after uninstallation), use the-- nodeps command line option.

3.2.3 upgrade

The upgrade package is very similar to the installation package.

# rpm-Uvh foo-2.0-1.i386.rpm

Foo # #

#

RPM will automatically uninstall the older version of the foo package that has been installed, and users will not be able to see the information. In fact, users may always use-U to install the package, because it works even if it has not been installed before.

Because RPM performs an intelligent package upgrade and automatically processes the configuration file, the following message is displayed:

Saving / etc/foo.conf as / etc/foo.conf.rpmsave

This means that the user's changes to the configuration file may not necessarily be "upward compatible" with the configuration file in the package. Therefore, RPM backs up the original files before installing the new ones. Users should resolve the differences between the two profiles as soon as possible so that the system can continue to function normally.

Because the upgrade is actually a combination of uninstalling and installing the package, you may also encounter errors that may occur in those operations. Then there is the following message when upgrading a new version of the software using the old version of the RPM package:

# 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

#

To force an "upgrade" using RPM, use the-- oldpackage command line argument:

# rpm-Uvh-oldpackage foo-1.0-1.i386.rpm

Foo # #

#

3.2.4 Update

Package updates are similar to package upgrades:

# rpm-Fvh foo-1.2-1.i386.rpm

Foo # #

#

The RPM update option is to check that the package version specified on the command line is consistent with the package version installed on the system. When the RPM update option finishes processing a new version of the installed package, the package is upgraded to the new version. However, the RPM update option cannot install packages that are not currently available on the system. This is different from the RPM upgrade, which allows you to install the package, regardless of whether the older version of the package has been installed.

The RPM update option is a good way to update a package or set of packages. The RPM update option is useful if users download a large number of packages but only want to upgrade existing packages on the system. Using the RPM update option means you don't have to pick and choose from downloaded packages, and you don't have to delete unwanted packages in advance.

In this case, simply type:

# rpm-Fvh * .rpm

The RPM tool automatically upgrades packages that are already installed.

3.2.5 query

Use the command rpm-Q to query the database of the installed package. 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, the user can also use the following options with-Q to indicate which software packages to query for information. These options are called package specification options.

-a query for all installed software packages.

-f will query the software package that contains the file.

-p query the package file named package.

There are several ways to specify the information displayed when querying the package. The following options can display the information you are interested in. Such options are called information selection options.

-I displays package information, such as description, release number, size, compilation date, installation date, hardware platform, and other types of information.

-l lists the files contained in the package.

-s displays the status of all files in the package.

-d lists the files marked as documents (for example, man manuals, info information, README, and so on).

-c lists the files marked as configuration files. These files need to be customized after installation, such as (sendmail.cf, passwd, inittab, etc.).

If you want to display a list of files while performing the above options, you can use the-v command line option at the same time to get output similar to the ls-l format.

3.2.6 check

The package check compares the same information of the files installed from the package with the original files in the package. Like other checks, the package check compares the file length, MD5 checksum, license, type, file owner, and group.

Use the rpm-V command for packet verification. Users can use each package selection option to list the query results of the check package. Simply use rpm-V foo to verify all the files in the foo package at the time of the original installation. For example:

Verify the software package containing a specific file: rpm-Vf / bin/vi

Verify all installed software packages: rpm-Va

Use the RPM package file to verify the installed package: rpm-Vp foo-1.0-1.i386.rpm

If you are worried about the corruption of the RPM database, you can verify it in this way.

If the verification result is normal, no output will be produced. If there is any inconsistency, it will be shown. The output format is an 8-bit long string, and "c" is used to refer to the configuration file, followed by the file name. 8-bit long characters, each representing the result of a file attribute compared to the attribute recorded in the RPM database. "." (dot) indicates that the test passed. The following characters represent the failure of a test:

5-MD5 checksum

S-File length

L-symbolic link

T-date the file was modified

D-equipment

U-user

G-user group

M-mode (including license and file type)

?-unreadable files

If there is information output, the user should seriously consider whether to delete, reinstall, or fix the problem.

Thank you for your reading, the above is the "linux system rpm package installation, deletion, validation, query command" content, after the study of this article, I believe you on the linux system rpm package installation, deletion, effectiveness, query command this problem has a more profound understanding, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report