Table of contents
1. Introduction to software package management
1.1, software package classification
- Source code package (direct code)
a. Script installation package (an extra installation interface, but convenient) - Binary package (that is, the compiled source code file) (alias RPM package or system default package)
1.2. Source package
Advantages
• Open source, you can directly modify the source code
• Free to choose the required functions
• Compile and install, more stable and efficient
• Easy to uninstall (directly delete the source package installation directory)
Disadvantages
• There are many steps in the installation process, prone to spelling mistakes
• Compilation is too long Longer, the installation time is longer than the binary installation
• Because it is compiled and installed, once an error occurs during the installation process, it is difficult for novices to solve
1.3, RPM package
Advantages of binary packages
• The package management system is simple, and operations such as installation, upgrade, and uninstallation can be realized with only a few commands
• The installation speed is much faster than that of source packages (similar to the time of win)
Disadvantages
• After compiling, you cannot see the source code
• Function selection is not as flexible as source code
• Dependency (some software needs other software support, so only supporting software must be installed)
2. RPM package management - package naming and dependencies
2.1, RPM naming rules
For example package full name:httpd-2.2.15-15.e16.centos.1.i686.rpm
name | illustrate |
---|---|
httpd | package name |
2.2.15 | Software version |
15 | Number of software releases |
el6.centos | This version is suitable for installation in the two linux versions of el6 and centos |
i686 | Suitable for our 686 microcomputer platform (hardware platform) noarch- means any hardware platform can be installed |
rpm | rpm package extension |
2.2. RPM package dependencies
• Tree dependency: a->b->c
install a requires b, install b requires c, if we install c first, then install b, and finally install a. To uninstall, first uninstall a, then uninstall b, and finally uninstall c
• Circular dependency: a->b->c->a
installs software a, b, and c at the same time with commands
• Module dependency: all libraries ending with .so. numbers Dependency
Module dependency query website: www.rpmfind.net
3. RPM package management - installation, upgrade and uninstallation
3.1. Package full name and package name
Full package name : When the package to be operated is a package that is not installed, use the full package name. And pay attention to the path
package name : when operating an installed package, use the package name. is to search the database in /var/lib/rpm
3.2. RPM installation
Grammar :rpm-ivh 包全名
parameter | illustrate |
---|---|
-i(install) | Install |
-v(verbose) | show details |
-h(hash) | show progress |
–nodeps | Does not detect dependencies |
The picture above depends on the following two, you need to install the following packages first
3.3. RPM package upgrade
Syntax : rpm -Uvh package full name
parameter | illustrate |
---|---|
-U(upgrade) | upgrade |
3.4. Uninstall
Syntax : rpm -e package name
parameter | illustrate |
---|---|
-e (erase) | uninstall |
–nodeps | do not check dependencies |
4. RPM package management - query
4.1. Check whether it is installed
Command: rpm -q package name
parameter | illustrate |
---|---|
-q | query |
-a | all |
Command: rpm -qa
parameter | illustrate |
---|---|
-a | all |
4.2. Query the detailed information of the software package
Command: rpm qi package name
parameter | illustrate |
---|---|
-i | Querying Software Information (information) |
-p | Query the information of uninstalled packages (package) To inquire about uninstalled packages, you need to write the full name of the package |
4.3. Query the installation location of the files in the package
Command: rpm -ql package name
parameter | illustrate |
---|---|
-l | list |
-p | Query information about uninstalled packages |
For example: rpm -qlp zsh-4.3.11-4.el6.centos.2.x86_64.rpm
You can query the desired installation location of uninstalled software
4.4. Query which rpm package the system file belongs to
Command: rpm -qf system file name
parameter | illustrate |
---|---|
-f | Query which software package (file) the system file belongs to |
4.5. Query the dependencies of the software package
Command: rpm -qR package name
parameter | illustrate |
---|---|
-R | Query package dependencies (requires) |
-p | Query information about uninstalled packages (package) |
5. RPM package management - checksum file extraction
5.1, RPM package verification
After packaging, first record the characteristics, and then compare the current file with the original file when necessary, compare any changes, see if I made it, and judge whether the file has been modified. Command: rpm
- V installed package name
parameter | illustrate |
---|---|
-V : Verify the files in the specified RPM package (verify) |
S 5 T
As shown in the above picture , the details of the 8 pieces of information in the modified verification content are as follows:
parameter | illustrate |
---|---|
S | Whether the file size has changed |
M | Whether the type of the file or the permission (rwx) of the file has been modified |
5 | Whether the file MD5 checksum has changed (can be seen as whether the file content has been modified) |
D | In the device, does the slave code change |
L | Has the file path changed? |
U | Has the owner (owner) of the file changed |
G | Whether the group of the file has changed |
T | Whether the modification time of the file has changed |
The c in the above picture is the file type
parameter | file type |
---|---|
c | configuration file (config file) |
d | General documentation (documentation) |
g | 'ghost' files (ghost) are rare, that is, the file should not be included in this RPM package |
l | Authorization file (license file) |
r | Description file (read me) |
5.2. Extract files from RPM package
Extract the specified file in a package.
If a file is lost or damaged, just download a file in this package.
For example: rpm2cpio 包全名 | cpio -idv
; .
indicates the absolute path of the file
Command: cpio options < [file|device]
parameter | illustrate |
---|---|
-i | copy-in mode, restore |
-d | Automatically create a new directory when restoring |
-v | show restore process |