Linux rpm Command parameter usage [introduction and application]

Source: Internet
Author: User
Tags gpg

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

RPM Executes the installation package binary package (binary) as well as the source code package (source) in two ways. 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 description information for RPM packages [query package install package];-QF: finds which RPM package the specified file belongs to [query file];-va: verifies all RPM packages to find missing files [View Lost];-E: Delete Package

Rpm-q Samba//Whether the query program is installedrpm-ivh/media/cdrom/redhat/rpms/samba-3.0.10-1.4e.i386.rpm//Install and show progress by pathRPM-IVH--relocate/=/opt/gaim gaim-1.3.0-1.fc4.i386.rpm//Specifying the installation directoryRPM-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 //      rpm -qa | grep httpd  #[Search Specifies if RPM package is 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 Package]--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 & nbsp;  #[extract file]
rpm -ivh file.rpm  #[Install new Rpm]--install--verbose--hash RPM -IVH
rpm -uvh file.rpm    #[upgrade a rpm]--upgrade rpm -e file.rpm       #[Delete a RPM package]--erase

Common parameters:

Install/upgrade/erase options:

-I,--install install package (s)-V,--verbose provide more detailed output-h,-- Hash print hash marksas package installs  (GOOD&NBSP;WITH&NBSP;-V)-e, --erase                         erase  (uninstall)  package-U, --upgrade=<packagefile>+       Upgrade package (s)--replacepkge                      forcibly installs packages regardless of whether they have been installed--test                               installation test, does not actually install--nodeps                            ignore 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 filesin package-d,--docfiles list all documentation files-f,--file Query/veri FY 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 south-North from:linuxsir.org Summary:RPM is the Red Hat Package manager abbreviation, the original is Red Hat packages management, this article introduces RPM, and combined with examples to explain the RPM manual installation, Inquiries and other applications;

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 the file.tar.gz or file.tar.bz2 the source package make; The software installed by make install is invalid; 2. It is best to use the System Package management tools provided by the respective distribution, 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 tool, usage: Install or upgrade Fedora Core 4.0 package with apt+synaptic 4) Yum package online installation, upgrade, removal Tool; Usage: "Fedora/redhat in Line install update package, yum Chapter

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 manage the 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 belongs 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, dependency checks to see if there is a package due to incompatibility and disrupt the system;

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;

Third, a simple use of RPM , in addition to the Package manager, we can also be installed through the RPM command, is not all software 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 use RPM to install; a) initialize the RPM database; Check if an RPM package is installed with the RPM command, which is done through the RPM database; 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 queried, mostly there is a problem; II) RPM Package Management query function: command format

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

The query function of RPM 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 installed 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] 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. View of packages that are not installed: The prerequisite is that you have a. rpm file, that is, 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:

[[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]host 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 V, RPM Management Pack Manager supports 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; ix. usage of src.rpm: "Introduction to file.src.rpm use Method"

PostScript: Fedora/redhat Starter Tutorial in the package management chapter, 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]

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.