1. Install the software with rpm
When using RPM installation, there are three main options, namely-i option,-q option,-v option, these three options have a number of sub-options, we will be sub-bar to describe these options.
1.-E Options
Before we introduce the installation, we need to introduce the uninstall command so that we can experiment with a package with the following commands:
rpm -e ftp
2.-i Options
-I. Option
This one option, followed by the path of the installation package, is to install the software, we ftp for example, the CD-ROM is mounted under/media:
mount /dev/cdrom /media
The installation commands are as follows:
rpm -i /media/Package/ftp-0.17-54.el6.x86_64.rpm
With the-I option does not display any installation information and you do not even know if there is a successful installation.
-V option
The-v option is to display the details of the installation, which is a sub-option for-I, which can only be used with-I, and will have no meaning, for example:
rpm -iv /media/Package/ftp-0.17-54.el6.x86_64.rpm
If the information shown here is not detailed enough, you can add a-v option.
-H option
The effect of the-H option is to display the installation percentage, for example
rpm -ih /media/Package/ftp-0.17-54.el6.x86_64.rpm
So the most classic installation option is-IVH, which is the most common option in our software installation process.
--test Options
The purpose of the-test option is to test the installation, not really install the software, we can test whether the current environment can be installed, for example:
rpm -i --test /media/Package/ftp-0.17-54.el6.x86_64.rpm
--nodeps Options
The--nodeps option is to ignore dependencies when installing the software, some software needs to install other software when installing, otherwise cannot install successfully, if use--nodeps can ignore these dependencies to install, for example:
rpm -i --nodeps --test /media/Packages/samba4-4.2.10-9.el6.x86_64.rpm
--replacepkgs Options
Repeatedly installs packages that have already been installed, overwriting files. For example:
--replacefiles Options
Some of the files that will install the package conflict with other installed package files, and you can continue with the installation without overwriting the files. For example
--oldpackages Options
A new version is installed and the old version is now installed
--force Options
Equivalent to--replacepkgs,--replacefiles, and--oldpackage. For example
rpm -i --force /media/Packages/tree-1.5.3-3.el6.x86_64.rpm
--noscripts Options
The script in the RPM package is not executed during installation. In some packages, there are scripts that, when the package is installed, execute the scripts themselves and use this option to not execute the scripts that these packages carry during the installation. For example:
First, check to see if the Apache user exists:
id apache
Installing httpd may not be successful because of some dependencies, so we add the--nodeps option command as follows:
rpm -ih --nodeps /media/Packages/httpd-2.4.6-80.el7.centos.x86_64.rpm
Now check to see if the user Apache exists;
id apache
We can find that after installing httpd, there is a user named Apache, we did not manually to create him, why does it appear? Because the script to create Apache users was executed during the httpd installation, there will be no script execution if we use the--noscripts option.
3.-q Options
The-Q option is to view information about the current installation package, similar to the-I option, and has many sub-options.
The single-to-Q option is to view the description of the installed package, and if the package is not installed, the prompt is not installed, for example:
-A option
List all installed packages, we use the pipeline to calculate how many packages are installed.
Rpm-qa |wc-l
-F option
To see which installation package the specified file originates from, the-F followed by the absolute path of the file. For example:
rpm -qf /etc/rc.d/init.d/function
-I. Option
This option can show the package details, not the demo.
- P option
Query the information of the RPM package that is not installed, the data of the query information comes from the RPM package, and the RPM path should be added after-p, for example
rpm -qi -p /media/Packages/ftp-0.17-54.el6.x86_64.rpm
--provides Options
Query what capabilities a package provides
rpm -q --provides httpd
--whatprovides Options
Query which RPM package is provided by a capability, for example
rpm -q --whatprovides webserver
--whatrequires Options
Query which RPM package is dependent on a capability, for example:
rpm -q --whatrequires webserver
--changelog Options
Query the update log, this option is not very useful, do not introduce too much.
-L
List all files provided by the package
-C
List the configuration files provided by the package
-D
List the documentation files provided by the package
These three options list the files provided by the package, but only the files provided by the installed software are listed. For example
rpm -q -l httpdrpm -q -c httpdrpm -q -d httpd
This lists all the files, profiles, and document files provided by httpd.
3.-V option
The-v option is used for package verification, and if the result has the following result, the content is modified.
S file Size differs
M Mode differs (includes permissions and file type)
5 Digest (formerly MD5 sum) differs
D Device Major/minor number mismatch
L Readlink (2) path mismatch
U User ownership differs
G Group ownership differs
T mtimediffers
P capabilities differ
For example:
rpm -V httpd
Nothing is displayed at this point, because no files have been modified for httpd, and now I'm adding 123 to the first line in httpd.conf.
Execute the above command again, the result is as follows:
The description of the package has been modified, specifically modified what things, you can refer to the above.
2. Install with Yum
When we use RPM to install the software, we will find that we install the package may depend on other files, these files belong to those we do not install the package, when we first install the other packages, these packages may also rely on other files, such layers of recursion, will make our installation process becomes extremely cumbersome, And some of the file names and package names are related, some are not, at this point we do not know where these packages come from, it will be a dilemma, and Yum is the front end of the RPM program, you can solve the dependencies of the package. Packages can be located between multiple libraries.
To use Yum, the first thing to do is to configure the Yum repository, the Yum repository file in/etc/yum.repos
. d folder, and then named . Repo, can be anything, but be sure to end with repo, the content format is as follows:
[candvd]name=Canbaseurl=file:///mediaenabled=1gpgcheck=0gpgkey=file:///media/RPM-GPG-KEY-CentOS-6
where [Candvd] is the warehouse ID, can be anything, name is the warehouse name, or anything, BaseURL is the path that the warehouse points to, if it is a file is file://followed the path of the file, if it is a link, that is to follow the link such as:/HTTP 172.18.0.1/centos/$releasever, the path or link must be to the directory containing Repodata, as above, the path is the path of the mounted disc/media, and under/media has a directory repodata, then the path is here. Enable is whether the warehouse is enabled, 1 is enabled, 0 is not enabled, Gpgcheck represents whether GPG authentication is enabled, 1 is enabled, and 0 is not enabled. Gpgkey represents the public key, GPG is a data encryption and digital signature method, to ensure the reliability of data transmission, CentOS CD has Gpgkey, we can use the following command to import the public key:
rpm --import /media/RPM-GPG-KEY-CentOS-6
You can then see whether the import was successful by using the following command:
rpm -qa "gpg-pubkey*"
The results are as follows:
After we have configured a warehouse, we need to use two commands to make the warehouse effective, the command is as follows:
Emptying the warehouse cache
yum clean all
Rebuilding the warehouse cache
yum makecache
In fact, we do not need to rebuild the Yum repository, and when we execute any of the Yum commands, when there is no repository cache, the system rebuilds the repository for us.
We can use the following command to view our warehouses:
yum repolist
You can see that there are now three warehouses, the ID is Base,candvd,epel, two are my first configuration of the network warehouse, the use of the classroom server provided by the Yum source, there is a local CD source, the three Yum source to provide a total of 25,767 packages.
Repolist also has three options, the first is enabled is also the system default, display the active warehouse, we will disable the base, and then view, you can find that the base warehouse is not displayed.
The second option is disabled, which shows the disabled warehouses:
The third one is all, showing all warehouses:
The Yum installation method is yum install + package name, or you can install multiple packages at the same time, plus-y is a non-interactive installation. The command is as follows:
yum install -y 包1 包2 ...包n
The Yum list can list all the packages provided by the repository and the system, which is equivalent to the Yum list all, which can be used to access the warehouse ID, and if the last column is a warehouse ID, the package is not installed in that warehouse, and if the @ Plus warehouse ID is displayed, then the package is installed. and belongs to the warehouse; if it is @anaconda the package is installed and installed from the operating system Setup anaconda.
The Yum list can be followed by the option, all is to list all packages, the default is all, the update is to list all the updatable packages, then installed is to list all installed packages, if the last column is @repoid indicates that the package is installed from the specified warehouse, If installed indicates that the package was manually installed by the RPM command, for example:
The Reinstall option allows you to reinstall the specified package name with the following command:
yum reinstall -y +包名
Update option that updates the specified package, such as:
yum update tree
The Remove option to unload the specified package, such as:
yum remove tree -y
Info option to view detailed information about the specified package, such as:
yum info tree
The provides option, the ability to search for a file from which package, can be a package that is not installed, such as:
yum provides "*/rz"
The search option, which blurs the search, searches for descriptions of packages and packages, such as:
yum search ftp
The Deplist option to list all packages on which the specified package depends, for example:
yum deplist tree
History option to list all Yum histories, such as:
Info plus the history number, you can see the details of a historical piece, such as:
yum history info 12
History redo to redo one of the histories, and the history undo undo one.
Yum [local]install/path/*.rpm can install the local package.
Yum Package Group:
Yum Grouplist lists all the package group names
Yum GroupInfo ' package group name ' to see which package is included in the specified package group
Yum Groupinstall ' package group name '
Yum Groupupdate ' package group name '
Yum Groupremove ' package group name '
3. Installation with DNF
DNF is a newer installation command, CENTOS6 does not support DNF, you can install DNF,DNF on Centos7 more quickly than Yum, but almost all Yum options DNF are supported, and DNF shares the database with Yum, with the following installation commands:
yum install -y dnf
Install DNF First is to have the source of DNF, can be obtained from the network, when the installation of DNF, will find that DNF use of the warehouse is Yum's warehouse.
After installing the DNF, we can install the software using DNF like Yum, for example:
dnf install -y tree
Install the software under Linux