RPM is the abbreviation of red hat package manager, which means red hat package management, and as the name implies, it is the package management contributed by red hat; The mainstream distribution versions such as Fedora, Redhat, Mandriva, SuSE and YellowDog are adopted and developed on the basis of these versions; RPM packages all contain executable binary programs.
The application in the RPM package sometimes needs other specific versions of files besides the attached files to keep normal, which is the dependency of the software package.
First, the purpose of RPM package management
1, the software can be installed, deleted, upgraded and managed; Of course, it also supports online installation and upgrade of software;
2. Through RPM package management, you can know which files are included in the software package and which software package a file in the system belongs to;
3. You can query whether the software package in the system is installed and its version;
4. As a developer, you can package your program into an RPM package and then publish it.
5. Import, verification and signature publishing of package signatures GPG and MD5.
6. Check the dependency to see if there are any software packages that interfere with the system due to incompatibility;
Second, the right to use RPM.
The installation, deletion and update of RPM software can only be used with root permission; Any user can operate the query function; If ordinary users have the right to install the directory, they can also install it;
Third, a simple usage of rpm.
In addition to the package manager, we can also install it through the rpm command; Can all software packages be installed with rpm command? No, the end of the file is. Rpm suffix. Sometimes we find file.rpm on some websites, and we need to install it with rpm.
1) Initializes the rpm database.
Inquiring whether the rpm package is installed through the rpm command is also completed through the rpm database; So we often use the following two commands to initialize the rpm database.
[root @ localhost Bei nan]# rpm-initdb
[root @ localhost beinan]# rpm-rebuild db
Note: this will take a long time;
Note: These two parameters are very useful. Sometimes there is something wrong with the rpm system, and it is impossible to install the query, mostly because there is something wrong here.
Query function of RPM software package management
Command format
Rpm {-q |-query }[ Select Options] [Query Options]
The query function of RPM is extremely powerful, which is one of the most important functions. Some common examples, please refer to #man rpm for more details.
1. Query the installed software in the system;
1) Inquire about the installed software of the system;
Syntax: rpm -q software name
For example:
[root @ localhost Bei nan]# rpm-q gaim
gaim- 1.3.0- 1.fc4
-q is-query, which means "ask" in Chinese. This command indicates whether gaim is installed in the system; if so, information will be output; If it is not installed, the information that gaim is not installed is output; View all installed software packages in the system and add the -a parameter;
[root@localhost RPMS]# rpm -qa
If paging, add pipeline | and more commands;
[root @ local host RPMS]# rpm-QA | More
Find a software in all installed software packages, such as gaim can be extracted by grep;
[root @ localhost RPMS]# rpm-QA | grep gaim
The function of the above items is the same as the output result of rpm -q gaim;
2) Query which package the installation file belongs to;
Syntax rpm -qf file name
Note: You should indicate the absolute path of the file name.
For example:
[root @ localhost RPMS]# rpm-qf/usr/lib/libacl . la
libacl-devel-2.2.23-8
3) Query the installation location of the installed software package.
Syntax: rpm -ql software name or rpmquery -ql software name.
For example:
[root @ localhost RPMS]# rpm-QL lynx
[root @ localhost RPMS]# rpm query-QL lynx
4) Query the information of installed software packages.
Syntax format: rpm -qi software name
For example:
[root @ localhost RPMS]# rpm-qi lynx
5) Check the configuration file of the installed software;
Syntax format: rpm -qc software name
For example:
[root @ localhost RPMS]# rpm-QC lynx
6) Check the installation location of files with installed software:
Syntax format: rpm -qd software name
For example:
[root @ localhost RPMS]# rpm-qd lynx
7) Check the software packages and files on which the installed software depends;
Syntax format: rpm -qR software name
For example:
[root @ localhost Bei nan]# rpm-qR rpm-python
Query the installed software summary: for an installed software package, we can combine a series of parameters to use; Such as rpm-qil;; For example:
[root @ localhost RPMS]# rpm-qil lynx
2. View the uninstalled packages:
1) View the purpose and version of a software package;
Syntax: rpm-qpifile.rpm
For example:
[root @ local host rpms] # rpm-qpilynx-2.8.5-23.i386.rpm
2) Check the files contained in the software package;
Syntax: rpm-qplfile.rpm
For example:
[root @ local host rpms] # rpm-qpllynx-2.8.5-23.i386.rpm
3) Check the location of the software package document;
Syntax: rpm-qpdfile.rpm
For example:
[root @ local host rpms] # rpm-qpdlynx-2.8.5-23.i386.rpm
5) View the configuration file of the software package;
Syntax: rpm-qpcfile.rpm
For example:
[root @ local host rpms] # rpm-qpclynx-2.8.5-23.i386.rpm
4) Check the dependencies of the software package.
Syntax: rpm-qprfile.rpm
For example:
[root @ localhost archives]# rpm-qpR yumex _ 0.42-3.0 . fc4 _ no arch . rpm
/bin/bash
/usr/bin/python
Configuration (yumex) = 0.42-3.0.fc4
pygtk2
pygtk2-libglade
rpmlib(compressed filenames)& lt; = 3 . 0 . 4- 1 rpmlib(PayloadFilesHavePrefix)& lt; = 4.0- 1 user mode yum>= 2.3.2
3) Installation, upgrade and deletion of software packages;
1. Install and upgrade the rpm package;
[root @ localhost Bei nan]# rpm-VIH file . rpm
Note: This is used to install a new rpm.
[root @ localhost Bei nan]# rpm-Uvh file . rpm
Note: This is used to upgrade the rpm package;
If there are dependencies, please solve them. In fact, the package manager can solve the dependency well. Please see the introduction of the front bread manager. If the dependent package cannot be found in the package manager; That can only be solved by compiling the package on which it depends, or forcing installation; Grammatical structure:
[root @ localhost beinan]# rpm-IVH file . rpm-nodeps-force
[root @ localhost beinan]# rpm-Uvh file . rpm-nodeps-force
Example application:
[root @ local host rpms] # rpm-ivhlynx-2.8.5-23.i386.rpm
Prepared ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
1:lynx # # # # # # # # # # # # # # # # # # # # # # # # # # #[ 100%]
[root @ localhost RPMS]# rpm-IVH-replace pkgs lynx-2 . 8 . 5-23 . i386 . rpm
Prepared ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
1:lynx # # # # # # # # # # # # # # # # # # # # # # # # # # #[ 100%]
Note: the-replacepkgs parameter is installed again with the installed software; Sometimes it is not necessary;
Test installation parameter-test, which is used to check the dependency; Not a real device;
[root @ localhost RPMS]# rpm-IVH-test gaim- 1 . 3 . 0- 1 . fc 4 . i386 . rpm
Prepared ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
To downgrade from a new version to an old version, add the-oldpackage parameter.
[root @ localhost RPMS]# rpm-QA gaim
[root @ localhost RPMS]# rpm-Uvh-old package gaim- 1 . 3 . 0- 1 . fc 4 . i386 . rpm
Prepared ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
1:gaim # # # # # # # # # # # # # # # # # # # # # # # # # # # #[ 100%]
[root @ localhost RPMS]# rpm-QA gaim
gaim- 1.3.0- 1.fc4
Specify the installation directory of the software package: add the-relocate parameter;
The following example is to install gaim-1.3.0-1.fc4.i386.rpm in the /opt/gaim directory;
[root @ localhost RPMS]# rpm-IVH-relocate =/opt/gaim gaim- 1 . 3 . 0- 1 . fc 4 . i386 . rpm
Prepared ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
1:gaim # # # # # # # # # # # # # # # # # # # # # # # # # # # #[ 100%]
[root @ local host RPMS]# ls /opt/
Gaim
Specify the installation directory of the software package: add the -relocate parameter;
The following example is to install lynx-2.8.5-23.i386.rpm in the /opt/lynx directory;
[root @ localhost RPMS]# rpm-IVH-relocate =/opt/lynx-badreloc lynx-2 . 8 . 5-23 . i386 . rpm
Prepared ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
1:lynx # # # # # # # # # # # # # # # # # # # # # # # # # # #[ 100%]
How to call the program we installed in the specified directory? General executive programs are placed in the bin or sbin directory of the installation directory; Look at the following example; If there is an error output, make the corresponding link and use LN-S;
[root @ local host RPMS]# /opt/lynx/usr/bin/lynx
The configuration file /etc/lynx.cfg is not available.
[root @ localhost RPMS]# ln-s/opt/lynx/etc/lynx . CFG/etc/lynx . CFG
[root @ localhost RPMS]#/opt/lynx/usr/bin/lynx www.linuxsir.org
2. Delete the rpm package;
[root@localhost beinan]#rpm -e package name
For example, I want to delete the lynx package. The complete operation should be:
[root@localhost RPMS]# rpm -e lynx
If there is a dependency, you can also use-nodeps to ignore the dependency check and delete it. But try not to do so. It is best to use the package manager system-config-packages to remove or add software.
[root @ localhost beinan]# rpm-e lynx-nodeps
Fourth, import the signature:
[root @ localhost rpm]# rpm- Import signature file.
For example:
[root @ localhost fc40]# RPM-import RPM-GPG-KEY
[root @ localhost fc40]# RPM-import RPM-GPG-KEY-fedora
Fifth, the RPM management package manager supports network installation and query;
For example, we want to query and install software packages through the mirror image of Fedora Core 4.0;
Address: http://mirrors.kernel.org/fedora/core/4/i386/OS/fedora/rpms/
For example:
Command format: rpm parameter, http or ftp address of rpm package file.
# rpm-qpi http://mirrors . kernel . org/Fedora/core/4/i386/OS/Fedora/RPMS/gaim- 1 . 3 . 0- 1 . fc 4 . i386 . rpm
# rpm-IVH http://mirrors . kernel . org/Fedora/core/4/i386/OS/Fedora/RPMS/gaim- 1 . 3 . 0- 1 . fc 4 . i386 . rpm
Sixth, supplement the query of installed software packages;
[root@localhost RPMS]# updatedb
[root@localhost RPMS]# Locate the software name or file name.
Through updatedb, we can use locate to find out where some software is installed; Updatedb should be executed when the system is first installed, and it should be executed once every once in a while; So as to keep the installed software library up to date; Updatedb is owned by the slocate package; If you don't have this command, you have to install slocate.
For example:
[root@localhost RPMS]# Find gaim
7. Extract files from the rpm software package;
Command format: rpm2cpio file.rpm |cpio -div
For example:
[root @ localhost RPMS]# rpm 2 cpio gaim- 1 . 3 . 0- 1 . fc 4 . i386 . rpm | cpio-div
The extracted files are in usr and etc under the current operation directory;
In fact, extracting files is not as convenient as installing software in the specified installation directory; You can also extract files;
Specify the installation directory of the software package: add the -relocate parameter;
The following example is to install gaim-1.3.0-1.fc4.i386.rpm in the /opt/gaim directory;
[root @ localhost RPMS]# rpm-IVH-relocate =/opt/gaim gaim- 1 . 3 . 0- 1 . fc 4 . i386 . RP
Prepared ... # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # [100%]
1:gaim # # # # # # # # # # # # # # # # # # # # # # # # # # # #[ 100%]
[root @ localhost RPMS]# ls/opt/& lt;
Gaim
This can also be clear at a glance; All files of gaim are installed in /opt/gaim. We just need to back up the gaim directory and uninstall gaim. This is actually a small usage of extracting files;
Eight, the configuration file of RPM;
The configuration file of RPM package management is rpmrc, which we can find in our own system. For example, the rpmrc file in Fedora Core 4.0 is located;
[root @ localhost RPMS]# locate RPC
/usr/lib/rpm/rpmrc
/usr/lib/rpm/redhat/rpmrc
You can also view it through rpm-showrc.