7.1 Three ways to install software packages 7.2 Introduction of rpm package 7.3 Usage of rpm tool 7.4 Usage of yum tool

7.1 Three ways to install packages

  • rpmtools

rpm (Redhat Package Manager) RPM package manager is a set of management programs that install the packages we need to Linux hosts in a database record manner. The rpm package is a pre-compiled and packaged file on the Linux machine, and it is very fast to install. But there is a disadvantage: the installation environment must be the same as or equivalent to the compilation time; there is mutual dependence between packages, so when installing or uninstalling packages, you need to install/uninstall the dependent packages first. It is necessary to uninstall this package.

  • yumtools

The yum command is an rpm-based package manager in Fedora, RedHat and SUSE. It enables system administrators to interact and automate finer and more detailed management of RPM packages. It can automatically download and install RPM packages from specified servers. Handle dependencies and install all dependent software packages at one time, without having to download and install tediously again and again.

  • source package

The source code distribution of Linux software refers to the distribution form that provides all the program source codes of the software, and requires users to compile and install executable binary codes by themselves. The advantage is that the configuration is flexible, some functions/modules can be removed or retained at will, and it is suitable for a variety of hardware/operating system platforms and compilation environments; the disadvantage is that it is more difficult.

7.2-7.3 rpm tools

rpm package introduction (preparation)

Mount the system installation disk image (mount to an empty directory, where the /mnt/ directory is not used, so directly mount it to the /mnt/ directory)

[root@cham3~]# df -h
文件系统        容量  已用  可用 已用% 挂载点
/dev/sda3        28G  1.3G   27G    5% /
devtmpfs        483M     0  483M    0% /dev
tmpfs           493M     0  493M    0% /dev/shm
tmpfs           493M  6.8M  486M    2% /run
tmpfs           493M     0  493M    0% /sys/fs/cgroup
/dev/sda1       197M  109M   88M   56% /boot
tmpfs            99M     0   99M    0% /run/user/0
[root@cham3~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
[root@cham3 mnt]# ls
CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7
EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7
EULA             isolinux  repodata  TRANS.TBL
[root@cham3 Packages]# # ls
yum-plugin-changelog-1.1.31-40.el7.noarch.rpm
yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
yum-plugin-tmprepo-1.1.31-40.el7.noarch.rpm
yum-plugin-verify-1.1.31-40.el7.noarch.rpm
yum-plugin-versionlock-1.1.31-40.el7.noarch.rpm
……
(rpm包格式:包名、版本号、发布版本号、平台)

The rpm package is stored under the Packages file!

rpm tool usage

install rpm package

Syntax:  rpm [options] [parameters]
Options:
-i:=install, install
-v: visualize
-h: display installation progress
Commonly used when installing an rpm package with options:
--force: force installation
--nodeps:=no dependent installation without dependencies (ignoring dependencies with other packages)

Note:  When installing a package with dependencies, you can install the package it depends on first and then install the target package (install the package with dependencies at the same time), or use the --force or --nodeps option to forcibly install (not recommended) .

 

 

 

7.4 yum tool usage

 

List all rpm packages

Syntax:  yum list

[root@cham3 Packages]# yum list 
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.aliyun.com
 * updates: mirrors.tuna.tsinghua.edu.cn
Installed Packages
NetworkManager-libnm.x86_64                1:1.4.0-12.el7              @anaconda
NetworkManager-team.x86_64                 1:1.4.0-12.el7              @anaconda
zsh.x86_64                                        5.0.2-25.el7_3.1                    updates  
zsh-html.x86_64                                   5.0.2-25.el7_3.1                    updates  
zziplib.i686                                      0.13.62-5.el7                       base     
zziplib.x86_64                                    0.13.62-5.el7                       base   
……
Exiting on Broken Pipe
注: 第一列是包名,第二列是版本号,第三列是库

Note:  "@" in the location of the library indicates that it is installed; "updates" indicates that it has been installed, there is a new version and needs to be upgraded; the others indicate rpm packages that can be installed but not yet installed.

  • yum configuration file
[root@cham3 Packages]# ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-fasttrack.repo
CentOS-CR.repo    CentOS-Media.repo      CentOS-Vault.repo
  • Information about the configuration file base
[root@cham3 Packages]## cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
……
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
……

Description:  This file contains the mirror address information of the base library where the rpm package is located!

search for rpm packages

Syntax:  yum search [keyword]

[root@cham3 Packages]# yum search vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
=================================================== N/S matched: vim ===================================================
protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptions
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements
vim-filesystem.x86_64 : VIM filesystem layout
vim-minimal.x86_64 : A minimal version of the VIM editor

  名称和简介匹配 only,使用“search all”试试。

 Note:  When you use this command to search, all the information containing 'vim' (keyword) will be listed, which is not accurate. In order to only search for related rpm packages, the following methods can be used:

[root@cham3 Packages]# yum list |grep 'vim'
vim-minimal.x86_64                          2:7.4.160-1.el7            @anaconda
protobuf-vim.x86_64                         2.5.0-8.el7                base     
vim-X11.x86_64                              2:7.4.160-2.el7            base     
vim-common.x86_64                           2:7.4.160-2.el7            base     
vim-enhanced.x86_64                         2:7.4.160-2.el7            base     
vim-filesystem.x86_64                       2:7.4.160-2.el7            base     
vim-minimal.x86_64                          2:7.4.160-2.el7            base     

Description:  grep means filtering.

 

List rpm package groups

Syntax:  yum grouplist

[root@cham3 Packages]# yum list |grep 'vim'
vim-minimal.x86_64                          2:7.4.160-1.el7            @anaconda
protobuf-vim.x86_64                         2.5.0-8.el7                base     
vim-X11.x86_64                              2:7.4.160-2.el7            base     
vim-common.x86_64                           2:7.4.160-2.el7            base     
vim-enhanced.x86_64                         2:7.4.160-2.el7            base     
vim-filesystem.x86_64                       2:7.4.160-2.el7            base     
vim-minimal.x86_64                          2:7.4.160-2.el7            base     
[root@cham3 Packages]# yum grouplist
已加载插件:fastestmirror
没有安装组信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
可用的环境分组:
   最小安装
   基础设施服务器
   计算节点
   文件及打印服务器
   基本网页服务器
   虚拟化主机
   带 GUI 的服务器
   GNOME 桌面
   KDE Plasma Workspaces
   开发及生成工作站
可用组:
   传统 UNIX 兼容性
   兼容性程序库
   图形管理工具
   安全性工具
   开发工具
   控制台互联网工具
   智能卡支持
   科学记数法支持
   系统管理
   系统管理工具
完成


[root@cham3 Packages]#  yum grouplist
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.aliyun.com
 * updates: mirrors.tuna.tsinghua.edu.cn
Available Environment Groups:
   Minimal Install
   Compute Node
……
Available Groups:
   Compatibility Libraries
   Console Internet Tools
……
Done

install rpm package

Syntax:  yum install [-y] [package name]
Description:  If the '-y' option is not added, it will be installed interactively with the user. The first is to list the rpm packages that need to be installed, and then the user will be asked if they need to be installed. Enter 'y' to install it, and enter 'n' to not install it. This is too troublesome, so add the '-y' option directly and omit the connection with the user. interaction between.

Install rpm package group

Syntax:  yum groupinstall [-y] [package group name]
If you don't know the group name, you can view it with yum grouplist (Note: You can only use the English name when installing).

uninstall rpm package

Syntax:  yum remove [-y] [package name]
Description:  The '-y' option is the same as the usage of install. It should be noted that when using this command to uninstall, all packages that the target file depends on will be deleted at the same time, so it is necessary to Use with caution!

upgrade rpm package

Syntax:  yum update [-y] [package name]
Description:  If no package name is added, all packages in the system and the system itself will be upgraded (use with caution, generally only when the system is just installed).
 

yum provides

The function of this command is to search its rpm package name by known command name.
usage:

[root@cham3 Packages]# yum provides "/*/vim"
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
base/7/x86_64/filelists_db                                                                       | 6.7 MB  00:00:08     
extras/7/x86_64/filelists_db                                                                     | 486 kB  00:00:00     
updates/7/x86_64/filelists_db                                                                    | 2.1 MB  00:00:03     
cmake-2.8.12.2-2.el7.x86_64 : Cross-platform make system
源    :base
匹配来源:
文件名    :/usr/share/cmake/editors/vim



2:docker-unit-test-1.12.6-48.git0fdc778.el7.centos.x86_64 : Automates deployment of containerized applications - for
                                                          : running unit tests
源    :extras
匹配来源:
文件名    :/var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/runc-79c3939053c870fbb4de5484d98640d5ba028ef4/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/containerd-fa8fb3d455e1baf716f3131581f0ed8b07c573a6/vendor/src/github.com/docker/docker/contrib/syntax/vim



2:docker-unit-test-1.12.6-55.gitc4618fb.el7.centos.x86_64 : Automates deployment of containerized applications - for
                                                          : running unit tests
源    :extras
匹配来源:
文件名    :/var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/runc-31a9f6e22729606814e9bcbcf9eeebc1887527cb/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/containerd-fa8fb3d455e1baf716f3131581f0ed8b07c573a6/vendor/src/github.com/docker/docker/contrib/syntax/vim



2:docker-unit-test-1.12.6-61.git85d7426.el7.centos.x86_64 : Automates deployment of containerized applications - for
                                                          : running unit tests
源    :extras
匹配来源:
文件名    :/var/lib/docker-unit-test/runc-c5d311627d39439c5b1cc35c67a51c9c6ccda648/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名    :/var/lib/docker-unit-test/containerd-fa8fb3d455e1baf716f3131581f0ed8b07c573a6/vendor/src/github.com/docker/docker/contrib/syntax/vim



git-1.8.3.1-11.el7.x86_64 : Fast Version Control System
源    :base
匹配来源:
文件名    :/usr/share/doc/git-1.8.3.1/contrib/vim



git-1.8.3.1-12.el7_4.x86_64 : Fast Version Control System
源    :updates
匹配来源:
文件名    :/usr/share/doc/git-1.8.3.1/contrib/vim



2:vim-common-7.4.160-2.el7.x86_64 : The common files needed by any version of the VIM editor
源    :base
匹配来源:
文件名    :/usr/share/vim



2:vim-enhanced-7.4.160-2.el7.x86_64 : A version of the VIM editor which includes recent enhancements
源    :base
匹配来源:
文件名    :/usr/bin/vim

Note:  Because the command location is uncertain, use '*' (wildcard) to represent its path when searching.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325473018&siteId=291194637