Linux-beginner series 4_rpm-yum package management
1. Software package management
Default directory path after system software installation:
/user/local
/opt
These two directories are used to store the directory of the user's self-compiled and installed software. For the software installed through the source package, if the installation directory is not specified, it will generally be installed in the above directory.
Download tool using wget
wget 软件包的URL网址
wget 软件包的URL网址 -O /目录路径/新文件名
1. Software installation method: rpm command
rpm: R
edhat P
ackage M
manager Red Hat package management tool.
installation steps:
-
Download the package to the local system
-
Dependencies needed to install packages
-
Execute commands for software installation and deployment
//安装软件包 rpm -ivh 软件包 // 忽略报错,强制安装 rpm --force -ivh 软件包 //覆盖替换安装 rpm --replacepkgs -ivh 软件包
Common parameters
serial number | 参数 |
illustrate |
---|---|---|
1 | -i | Install software packages |
2 | -v | Detailed display of software installation process |
3 | -h | Print and display hash tag information when installing the data package |
4 | –force | Mandatory installer (overwrites existing programs and configuration files) |
5 | –replacepkgs | If the software package already exists, it will be reinstalled (do not overwrite the software configuration information) |
基本选项:
-
-i install (install), with -vh.
-
v means output verbose information
-
h indicates the output hash hash
-
-
-U upgrade (upgrade), can be used with -vh.
-
-e Erase.
- rpm -e httpd
Alibaba open source mirror station:
阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区:
https://developer.aliyun.com/mirror/
[root@bogon ~]# wget https://mirrors.aliyun.com/centos/7.9.2009/updates/x86_64/Packages/telnet-0.17-66.el7.x86_64.rpm
[root@bogon ~]# ls
[root@bogon ~]# rpm -ivh telnet-0.17-66.el7.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:telnet-1:0.17-66.el7 ################################# [100%]
[root@bogon ~]# rpm -Uvh telnet-0.17-66.el7.x86_64.rpm
准备中... ################################# [100%]
软件包 telnet-1:0.17-66.el7.x86_64 已经安装
[root@bogon ~]# rpm -e telnet
Package query:
选项参数 |
illustrate |
---|---|
-q | query, followed by the package name. |
-qa | All rpm-installed software are listed, which can be followed by the package name. |
-qi | Query Package Details |
-ql | Query packages related directories and files |
-qf | The absolute path of the Houjie file, check the rpm package associated with a certain file |
Example:
[root@bogon ~]# rpm -q telnet
telnet-0.17-66.el7.x86_64
[root@bogon ~]# telnet
telnet> quit
[root@bogon ~]# rpm -qa telnet
telnet-0.17-66.el7.x86_64
[root@bogon ~]# rpm -qi telnet
Name : telnet
Epoch : 1
Version : 0.17
[root@bogon ~]# rpm -ql telnet
/usr/bin/telnet
/usr/share/doc/telnet-0.17
/usr/share/doc/telnet-0.17/README
/usr/share/man/man1/telnet.1.gz
[root@bogon ~]# rpm -qf /usr/share/doc/telnet-0.17
telnet-0.17-66.el7.x86_64
[root@bogon ~]# rpm -q vim
未安装软件包 vim
[root@bogon ~]# rpm -qa | grep vim
vim-enhanced-7.4.160-4.el7.x86_64
vim-common-7.4.160-4.el7.x86_64
vim-minimal-7.4.160-4.el7.x86_64
vim-filesystem-7.4.160-4.el7.x86_64
[root@bogon ~]# rpm -q vim-enhanced
vim-enhanced-7.4.160-4.el7.x86_64
practise
安装nginx
On the Alibaba open source mirror station:
复制链接地址
https://mirrors.aliyun.com/centos/7.9.2009/infra/x86_64/infra-common/Packages/n/nginx-1.12.2-2.el7.x86_64.rpm?spm=a2c6h.13651111.0.0.43b52f7043Kusj&file=nginx-1.12.2-2.el7.x86_64.rpm
2. Software installation method: yum command
grammar:
yum [option] [command] [package_name]
[option] basic options:
-y
//yes,表示告诉yum直接执行,无须再确认
[command] subcommand:
Install the software install
yum -y install nginx
update software update
yum -y update nginx
Not followed by a package name will update all installed software
uninstall software remove
yum -y remove nginx
Practical
01 yum query subcommand
Package query
命令 |
illustrate |
---|---|
yum list | List all available software |
yum list httpd | List the software specified in the software inventory |
yum info nginx | Display properties of currently available nginx packages |
yum search httpd | Use the keyword httpd to search for available software |
software repository
yum's software package query update and installation depends on the software warehouse, the abbreviation in the command and configuration file repo
.
The query of yum is performed in the software warehouse, and it is recommended to use the following to query the locally installed software:rpm -qa | grep httpd
configuration file
Main configuration file:
/etc/yum.conf
/etc/yum/repos.d
**/etc/yum/repos.d:**
-
The directory where the software warehouse configuration files are stored
-
The first-level sub-files in the directory are valid for configuration files ending with .repo
-
The *.repo configuration file defines which software warehouse Yum searches for
-
yum clean all
Used to clean up the local cache (executed after replacing the warehouse configuration file) -
yum repolist
Used to list available repositories
installation steps:
View information about packages that are available for download
[root@bogon ~]# yum info
[root@bogon ~]# yum list
// 显示详细的软件包/软件包组信息
[root@bogon ~]# yum info httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bupt.edu.cn
* extras: mirrors.bupt.edu.cn
* updates: mirrors.bupt.edu.cn
可安装的软件包
名称 :httpd
架构 :x86_64
版本 :2.4.6
发布 :98.el7.centos.7
大小 :2.7 M
源 :updates/7/x86_64
简介 : Apache HTTP Server
网址 :http://httpd.apache.org/
协议 : ASL 2.0
描述 : The Apache HTTP Server is a powerful, efficient, and extensible
: web server.
[root@bogon ~]# yum list httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.bupt.edu.cn
* extras: mirrors.bupt.edu.cn
* updates: mirrors.bupt.edu.cn
可安装的软件包
httpd.x86_64 2.4.6-98.el7.centos.7 updates
View the specified software package (data) information
[root@bogon ~]# yum search 软件包
[root@bogon ~]# yum provides 软件包
Perform software installation and deployment
免交互方式进行软件安装
[root@bogon ~]# yum install -y 软件包/软件包组
覆盖重复安装指定软件程序
[root@bogon ~]# yum reinstall -y 软件包/软件包组
3. After the software package is installed, check:
1. Operation steps:
Use the rpm command to only view and confirm the rpm mode and yum
Check whether the specified software program is successfully installed
[root@bogon ~]# rpm -qa httpd
httpd-2.4.6-98.el7.centos.7.x86_64
View all data information of the specified software installation
[root@bogon ~]# rpm -ql httpd
View the configuration file generated after the specified software is installed
[root@bogon ~]# rpm -qc httpd
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
View which package the specified operation command or file data belongs to
[root@bogon ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@bogon ~]# which ssh
/usr/bin/ssh
[root@bogon ~]# rpm -qf /usr/bin/ssh
openssh-clients-7.4p1-22.el7_9.x86_64
//使用反引号查看
[root@bogon ~]# rpm -qf `which ssh`
openssh-clients-7.4p1-22.el7_9.x86_64
4. Software package uninstallation:
1. Operation steps:
Use yum command to realize software uninstallation
[root@bogon ~]# yum erase httpd
[root@bogon ~]# yum remove httpd
Use the rpm command to realize software uninstallation
[root@bogon ~]# rpm -e --nodeps httpd