Linux rpm Command parameter usage [introduction and application]

Source: Internet
Author: User
Tags gpg pack

RPM is a "Add/Remove Program" in Windows like Redhat Package Manager (Redhat Packages management tool)

RPM Execution Installation package
Binary packages (binary) and source code packages (sources) are two types. Binary packages can be installed directly on the computer, and the source code package will be automatically compiled and installed by RPM. Source code packages often use src.rpm as the suffix name.

Common Command combinations:

-IVH: Installation shows installation progress--install--verbose--hash
-UVH: Upgrade package--update;
-QPL: Lists the file information in the RPM package [Query packages list];
-QPI: Lists the description information for RPM packages [Query Package Install pack (s)];
-QF: Find which rpm package the specified file belongs to [Query file];
-va: Check all RPM packages to find the missing files [View Lost];
-E: Remove Package

Rpm-q Samba//query program is installed

RPM-IVH/MEDIA/CDROM/REDHAT/RPMS/SAMBA-3.0.10-1.4E.I386.RPM//install by Path and show progress
RPM-IVH--relocate/=/opt/gaim gaim-1.3.0-1.fc4.i386.rpm//Specify installation directory

RPM-IVH--test gaim-1.3.0-1.fc4.i386.rpm//used to check dependencies; not a real installation;
RPM-UVH--oldpackage gaim-1.3.0-1.fc4.i386.rpm//new version degraded to old version

Rpm-qa | grep httpd #[Search Specifies whether RPM packages are installed]--all search *httpd*
RPM-QL httpd #[Search rpm Package]--list All files installation directory

Rpm-qpi linux-1.4-6.i368.rpm #[View RPM Packages]--query--package--install Package Information
RPM-QPF linux-1.4-6.i368.rpm #[View RPM Package]--file
RPM-QPR file.rpm #[View Package] Dependencies
Rpm2cpio file.rpm |cpio-div #[extract file]

RPM-IVH file.rpm #[Installing the new Rpm]--install--verbose--hash
Rpm-ivh

RPM-UVH file.rpm #[Upgrade a Rpm]--upgrade
Rpm-e file.rpm #[Delete an RPM package]--erase

Common parameters:

Install/upgrade/erase options:

-I,--install install package (s)
-V,--verbose provide more detailed output
-H,--hash print hash marks as package installs (good with-v)
-E,--erase Erase (Uninstall) package
-U,--upgrade=<packagefile>+ upgrade package (s)
--replacepkge Install packages Regardless of whether they have been installed
--test installation test, not actually installed
--nodeps ignoring dependencies of packages forcibly installed
--force ignoring package and file conflicts

Query options (With-q or--query):
-A,--all query/verify all packages
-P,--package query/verify a package file
-L,--list list files in package
-D,--docfiles list all documentation files
-F,--file query/verify package (s) owning file

RPM Source Code Packaging installation

. src.rpm end of the file, these files are packaged by the software source code, the user to install such RPM packages, must use the command:

RPM--recompile vim-4.6-4.src.rpm # This command will unpack and compile the source code and install it if the user uses the command:

RPM--rebuild vim-4.6-4.src.rpm # After the installation is complete, the compiled executable is also repackaged as a i386.rpm RPM package.

I do not like to write more complex things, trouble words ' but as a reference ' I also turn a person's ' write really very comprehensive '

North-South and north-south
from: linuxsir.org
Summary: RPM is an abbreviation for Red Hat Package manager and is originally intended to be managed by Red Hat packages, this article introduces RPM, and combines examples to explain the application of RPM manual installation, query, etc.


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Body:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

RPM is an abbreviation for Red Hat Package Manager and is intended to be managed by Red Hat packages, as the name implies in the package management that Red Hat has contributed, and in mainstream releases such as Fedora, Redhat, Mandriva, SuSE, Yellowdog, etc. , as well as the two-time releases that were developed on the basis of these editions;

What is included in the RPM package? It contains an executable binary program, This program is similar to the. exe file in the Windows package, and the RPM package also includes the files required for the program to run, which is similar to the Windows package, where Windows programs run with other files besides the. exe file.

A RPM package of applications, and sometimes in addition to their own additional files to ensure that other specific version of the file, which is the dependencies of the package, dependencies are not unique to Linux, Windows operating system also exists in the same , for example, we run 3D games in Windows, and during installation, he may be prompted to install direct 9; Linux and Windows are similar in principle;

Software Installation Flowchart:


This article uses the scope:

1, this article is the RPM management software description, to pass file.tar.gz or file.tar.bz2 source package make;
2, when installing the software, it is best to use the respective distribution of the system software package management tools, for fedora/redhat you can refer to the following articles;

1) Fedora System Management Package tool System-config-packages, easy to add and remove software packages provided by the system installation disk, see Fedora Package Manager system-config-packages for details

2) Redhat System Management software Package tool, the new point of the system should be redhat-config-packages, the use of the same as the Fedora Package Manager system-config-packages;

3) Apt + synaptic package online installation, removal, upgrade tools, usage: Install or upgrade Fedora Core 4.0 packages online with apt+synaptic
4) Yum Package online installation, upgrade, removal Tool; Usage: "Fedora/redhat install update package online, yum"

5) all Yum and apt tutorials "apt and yum"

Now that apt and Yum are very mature, it is advisable to use apt or yum when installing the software, or system-config-packages or redhat-config-packages if the packages provided by the system disk are installed;


One, the use of RPM package management;

1, can install, delete, upgrade and management software, of course, also support online installation and upgrade software;
2, through the RPM package management can know what the package contains files, you can also know the system of a file belonging to which package;
3, can be in the query system of the package is installed and its version;
4, as a developer can package their own program for the RPM package release;
5, Package signing GPG and MD5 import, verification and signature release
6. Check the dependencies to see if there are any packages that disrupt the system due to incompatibility;


Second, the use of RPM rights;

RPM Software Installation, deletion, update only the root permission to use, for the query function of any user can operate, if the normal user has the installation directory permissions, can also be installed;


Three, rpm a little simple usage;

In addition to the Package manager, we can also install through the RPM command, is not all packages can be installed through the RPM command? No, the file ends with a. rpm suffix; sometimes we find file.rpm on some websites, we have to use RPM to install;

A) initialize the RPM database;

The RPM command is used to query whether an RPM package is installed and is to be done through the RPM database, so we often use the following two commands to initialize the RPM database;

[[email protected] beinan]# rpm --initdb
[[email protected] beinan]# rpm --rebuilddb 注:这个要花好长时间;

Note: These two parameters are extremely useful, sometimes the RPM system is out of the question, can not be installed and query, mostly there is a problem;

II) the query function of RPM package management:

Command format

rpm {-q|--query} [select-options] [query-options]

The RPM query function is extremely powerful and is one of the most important functions; For a few common examples, more specific, please refer to #man rpm

1, the system has installed the software query;

1) Query the system has installed software;

语法:rpm -q 软件名

Example:

[[email protected] beinan]# rpm -q gaim
gaim-1.3.0-1.fc4

-Q is--query, Chinese means "ask", this command indicates that the system is not installed Gaim, if the installation will have information output, if not installed, will output Gaim not installed information;

To view all installed packages in the system, add the-a parameter;

[[email protected] RPMS]# rpm -qa


If paging is viewed, add a pipe | and more command;

[[email protected] RPMS]# rpm -qa |more

Look for a software in all installed packages, such as Gaim, which can be extracted with grep;

[[email protected] RPMS]# rpm -qa |grep gaim

The function of the above is the same as the result of rpm-q gaim output;

2) query which package a file is already installed in;

语法 rpm -qf 文件名


Note: The absolute path to which the file name is located is indicated

Example:

[[email protected] RPMS]# rpm -qf /usr/lib/libacl.la
libacl-devel-2.2.23-8

3) query where the installed packages are installed;

语法:rpm -ql 软件名 或 rpm rpmquery -ql 软件名

Example:

[[email protected] RPMS]# rpm -ql lynx
[[email protected] RPMS]# rpmquery -ql lynx

4) query information for an installed package

语法格式: rpm -qi 软件名

Example:

[[email protected] RPMS]# rpm -qi lynx

5) Check the configuration file of the installed software;

语法格式:rpm -qc 软件名

Example:

[[email protected]ost RPMS]# rpm -qc lynx

6) View a document where the software has been installed:

语法格式: rpm -qd 软件名

Example:

[[email protected] RPMS]# rpm -qd lynx

7) Check the packages and files on which the software is installed;

语法格式: rpm -qR 软件名

Example:

[[email protected] beinan]# rpm -qR rpm-python

Query the summary of installed software: For a package has been installed, we can combine a series of parameters to use, such as Rpm-qil;

[[email protected] RPMS]# rpm -qil lynx


2. For non-installed packages, view:

The prerequisite for viewing is that you have a. rpm file, which means a view of the existing software file.rpm;

1) To view the use of a software package, version and other information;

语法: rpm -qpi file.rpm

Example:

[[email protected] RPMS]# rpm -qpi lynx-2.8.5-23.i386.rpm

2) View the files contained in a package;

语法: rpm -qpl file.rpm

Example:

[[email protected] RPMS]# rpm -qpl lynx-2.8.5-23.i386.rpm

3) View the location of the package's documentation;

语法: rpm -qpd file.rpm

Example:

[[email protected] RPMS]# rpm -qpd lynx-2.8.5-23.i386.rpm

5) View the configuration file of a package;

语法: rpm -qpc file.rpm

Example:

[[email protected] RPMS]# rpm -qpc lynx-2.8.5-23.i386.rpm

4) View dependencies for a package

语法: rpm -qpR file.rpm

Example:

[[email protected] archives]# rpm -qpR yumex_0.42-3.0.fc4_noarch.rpm
/bin/bash
/usr/bin/python
config(yumex) = 0.42-3.0.fc4
pygtk2
pygtk2-libglade
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
usermode
yum >= 2.3.2


(iii) installation, upgrading and deletion of software packages;


1, install and upgrade a RPM package;

[[email protected] beinan]#rpm -vih file.rpm 注:这个是用来安装一个新的rpm 包;
[[email protected] beinan]#rpm -Uvh file.rpm 注:这是用来升级一个rpm 包;

If there is a dependency, please resolve the dependency, in fact, the package Manager can be a good solution to the dependency, see the previous Package Manager introduction, if you can not find dependencies in the package manager of the package, it can only compile the package he depends on to resolve the dependency, or force installation;

Syntax structure:

[roo[email protected] beinan]# rpm -ivh file.rpm --nodeps --force
[[email protected] beinan]# rpm -Uvh file.rpm --nodeps --force

For more parameters, see man rpm

Examples of applications:

[[email protected] RPMS]# rpm -ivh lynx-2.8.5-23.i386.rpm
Preparing... ########################################### [100%]
      1:lynx ########################################### [100%]
[[email protected] RPMS]# rpm -ivh --replacepkgs lynx-2.8.5-23.i386.rpm
Preparing... ########################################### [100%]
      1:lynx ########################################### [100%]

Note: The--replacepkgs parameter is installed with the software installed again, sometimes not too much necessary;

Test installation Parameters--test, used to check dependencies; not a real installation;

[[email protected] RPMS]# rpm -ivh --test gaim-1.3.0-1.fc4.i386.rpm
Preparing... ########################################### [100%]

Downgrade to old version by new version, add--oldpackage parameter;

[[email protected] RPMS]# rpm -qa gaim
gaim-1.5.0-1.fc4
[[email protected] RPMS]# rpm -Uvh --oldpackage gaim-1.3.0-1.fc4.i386.rpm
Preparing... ########################################### [100%]
      1:gaim ########################################### [100%]
[[email protected] RPMS]# rpm -qa gaim
gaim-1.3.0-1.fc4

Specify the installation directory for the package: To add the-relocate parameter, the following example is to install the gaim-1.3.0-1.fc4.i386.rpm specified in the/opt/gaim directory;

[[email protected] RPMS]# rpm -ivh --relocate /=/opt/gaim gaim-1.3.0-1.fc4.i386.rpm
Preparing... ########################################### [100%]
      1:gaim ########################################### [100%]
[[email protected] RPMS]# ls /opt/
gaim

Specify the installation directory for the package: To add the-relocate parameter, the following example is to install the lynx-2.8.5-23.i386.rpm specified in the/opt/lynx directory;


[Email protected] rpms]# RPM-IVH--relocate/=/opt/lynx--badreloc lynx-2.8.5-23.i386.rpm
Preparing ... ########################################### [100%]
1:lynx ########################################### [100%]

How do the programs we install in the specified directory call? General execution procedures, are placed in the installation directory of the bin or sbin directory; see the following example; If there is an error output, do the corresponding link, with ln-s;

[[email protected] RPMS]# /opt/lynx/usr/bin/lynx
Configuration file /etc/lynx.cfg is not available.
[[email protected] RPMS]# ln -s /opt/lynx/etc/lynx.cfg /etc/lynx.cfg
[[email protected] RPMS]# /opt/lynx/usr/bin/lynx www.linuxsir.org


2, delete a RPM package;

First of all, you have to learn to query the RPM package, please see the previous instructions;

[[email protected] Beinan] #rpm-E package Name

Example: I want to remove the Lynx package, the complete operation should be:

[[email protected] RPMS]# rpm -e lynx

If you have dependencies, you can also remove them with--nodeps ignore dependent checks. But as far as possible not to do so, it is best to use the Package Manager systerm-config-packages to remove or add software;

[[email protected] beinan]# rpm -e lynx --nodeps


Iv. Import Signature:

[[Email protected] rpms]# rpm--import signature file

Example:

[[email protected] fc40]# rpm --import RPM-GPG-KEY
[[email protected] fc40]# rpm --import RPM-GPG-KEY-fedora

For more information on the signature function of RPM, see Man rpm

Five, RPM Management Pack Manager support network installation and query;

For example, we want to query and install packages through a single image of Fedora Core 4.0;

Address:
http://mirrors.kernel.org/fedora/core/4/i386/os/Fedora/RPMS/

Example:

Command format:

rpm 参数 rpm包文件的http或者ftp的地址 # rpm -qpi http://mirrors.kernel.org/fedora/core/4/i386/os/ Fedora/RPMS/gaim-1.3.0-1.fc4.i386.rpm
# rpm -ivh http://mirrors.kernel.org/fedora/core/4/i386/os/ Fedora/RPMS/gaim-1.3.0-1.fc4.i386.rpm

Extrapolate bar;


Vi. add to the query of installed packages;

[[email protected] RPMS]# updatedb
[[email protected] RPMS]# locate 软件名或文件名

Through the updatedb, we can use locate to find out where some software is installed, the system will be executed at the initial installation updatedb, once every time, to keep the installed repositories up-to-date; UpdateDB is Slocate package all If you do not have this command, you have to install slocate;

Example:

[[email protected] RPMS]# locate gaim



Extracting files from RPM packages;

命令格式: rpm2cpio file.rpm |cpio -div


Example:

[[email protected] RPMS]# rpm2cpio gaim-1.3.0-1.fc4.i386.rpm |cpio -div

The extracted files are used in USR and etc in the operating directory;

In fact, this is not as easy as specifying the installation directory to install the software, you can also extract files;

Specify the installation directory for the package: To add the-relocate parameter, the following example is to install the gaim-1.3.0-1.fc4.i386.rpm specified in the/opt/gaim directory;

[[email protected] RPMS]# rpm -ivh --relocate /=/opt/gaim gaim-1.3.0-1.fc4.i386.rpm
Preparing... ########################################### [100%]
      1:gaim ########################################### [100%]
[[email protected] RPMS]# ls /opt/
gaim

This also can be at a glance; Gaim all the files are installed in the/opt/gaim, we just back up the Gaim directory, and then remove the Gaim, which is actually a little use of extracting files;


Eight, RPM configuration file;

RPM package Management, the configuration file is RPMRC, we can find in our own system, such as Fedora Core 4.0 in the RPMRC file is located;

[[email protected] RPMS]# locate rpmrc
/usr/lib/rpm/rpmrc
/usr/lib/rpm/redhat/rpmrc

We can view it through RPM--SHOWRC, and we have to learn it by ourselves. Oh... Do not ask me, I do not understand, as long as you read this article, think that it is useful to you, your level is similar to mine, we are the same level, so I can not help you, please understand;

Nine, the use of src.rpm:

Introduction to the file.src.rpm use method


PostScript:
fedora/redhat The package management in the introductory tutorial, I have written a lot of; there is still a lack of software through the source package to install my method and a summary of the document; I want to make up in the last two days, these two articles I have written before;

At my level, writing the Fedora Introductory tutorial is extremely laborious and can only be perfected and supplemented by 1.1 points; The tutorial I wrote was faced with a novice who knew nothing about Linux, and the majority of instances in the tutorial; I found that without an instance, a novice would look man; Certainly not a novice;

Often in the forum to see some of the brother's questions, although an explanation of the past can be dealt with, but want to make it easier for everyone, rather than write the system to get started tutorial, although the time spent a bit longer;

Linux rpm Command parameter usage [introduction and application]

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.