table of Contents
Linux software management tool --RPM
Rpm basic overview:
RPM stands for RPM Package Manager
an abbreviation, Red Hat developed for installation packages, upgrade and uninstall query mysql-5.6.40.tar.gz source package
Naming RPM packages
When we get a package when the need to have a basic understanding of the RPM package.
RPM包:bash-4.2.46-28.el7.x86_64.rpm
如:tree-1.6.0-10.el7.x86_64.rpm
tree- 1.6.0- 10. el7 .x86_64 .rpm
包名 版本 发布次数 centos7 包的架构(64位) 后缀 (如果是noarch 则32位 64位都兼容)
name: 软件包名称
version: 版本号, 主版本, 重大更新. 次版本, 子功能更新. 修订号, 修复bug
release: 发布版本 el6, el7 (hostnamectl)
arch: 系统平台, i386、x86_64(hostnamectl)
rpm package consists of:
安装释放的文件
软件包的元数据(版本,发布号,架构,描述,要求,更改日志等)
脚本:安装前执行的脚本和安装后的脚本
Linux in the package type
classification | installation | version |
---|---|---|
rpm package | Pre-compiled package, easy to install | Software version Low |
Source Package | Manually compile the package, install cumbersome | Software Version random |
Binary packages | Decompression can be used, simple installation | You can not modify the source code |
Note: Whether the source package, or binary package, may have dependencies during installation!
the system platform | Package Type | tool | Automatically resolve dependencies |
---|---|---|---|
RedHat/Centos | RPM | rpm | yum |
Ubuntu/Debian | DPKG | dpkg | apt |
RPM package acquisition path
1.RedHat光盘或官方网站 (通过挂载的方式访问)
2.RPM查询官网网站
3.Nginx软件官方网站
4.MySQL软件官方网站
When we first started learning rpm package, it is recommended to use a mirror local CentOS7, but the actual production environment, are acquired through networking rpm package way.
We first load the virtual machine image, then linux performed mount /dev/cdrom /mnt
at this time will /mnt/packages
see a lot of rpm package file directory, so long rpm package management can begin the tour.
[root@localhost ~]# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# ls /mnt/
CentOS_BuildTag Packages RPM-GPG-KEY-CentOS-Security-6
EULA RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Testing-6
GPL repodata TRANS.TBL
images RPM-GPG-KEY-CentOS-6
isolinux RPM-GPG-KEY-CentOS-Debug-6
[root@localhost ~]# ls /mnt/Packages/|head
Rpm package installation management
Using the RPM command to install the package, you need to know the following parameters:
-i: #安装
-v: #详细信息
-h: #安装进度
--test: #测试是否能够安装成功
--force: #强制重新安装
--nodeps: #忽略依赖关系
#安装软件包, 需要指定软件包绝对路径
[root@zls ~]# rpm -ivh /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm
[root@zls ~]# rpm -ivh /mnt/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm
#在软件包所在目录下可以不指定绝对路径
[root@zls ~]# cd /mnt/Packages/
[root@zls Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm
#仅测试,是否能安装成功
[root@oldboyedu Packages]# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm --test
Preparing... ################################# [100%]
#测试一个软件包是否能在该系统上安装
[root@zls ~]# rpm -ivh --test /mnt/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm
#如果软件包存在, 强制再次安装
[root@zls ~]# rpm -ivh --force /mnt/Packages/tree-1.5.3-3.el6.x86_64.rpm
#安装samba服务需要依赖其他组件, 使用--nodeps可重新强制安装,忽略依赖
[root@zls ~]# rpm -ivh --nodeps /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm
RPM package query commands
Use the rpm
command to query the installed rpm package, you need to know the following parameters:
rpm -q #查看指定软件包是否安装
rpm -qa #查看系统中已安装的所有RPM软件包列表
rpm -qi #查看指定软件的详细信息
rpm -ql #查询指定软件包所安装的目录、文件列表
rpm -qc #查询指定软件包的配置文件
rpm -qd #查询指定软件包的帮助文档
rpm -qf #查询文件或目录属于哪个RPM软件
rpm -q --scripts #查询rpm包安装前和安装后执行的脚本
#查询未安装的软件包信息
rpm -qip //查询未安装的rpm包详细信息
rpm -qlp //查询未安装的软件包会产生哪些文件
#查询vsftpd这个rpm包是否安装
[root@zls ~]# rpm -q vsftpd
#模糊查找系统已安装的rpm包
[root@zls ~]# rpm -qa |grep ftp
#查询vsftpd软件包的相关信息
[root@zls ~]# rpm -qi vsftpd
#查询rpm包所安装的文件
[root@zls ~]# rpm -ql vsftpd
#查询rpm包相关的配置文件
[root@zls ~]# rpm -qc vsftpd
#查询配置文件或命令来自于哪个rpm包
[root@zls ~]# rpm -qf /etc/vsftpd/vsftpd.conf
[root@zls ~]# rpm -qf /usr/sbin/vsftpd
//查询未安装的软件包会产生哪些文件
[root@zls ~]# rpm -qlp /mnt/Packages/samba-3.6.23-41.el6.x86_64.rpm
//查询未安装的软件包会产生哪些文件
[root@zls ~]# rpm -qip /mnt/Packages/samba-3.6.23-41.el6.x86_64.rpm
#以上查询只能查询已存在 已安装的包,如果没有安装,需要联网查询,但yum 安装包如未安装直接可查需安装包的详细信息
[root@db04 ~]# yum provides zip
[root@db04 ~]# yum provides */ifconfig
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base/filelists_db
| 6.4 MB 00:00
epel/filelists_db
| 7.9 MB 00:00
extras/filelists_db
| 24 kB 00:00
updates/filelists_db
| 3.6 MB 00:00
net-tools-1.60-114.el6.x86_64 : Basic networking tools
Repo : base
Matched from:
Filename : /sbin/ifconfig
RPM package upgrade command
-U 如果老版本不存在,就全新安装,如果存在有新版即升级
-f 老版本必须存在
如果有新版则升级, 软件升级不要跨操作系统主版本号
[root@zls ~]# rpm -Uvh /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm
RPM packages uninstall command
Need to first uninstall dependent packages uninstall package, if the package is dependent on the system must be, you can not uninstall this package, otherwise it will cause the system to crash.
//先查询, 然后卸载
[root@zls ~]# rpm -qa |grep sh
[root@zls ~]# rpm -e zsh