Three ways to install packages
rpmtools
Similar to the exe under Windows, the installation path and file name are basically fixed.
yumtools
It belongs to the tool developed by Python, and the operation object is the rpm package; the biggest advantage of the yum tool is that it can download the required rpm package from the Internet, and then install it automatically.
source package
The source package needs to be compiled into an executable file with a compiler; the advantage is that the configuration is flexible, and the disadvantage is that it is difficult to install.
rpm package introduction
To mount the system installation image, first check whether the small CD-ROM icon in the lower right corner of VMware is lit. If not, click Connect to light up, and connect the CD to the Linux system.
Then mount the CD-ROM, mount it to the /mnt/ directory, then enter the /mnt/ directory to view some files and directories
Among them, there are many .rpm files in the packages directory, which is the rpm package
It can be divided into several parts from left to right: package name, version number, release version number, platform.
Usage of rpm tool
Install the rpm package, # rpm -ivh zsh-5.0.2-25.el7.x86_64.rpm
-i means install
-v for visualization
-h means show installation progress
--force means force installation
--nodeps means that when the rpm package to be installed depends on other packages, install this package even if other packages are not installed
Install the rpm package; #rpm -ivh zlib-1.2.7-13.el7.x86_64.rpm
Upgrade the rpm package, #rpm -Uvh zlib-1.2.7-13.el7.x86_64.rpm
Uninstall rpm, rpm -e package name #rpm -e zsh, it is normal to uninstall directly without showing
Query the installed package #rpm -qa, there are many installed packages that can be uninstalled
Query whether the specified package is installed, rpm -q [package name]
Query the specified package information, rpm -[qi] [package name]
List files installed by package, rpm [-ql] [package name]
Query which package is installed by absolute path, rpm [-qf] [absolute path]
special command backticks ``
The function of the backticks is to execute the commands in the backticks first, and then output them to the current command line for execution.
Usage of yum tool
List all available rpm packages, # yum list
yum configuration file; /etc/yum.repos.d
Information about the configuration file base (yum repository)
Search for rpm packages, yum search [related keywords]
This search is imprecise. For a more precise search, you can use this method
The command to install the package, yum install [-y] [package name], -y means no longer ask whether to install
List available groups, yum grouplist
Enter LANG=en to display in English
Install the rpm package group, yum groupinstall [-y] [package group name], you can use yum grouplist to view the group name and display it in English.
Uninstall the rpm package, yum remove [-y] [package name], when uninstalling, all packages that the target file depends on will be uninstalled at the same time.
To upgrade the rpm package, yum update [-y] [package name], if the package name is not added, all packages in the system and the system itself will be upgraded (usually used when the system is just installed)
yum provides the command to search for the rpm package name through known commands, /*/ wildcard, when the command path is uncertain, you can use the representative path
yum builds local warehouse
step:
1. Mount the image to the /mnt/ directory
2.cp -r /etc/yum.repos.d /etc/yum.repos.d.bak Copy files and directories to another location
3.vim /etc/yum/repos.d/dvd.repo //The content is as follows:
[dvd]
name=install dvd
baseurl = file: /// min
enable=1
gpgcheck=0
4.yum clean all
5.yum list
expand
1. yum retains installed packages
Set yum to retain downloaded rpm packages for later upgrades or reinstallations
Modify the /etc/yum.conf file
[main]
cachedir=/home/soft1/yumcache
keepcache = 1
debuglevel=2
cachedir is the place to set the download package, you can modify it to the location you want to store
When keepcashe is 1, it means that the downloaded rpm package has been saved
2. Build a local area network yum source
- Build Apache server or ftp server yum installation or binary package installation
- Prepare the RPM package and download the DVD1 and DVD2.iso of CentOS, extract all the contents in DVD1.iso, put it in the /var/www/html/centos-6 directory, and then extract the Packages from DVD2.iso The rpm packages in the directory are copied to the /var/html/centos-6/Packages directory, so that there are more than 6,000 rpm packages in /var/html/centos-6/Packages.
- Create yum repository
Prepare createrepo: yum -y install createrepo
Create repository: createrepo /var/www/html/centos-6/
After the creation is complete, some files will be generated under /var/www/html/centos-6/repodata.
- Use software sources
Try the software source on other centos machines to see if it works.
First modify the software source configuration file on the machine:
# cd /etc/yum.repos.d/
# mkdir bk
# mv *.repo bk/
# cp bk/CentOS-Base.repo ./
# vi CentOS-Base.repo
The CentOS-Base.repo file is modified as follows:
[base]
name=CentOS-$releasever - Base
baseurl=http://*.*.*.*/centos-6/
gpgcheck=1 (the line below 0 does not need to be set)
gpgkey=http:// /*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6
enabled=1
#released updates
#[updates]
#name=CentOS-$releasever -Updates
#baseurl=http:///* .*.*.*/centos-6/
#gpgcheck=1
#gpgkey=http:///*.*.*.*/centos-6/RPM-GPG-KEY-CentOS-6
#enabled = 1
After saving, you can use the software source of the LAN:
# yum update