In Linux, different software services need to be installed according to different needs. In Linux, software packages are classified into two types of source package installation and binary package installation.
1. Advantages and disadvantages:
Advantages: the installation process is simple and fast
Disadvantages: Unable to view source code, inflexible selection function, and dependency (need some pre-dependency packages in advance)
Second, dependence:
1. Tree dependency : If you install a, you need to install b in advance, and installing b requires c to be installed in advance.
Solution: install c → install b → install a
2. Ring dependency: If you install a, you need to install b in advance, install b needs to install c in advance, and install c needs to install a in advance.
Solution: install abc together
3. Model dependency : Some files are missing when installing a (generally function library, so. Number ending).
Solution: http://www.rpmfind.net/ Through this website combined with the system version you can query the name of the missing file belongs to the package.
3. Installation method (two methods: rpm installation method and yum installation method)
(Three, one, rpm installation method)
1. rpm installation
(A) rpm -ivh package name "i" means installation; "v" shows detailed information; "h" shows installation progress.
(B) service service name start | stop | restart | status service start | stop | restart | status
ps: There is a database (/ var / lib / rpm /) of RPM packages in the system, and it will be written to this database for the installed packages. Therefore, it is extremely convenient to query or uninstall the software (provided that it is installed by default during installation). And as shown in the figure below during installation, under normal circumstances it can be considered that the installation was successful.
(C) The default installation location
(D) rpm -ivh package name --force (reinstall the installed software again, generally used in case of missing individual configuration files, etc.)
rpm -ivh package name --test (do not install the package, just check its dependencies)
2. rpm query
rpm -qa (package name) Query installed packages.
rpm -q | grep abc query for packages with abc in the package name
rpm -qi package name to query detailed information of this software
rpm -qip package name to query information about uninstalled packages
rpm -ql package name to query the files and directories of files contained in the installed software
rpm -qlp package name to query files and directories of files that are not installed in the software
rpm -qf file name to query which RPM installation package the file belongs to (must be a file created automatically when the RPM package is installed, not a file created manually)
3. rpm upgrade
rpm -Fvh package name Upgrade installation (if the old version is installed, upgrade to the new version; if it is not installed, it will not be installed)
rpm -Uvh package name Upgrade installation (if the old version is installed, upgrade to the new version; if not, install directly)
4. rpm uninstall software
rpm -e package name
rpm -e package name --nodeps does not detect dependencies, force to uninstall directly
ps: Dependency detection is also required when uninstalling, but the order of uninstalling dependent packages is the reverse of the order of installation. It is not recommended to use the --nodeps option to uninstall directly.
5. Verification
rpm -V Installed package name to verify the files in the specified package
rpm -Vf system file name to verify whether a system file has been modified
If the software package has been modified, the following figure will appear (example)
(A) . Indicates that the verified attributes are consistent; S indicates that the file size is modified; M indicates that the file type or permissions are modified; 5 indicates that the file content is modified; D indicates that the device's primary and secondary codes are modified; L indicates that the path is modified; U means all modified; G means the group to be modified; T means the file modification time is changed;
There will be an original value to compare in the above comparison.
(B) The c position also has the following types:
c means configuration file; d means ordinary file; g means ghost file (meaning that this file should not be in this software package, it is rare); l means license file; r means readme file
(C) Finally, the path of the changed file
6. Digital certificate
It is recorded above that there will be original values in the software package for the file to compare, so that you can find whether the file has been modified to troubleshoot the problem. But how to ensure the accuracy of the original value, digital certificates are used here.
(1) Principle of digital certificate:
(A) The original public key file must be found for installation
(B) When installing the RPM package, the certificate information in it will be extracted and compared with the original certificate installed
(C) If it passes the verification, the installation of the software package is allowed; if it fails, the installation is prohibited and warning
(2) Certificate storage location:
Stored on CD
/ Etc / pki / rpm-gpg in the system
(3) Import method:
rpm --import /etc/pki/rpm-gpg/ RPM-GPG-KEY-CentOS-7
(4) Query the installed digital certificate
rpm -qa | grep gpg-pubkey
(Three, two, yum installation)
1. Configuration file of yum
The yum configuration file exists in the /etc/yum.repos.d/ directory, and the file extension is .repo for the yum configuration file. (CentOS-Base.repo uses this file by default). Use vim editor to open and view .
The parameters in yum are as follows
[base] The container name. (Be careful not to forget [])
name container description (can be filled in at will, but it is recommended to write a description, not a random one)
mirrorlist mirror URL
The server address of the baseurl yum source. The default is the official yum source server of CentOS. Can be modified to the domestic yum source server.
enabled Whether this container is enabled. (Not written by default or enabled = 1 means enabled; enabled = 0 means not enabled)
Whether gpgcheck digital certificate is enabled (gpgcheck = 1 means digital certificate is enabled; gpgcheck = 0 means digital certificate is not enabled)
Where to save the public key file of the gpgkey digital certificate.
2. Build a local yum source
Content of local yum source configuration file:
3. The yum command
yum list Query the packages that can be installed on the yum source server
yum list package name query whether contains a certain package
yum search keyword search for packages related to keywords
yum info package name query package details
yum -y install package name to install the package (-y is to automatically answer yes)
yum -y update package name upgrade package
yum -y update upgrade all packages installed by the system
yum -y remove package name to uninstall the package (uninstalling the package will check the dependencies and uninstall the dependent packages, but this dependent package may be used by other software. Use with caution)