一rpm包管理器

(一)rpm的介绍

rpm不仅是文件的后缀,也是一个工具,外部命令,程序包管理器

功能:将编译好的应用程序的各组成文件打包一个或几个程序包文件,从而方便快捷地实现程序包的安装、卸载、查询、升级和校验等管理操作。

[root@centos71 ~]# which   rpm
/usr/bin/rpm

(二)包文件组成 (每个包独有)

1RPM包内的文件

2RPM的元数据,如名称,版本,依赖性,描述等。打包但没有压缩。

3安装或卸载时运行的脚本。

rpm所谓的安装大部分是解压包,并且复制到设置好的路径。

要对复制的目录或者文件设置好相应的属性,比如文件的所有者和所属组。

如果系统没有这个账号那么就要编写脚本创建出来了。这是安装前的脚本。

系统中安装的软件是以rpm方式安装的。

安装好了之后那么Linux的数据库就会记录以rpm这种方式安装的所有包的信息。

可以查询在系统中安装了哪些rpm包,哪时候安装的,生成了哪些文件,在哪些目录里面。

从光盘里面拷贝一个文件

[root@centos71 ~]# cd  /mnt/Packages/
[root@centos71 Packages]# cp tree-1.6.0-10.el7.x86_64.rpm /app/
[root@centos71 Packages]# cd /app/
[root@centos71 app]# ls
tree-1.6.0-10.el7.x86_64.rpm

(三)数据库(公共):/var/lib/rpm

程序包名称及版本
依赖关系
功能说明
包安装后生成的各文件路径及校验码信息

/var/lib/rpm/下面的文件是很重要的,为了安全可以做备份。

[root@centos71 app]# cd  /var/lib/rpm/
[root@centos71 rpm]# ls
Basenames Conflictname __db.001 __db.002 __db.003 Dirnames Group Installtid Name Obsoletename Packages Providename Requirename Sha1header Sigmd5 Triggername
[root@centos71 rpm]# ll
total 93708
-rw-r--r--. 1 root root 4247552 Jan 10 17:13 Basenames
-rw-r--r--. 1 root root 16384 Jan 10 12:08 Conflictname
-rw-r--r--. 1 root root 270336 Jan 10 17:13 __db.001
-rw-r--r--. 1 root root 81920 Jan 10 17:13 __db.002
-rw-r--r--. 1 root root 1318912 Jan 10 17:13 __db.003
-rw-r--r--. 1 root root 1146880 Jan 10 17:13 Dirnames
-rw-r--r--. 1 root root 32768 Jan 10 17:13 Group
-rw-r--r--. 1 root root 20480 Jan 10 17:13 Installtid
-rw-r--r--. 1 root root 69632 Jan 10 17:13 Name
-rw-r--r--. 1 root root 32768 Jan 10 12:08 Obsoletename
-rw-r--r--. 1 root root 85598208 Jan 10 17:13 Packages
-rw-r--r--. 1 root root 2486272 Jan 10 17:13 Providename
-rw-r--r--. 1 root root 544768 Jan 10 17:13 Requirename
-rw-r--r--. 1 root root 131072 Jan 10 17:13 Sha1header
-rw-r--r--. 1 root root 73728 Jan 10 17:13 Sigmd5
-rw-r--r--. 1 root root 8192 Jan 10 12:05 Triggername

在6上查看

[root@centos65 ~]# ls  /var/lib/rpm/
Basenames Dirnames Group Name Packages Provideversion Requirename Sha1header Triggername
Conflictname Filedigests Installtid Obsoletename Providename Pubkeys Requireversion Sigmd5
[root@centos65 ~]# ls /var/lib/rpm/ -lh
total 46M
-rw-r--r--. 1 root root 2.7M Mar 3 17:51 Basenames
-rw-r--r--. 1 root root 12K Jan 23 18:38 Conflictname
-rw-r--r--. 1 root root 908K Mar 3 17:51 Dirnames
-rw-r--r--. 1 root root 4.6M Mar 3 17:51 Filedigests
-rw-r--r--. 1 root root 16K Mar 3 17:51 Group
-rw-r--r--. 1 root root 16K Mar 3 17:51 Installtid
-rw-r--r--. 1 root root 24K Mar 3 17:51 Name
-rw-r--r--. 1 root root 12K Jan 23 18:45 Obsoletename
-rw-r--r--. 1 root root 39M Mar 3 17:51 Packages
-rw-r--r--. 1 root root 1.3M Mar 3 17:51 Providename
-rw-r--r--. 1 root root 640K Mar 3 17:51 Provideversion
-rw-r--r--. 1 root root 12K Jan 23 16:50 Pubkeys
-rw-r--r--. 1 root root 212K Mar 3 17:51 Requirename
-rw-r--r--. 1 root root 144K Mar 3 17:51 Requireversion
-rw-r--r--. 1 root root 80K Mar 3 17:51 Sha1header
-rw-r--r--. 1 root root 44K Mar 3 17:51 Sigmd5
-rw-r--r--. 1 root root 12K Jan 23 19:10 Triggername

(四)程序包的来源

(1) 系统发版的光盘或官方的服务器

CentOS镜像:
https://www.centos.org/download/
http://mirrors.aliyun.com
http://mirrors.sohu.com
http://mirrors.163.com

(2) 项目官方站点

(3) 第三方组织

Fedora-EPEL:Extra Packages for Enterprise Linux

都是经过红帽测试过的,可以放心使用。

https://mirrors.aliyun.com/epel/

[root@centos71 rpm]# cd
[root@centos71 ~]# wget https://mirrors.aliyun.com/epel/7/x86_64/Packages/s/sl-5.02-1.el7.x86_64.rpm
--2019-01-10 23:43:01-- https://mirrors.aliyun.com/epel/7/x86_64/Packages/s/sl-5.02-1.el7.x86_64.rpm
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 183.136.135.213, 183.136.135.223, 183.136.135.221, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|183.136.135.213|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14244 (14K) [application/x-redhat-package-manager]
Saving to: ‘sl-5.02-1.el7.x86_64.rpm’ 100%[==================================================================================================================================================>] 14,244 --.-K/s in 0.05s 2019-01-10 23:43:07 (284 KB/s) - ‘sl-5.02-1.el7.x86_64.rpm’ saved [14244/14244] [root@centos71 ~]# ls
anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg Music oCam.exe Pictures Public sl-5.02-1.el7.x86_64.rpm Templates Videos
[root@centos71 ~]# rpm -i sl-5.02-1.el7.x86_64.rpm
warning: sl-5.02-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY [root@centos71 ~]# ls
anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg Music oCam.exe Pictures Public sl-5.02-1.el7.x86_64.rpm Templates Videos
[root@centos71 ~]# sl
[root@centos65 ~]# wget    https://mirrors.aliyun.com/epel/7/x86_64/Packages/s/sl-5.02-1.el7.x86_64.rpm
--2019-03-14 19:43:13-- https://mirrors.aliyun.com/epel/7/x86_64/Packages/s/sl-5.02-1.el7.x86_64.rpm
Resolving mirrors.aliyun.com... 119.96.206.233, 119.96.206.228, 119.96.206.230, ...
Connecting to mirrors.aliyun.com|119.96.206.233|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14244 (14K) [application/x-redhat-package-manager]
Saving to: “sl-5.02-1.el7.x86_64.rpm” 100%[============================================================================================>] 14,244 --.-K/s in 0.07s 2019-03-14 19:43:19 (200 KB/s) - “sl-5.02-1.el7.x86_64.rpm” saved [14244/14244] [root@centos65 ~]# sl
-bash: sl: command not found
[root@centos65 ~]# ls
1Gb.file a anaconda-ks.cfg bin blkid f1 f2 f3 install.log install.log.syslog restore_iptables.sh sl-5.02-1.el7.x86_64.rpm
[root@centos65 ~]# yum install sl
Loaded plugins: fastestmirror, security
Setting up Install Process
Determining fastest mirrors
ali-centos | 3.7 kB 00:00
base | 4.0 kB 00:00 ...
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:06
Resolving Dependencies
--> Running transaction check
---> Package sl.x86_64 0:5.02-1.el6 will be installed
--> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================
Package Arch Version Repository Size
======================================================================================================================================
Installing:
sl x86_64 5.02-1.el6 epel 13 k Transaction Summary
======================================================================================================================================
Install 1 Package(s) Total download size: 13 k
Installed size: 15 k
Is this ok [y/N]: y
Downloading Packages:
sl-5.02-1.el6.x86_64.rpm | 13 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : sl-5.02-1.el6.x86_64 1/1
Verifying : sl-5.02-1.el6.x86_64 1/1 Installed:
sl.x86_64 0:5.02-1.el6 Complete!

输入sl就会出现下面的图片

Rpmforge:RHEL推荐,包很全
搜索引擎:
http://pkgs.org
http://rpmfind.net
http://rpm.pbone.net
https://sourceforge.net/

注意搜索出来的包可能会有问题。

(4) 自己制作。注意:第三方包建议要检查其合法性,来源合法性,程序包的完整性

二rpm包管理

CentOS系统上使用rpm命令管理程序包:安装、卸载、升级、查询、校验、数据库维护

(一)使用rpm命令安装包

rpm {-i|--install} [install-options]    PACKAGE_FILE…

-v: verbose显示详细信息

-vv:显示更详细信息,可以在出现报错的时候进行排错的时候使用

-h: 以#显示程序包管理执行进度

rpm -ivh PACKAGE_FILE ..

注意安装包的时候要写明路径在哪

[root@centos71 app]# rpm   -ivvh   tree-1.6.0-10.el7.x86_64.rpm
D: ============== tree-1.6.0-10.el7.x86_64.rpm
D: loading keyring from pubkeys in /var/lib/rpm/pubkeys/*.key
D: couldn't find any keys in /var/lib/rpm/pubkeys/*.key
D: loading keyring from rpmdb
D: opening db environment /var/lib/rpm cdb:0x401
D: opening db index /var/lib/rpm/Packages 0x400 mode=0x0
D: locked db index /var/lib/rpm/Packages
D: opening db index /var/lib/rpm/Name 0x400 mode=0x0
D: Expected size: 47508 = lead(96)+sigs(1284)+pad(4)+data(46124)
D: Actual size: 47508
warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: added binary package [0]
D: found 0 source and 1 binary packages
D: opening db index /var/lib/rpm/Conflictname 0x400 mode=0x0
D: ========== +++ tree-1.6.0-10.el7 x86_64/linux 0x2
D: opening db index /var/lib/rpm/Providename 0x400 mode=0x0
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libc.so.6()(64bit) YES (db provides)
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libc.so.6(GLIBC_2.14)(64bit) YES (db provides)
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libc.so.6(GLIBC_2.2.5)(64bit) YES (db provides)
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libc.so.6(GLIBC_2.3)(64bit) YES (db provides)
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libc.so.6(GLIBC_2.3.4)(64bit) YES (db provides)
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libc.so.6(GLIBC_2.4)(64bit) YES (db provides)
D: Requires: rpmlib(CompressedFileNames) <= 3.0.4-1 YES (rpmlib provides)
D: Requires: rpmlib(FileDigests) <= 4.6.0-1 YES (rpmlib provides)
D: Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 YES (rpmlib provides)
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: rtld(GNU_HASH) YES (db provides)
D: Requires: rpmlib(PayloadIsXz) <= 5.2-1 YES (rpmlib provides)
D: opening db index /var/lib/rpm/Obsoletename 0x400 mode=0x0
D: ========== recording tsort relations
D: ========== tsorting packages (order, #predecessors, #succesors, depth)
D: 0 0 0 1 +tree-1.6.0-10.el7.x86_64
D: installing binary packages
D: closed db index /var/lib/rpm/Obsoletename
D: closed db index /var/lib/rpm/Conflictname
D: closed db index /var/lib/rpm/Providename
D: closed db index /var/lib/rpm/Name
D: closed db index /var/lib/rpm/Packages
D: closed db environment /var/lib/rpm
D: opening db environment /var/lib/rpm cdb:0x401
D: opening db index /var/lib/rpm/Packages (none) mode=0x42
D: sanity checking 1 elements
D: opening db index /var/lib/rpm/Name (none) mode=0x42
D: read h# 1363 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: read h# 1363 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: computing 5 file fingerprints
D: opening db index /var/lib/rpm/Basenames (none) mode=0x42
D: opening db index /var/lib/rpm/Group (none) mode=0x42
D: opening db index /var/lib/rpm/Requirename (none) mode=0x42
D: opening db index /var/lib/rpm/Providename (none) mode=0x42
D: opening db index /var/lib/rpm/Conflictname (none) mode=0x42
D: opening db index /var/lib/rpm/Obsoletename (none) mode=0x42
D: opening db index /var/lib/rpm/Triggername (none) mode=0x42
D: opening db index /var/lib/rpm/Dirnames (none) mode=0x42
D: opening db index /var/lib/rpm/Installtid (none) mode=0x42
D: opening db index /var/lib/rpm/Sigmd5 (none) mode=0x42
D: opening db index /var/lib/rpm/Sha1header (none) mode=0x42
Preparing... D: computing file dispositions
D: 0x00000802 4096 12157150 26087632 /
################################# [100%]
package tree-1.6.0-10.el7.x86_64 is already installed
D: closed db index /var/lib/rpm/Sha1header
D: closed db index /var/lib/rpm/Sigmd5
D: closed db index /var/lib/rpm/Installtid
D: closed db index /var/lib/rpm/Dirnames
D: closed db index /var/lib/rpm/Triggername
D: closed db index /var/lib/rpm/Obsoletename
D: closed db index /var/lib/rpm/Conflictname
D: closed db index /var/lib/rpm/Providename
D: closed db index /var/lib/rpm/Requirename
D: closed db index /var/lib/rpm/Group
D: closed db index /var/lib/rpm/Basenames
D: closed db index /var/lib/rpm/Name
D: closed db index /var/lib/rpm/Packages
D: closed db environment /var/lib/rpm

(二)rpm包安装的相关设置

[install-options]

--test: 测试安装,但不真正执行安装,即dry run模式

--nodeps:忽略依赖关系

--replacepkgs | replacefiles

--nosignature: 不检查来源合法性

--nodigest:不检查包完整性

--noscripts:不执行程序包脚本

%pre: 安装前脚本; --nopre

%post: 安装后脚本; --nopost

%preun: 卸载前脚本; --nopreun

%postun: 卸载后脚本; --nopostun

卸载包

[root@centos71 app]# rpm  -e  sl
[root@centos71 app]#
[root@centos71 app]# cd
[root@centos71 ~]# ls
anaconda-ks.cfg Desktop Downloads Music Pictures skipfish-2.10-0.2.b.el7.x86_64.rpm Templates
Documents initial-setup-ks.cfg oCam.exe Public sl-5.02-1.el7.x86_64.rpm Videos
[root@centos71 ~]# ls
anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg Music oCam.exe Pictures Public
skipfish-2.10-0.2.b.el7.x86_64.rpm sl-5.02-1.el7.x86_64.rpm Templates Videos
[root@centos71 ~]# mv sl-5.02-1.el7.x86_64.rpm /app/
[root@centos71 ~]# cd /app/
[root@centos71 app]# ls
sl-5.02-1.el7.x86_64.rpm tree-1.6.0-10.el7.x86_64.rpm

--test: 测试安装,但不真正执行安装,即dry run模式

[root@centos71 app]# rpm  -i    sl-5.02-1.el7.x86_64.rpm      --test
warning: sl-5.02-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
[root@centos71 app]# rpm -ivh sl-5.02-1.el7.x86_64.rpm --test
warning: sl-5.02-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################# [100%]
[root@centos71 app]# rpm -ivvh sl-5.02-1.el7.x86_64.rpm --test
D: ============== sl-5.02-1.el7.x86_64.rpm
D: loading keyring from pubkeys in /var/lib/rpm/pubkeys/*.key
D: couldn't find any keys in /var/lib/rpm/pubkeys/*.key
D: loading keyring from rpmdb
D: opening db environment /var/lib/rpm cdb:0x401
D: opening db index /var/lib/rpm/Packages 0x400 mode=0x0
D: locked db index /var/lib/rpm/Packages
D: opening db index /var/lib/rpm/Name 0x400 mode=0x0
D: Expected size: 14244 = lead(96)+sigs(1284)+pad(4)+data(12860)
D: Actual size: 14244
warning: sl-5.02-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
D: added binary package [0]
D: found 0 source and 1 binary packages
D: opening db index /var/lib/rpm/Conflictname 0x400 mode=0x0
D: ========== +++ sl-5.02-1.el7 x86_64/linux 0x2
D: opening db index /var/lib/rpm/Providename 0x400 mode=0x0
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libc.so.6()(64bit) YES (db provides)
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libc.so.6(GLIBC_2.2.5)(64bit) YES (db provides)
D: read h# 53 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libncurses.so.5()(64bit) YES (db provides)
D: read h# 53 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: libtinfo.so.5()(64bit) YES (db provides)
D: Requires: rpmlib(CompressedFileNames) <= 3.0.4-1 YES (rpmlib provides)
D: Requires: rpmlib(FileDigests) <= 4.6.0-1 YES (rpmlib provides)
D: Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 YES (rpmlib provides)
D: read h# 47 Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
D: Requires: rtld(GNU_HASH) YES (db provides)
D: Requires: rpmlib(PayloadIsXz) <= 5.2-1 YES (rpmlib provides)
D: opening db index /var/lib/rpm/Obsoletename 0x400 mode=0x0
D: ========== recording tsort relations
D: ========== tsorting packages (order, #predecessors, #succesors, depth)
D: 0 0 0 1 +sl-5.02-1.el7.x86_64
D: installing binary packages
D: Selinux disabled.
D: sanity checking 1 elements
D: computing 7 file fingerprints
D: opening db index /var/lib/rpm/Basenames 0x400 mode=0x0
D: opening db index /var/lib/rpm/Group 0x400 mode=0x0
D: opening db index /var/lib/rpm/Requirename 0x400 mode=0x0
D: opening db index /var/lib/rpm/Triggername 0x400 mode=0x0
D: opening db index /var/lib/rpm/Dirnames 0x400 mode=0x0
D: opening db index /var/lib/rpm/Installtid 0x400 mode=0x0
D: opening db index /var/lib/rpm/Sigmd5 0x400 mode=0x0
D: opening db index /var/lib/rpm/Sha1header 0x400 mode=0x0
Preparing... D: computing file dispositions
D: 0x00000802 4096 12157164 26087641 /
################################# [100%]
D: ========== +++ sl-5.02-1.el7 x86_64-linux 0x2
D: Expected size: 14244 = lead(96)+sigs(1284)+pad(4)+data(12860)
D: Actual size: 14244
D: sl-5.02-1.el7.x86_64: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
D: closed db index /var/lib/rpm/Sha1header
D: closed db index /var/lib/rpm/Sigmd5
D: closed db index /var/lib/rpm/Installtid
D: closed db index /var/lib/rpm/Dirnames
D: closed db index /var/lib/rpm/Triggername
D: closed db index /var/lib/rpm/Obsoletename
D: closed db index /var/lib/rpm/Conflictname
D: closed db index /var/lib/rpm/Providename
D: closed db index /var/lib/rpm/Requirename
D: closed db index /var/lib/rpm/Group
D: closed db index /var/lib/rpm/Basenames
D: closed db index /var/lib/rpm/Name
D: closed db index /var/lib/rpm/Packages
D: closed db environment /var/lib/rpm

下面显示并没有真正的安装

[root@centos71 app]# sl
-bash: /usr/bin/sl: No such file or directory

因为有依赖关系

包依赖关系就好比是楼与楼的关系。

假如A包依赖于B包,那么安装的时候就要先安装B包了。

但是在卸载的时候就要先卸载A包了。安装就相当于盖楼,B包是地基;卸载就相当于拆楼,A在楼上。

[root@centos71 app]# rpm   -ivh    /mnt/Packages/gcc-4.8.5-28.el7.x86_64.rpm
warning: /mnt/Packages/gcc-4.8.5-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
cpp = 4.8.5-28.el7 is needed by gcc-4.8.5-28.el7.x86_64
glibc-devel >= 2.2.90-12 is needed by gcc-4.8.5-28.el7.x86_64
libmpc.so.3()(64bit) is needed by gcc-4.8.5-28.el7.x86_64

--replacepkgs

[root@centos71 app]# rpm  -q  tree
tree-1.6.0-10.el7.x86_64
[root@centos71 app]# rpm -ql tree 安装包生成的文件。因为rpm包是打包文件,这些就相当于子文件。
/usr/bin/tree
/usr/share/doc/tree-1.6.0
/usr/share/doc/tree-1.6.0/LICENSE
/usr/share/doc/tree-1.6.0/README
/usr/share/man/man1/tree.1.gz
[root@centos71 app]# which tree 注意tree命令就是来自这个包的
/usr/bin/tree
[root@centos71 app]# rm -f /usr/bin/tree

后面加上选项--replacepkgs

[root@centos71 app]# rpm  -ivh     tree-1.6.0-10.el7.x86_64.rpm
warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
package tree-1.6.0-10.el7.x86_64 is already installed
[root@centos71 app]# #重新安装但是提示已经安装了。
[root@centos71 app]# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm --replacepkgs
warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:tree-1.6.0-10.el7 ################################# [100%]
[root@centos71 app]# tree
.
├── sl-5.02-1.el7.x86_64.rpm
└── tree-1.6.0-10.el7.x86_64.rpm 0 directories, 2 files

--replacepkgs的作用就是安装上包中所有的子包,已经有的文件就覆盖了。

[root@centos71 app]# ll    /usr/share/doc/tree-1.6.0/README
-rw-r--r--. 1 root root 4628 Jun 24 2011 /usr/share/doc/tree-1.6.0/README
[root@centos71 app]# echo >> /usr/share/doc/tree-1.6.0/README
[root@centos71 app]# ll /usr/share/doc/tree-1.6.0/README
-rw-r--r--. 1 root root 4629 Jan 11 09:43 /usr/share/doc/tree-1.6.0/README
[root@centos71 app]# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm --replacepkgs
warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:tree-1.6.0-10.el7 ################################# [100%]
[root@centos71 app]# ll /usr/share/doc/tree-1.6.0/README
-rw-r--r--. 1 root root 4628 Jun 24 2011 /usr/share/doc/tree-1.6.0/README

注意大部分程序是放在/usr/bin/或者/usr/sbin,并且不带版本号。

[root@centos71 app]# ls   /usr/bin/*    |   wc
1695 1695 32695
[root@centos71 app]# ls /usr/sbin/* | wc
663 663 13361
[root@centos71 app]# ll /usr/bin/mpstat
-rwxr-xr-x. 1 root root 53728 Apr 11 2018 /usr/bin/mpstat

内核文件就带版本号。几个内核是可以并存的。启动的时候可以选择。

[root@centos71 app]# cd   /boot/
[root@centos71 boot]# ls
config-3.10.0-862.el7.x86_64 grub initramfs-0-rescue-685dc66dda59420c9a03dae9e6d67f2c.img
symvers-3.10.0-862.el7.x86_64.gz vmlinuz-0-rescue-685dc66dda59420c9a03dae9e6d67f2cefi
grub2 initramfs-3.10.0-862.el7.x86_64.img
System.map-3.10.0-862.el7.x86_64 vmlinuz-3.10.0-862.el7.x86_64

做rpm包的人已经指定好了文件安装的路径了。

目录满了就清理,报错就提示。

每个软件包都是按照文件的分层结构FHS来装入目录的。在Linux里面每个文件都是有规定的路径的。

(三)rpm包升级

升级:

rpm {-U|--upgrade} [install-options] PACKAGE_FILE ...

rpm {-F|--freshen} [install-options] PACKAGE_FILE ...

upgrade:安装有旧版程序包,则“升级”。如果不存在旧版程序包,则“安装”。

注意对应内核不要把进行升级,这样有风险的。内核占用的空间不大,所以可以在系统中设置双内核。

freshen:安装有旧版程序包,则“升级”。如果不存在旧版程序包,则不执行升级操作。

rpm -Uvh PACKAGE_FILE ...
rpm -Fvh PACKAGE_FILE ...
--oldpackage:降级
--force: 强制安装

卸载-e,后面加上包名就可以了。

为什么不写路径就可以卸载和查询,是从数据库里面查的。

安装的时候就要写上完整的文件路径了。

[root@centos71 ~]# rpm  -e  tree
[root@centos71 ~]# rpm -q tree
package tree is not installed

linux软件包rpm的使用的更多相关文章

  1. linux 软件包 rpm命令之安装、更新、卸载、依赖

    软件包分类1.源码包2.二进制包二进制包是源码包编译后产生的文件..exe文件是适用于windows平台的二进制包:RPM包适用于redhat系列的二进制包:deb包是适用于ubuntu平台的二进制包 ...

  2. Linux下RPM软件包的安装及卸载

    http://os.51cto.com/art/201001/177866.htm 在 Linux 操作系统下,几乎所有的软件均通过RPM 进行安装.卸载及管理等操作.RPM 的全称为Redhat P ...

  3. Linux系列教程(十一)——Linux软件包管理之RPM命令

    前面我们介绍了Linux系统的常用命令介绍和文本编辑器vim命令的介绍.那么从这篇博客开始,我们会正式的讲解Linux的系统管理,首先要讲的是Linux的软件包管理. 1.Linux软件包分类 一.源 ...

  4. Linux软件包管理之RPM命令

    目录 1.Linux软件包分类 一.源码包 二.二进制包 2.rpm 包命名规则 3.rpm包安装 4.rpm包升级 5.rpm包卸载 6.查询rpm包是否安装 7.查询软件包的详细信息 8.查询软件 ...

  5. [转]Linux下RPM软件包的安装及卸载 yum操作

    在 Linux 操作系统下,几乎所有的软件均通过RPM 进行安装.卸载及管理等操作.RPM 的全称为Redhat Package Manager ,是由Redhat 公司提出的,用于管理Linux 下 ...

  6. Linux软件包管理

    Linux软件包管理 Linux软件包管理主要有2类:是二进制包管理.源码包管理 二进制包管理 主要有RPM和YUM两种 RPM包管理 安装 --ivh:-v ,-vv,-vvv显示的安装信息依次详细 ...

  7. Linux 软件包管理

    简介: linux中软件包的管理随着linux版本的不同而不同,一般RPM和DPKG是最常见的两类软件包管理工具.分别应用基于rpm软件包的linux发行版本和基于deb软件包的linux发行版本. ...

  8. linux软件包管理(下)

    在vi配置文件的编写的时候我们发现#并不能注释掉一行的信息 那什么才是linux标准的注释信息呢 查看软件对应的软件包命令 rpm –ap| grep vim 大多example是需要的事例文档  双 ...

  9. linux软件包管理(上)

    1.二进制包管理(RPM,yum) 2.源代码包的安装 3.脚本安装(shell或java) 4.Debian系列的linux软件包管理简介 在下载rmp包的时候注意检查硬件平台是否正确,如果硬件平台 ...

随机推荐

  1. 百度小程序-map组件定位

    给客户开发一个百度小程序,有个地图定位显示.百度小程序内置的api地图是不准的,通过百度一下,查询到坐标偏移算法公式,自己项目中使用,手机测试坐标已经正常显示! 经纬度,通过百度坐标拾取器拾取到! . ...

  2. Halo(十一)

    Spring Boot 继承 AbstractErrorController 实现全局异常处理 @RequestMapping("${server.error.path:${error.pa ...

  3. XP定位(APP元素定位)

    Appium app自动化测试经验分享-Xpath定位总结 在我看来,自动化测试中元素定位的倚天剑和屠龙刀莫过于 Xpath和CSS,但CSS只用于Web(之前已经分享过),这次就分享下Xpath的定 ...

  4. php strnatcasecmp()函数 语法

    php strnatcasecmp()函数 语法 作用:使用"自然"算法来比较两个字符串(不区分大小写):直线电机优势 语法:strnatcasecmp(string1,strin ...

  5. kafka-consumer.properties

    # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreement ...

  6. 二叉查找树BST

    每棵子树头节点的值都比各自左子树上所有节点值要大,也都比各自右子树上所有节点值要小. 二叉查找树的中序遍历序列一定是从小到大排列的. 一个节点的后继节点是指,这个节点在中序遍历序列中的下一个节点.相应 ...

  7. redis哨兵-5

    #地址: https://www.cnblogs.com/PatrickLiu/p/8444546.html #常用架构 redis1主1从+3哨兵 实现redis高可用 #redis主从 ##### ...

  8. 高精度模板 洛谷Luogu P1932 A+B & A-B & A*B & A/B Problem

    P1932 A+B & A-B & A*B & A/B Problem 题目背景 这个题目很新颖吧!!! 题目描述 求A.B的和差积商余! 输入输出格式 输入格式: 两个数两行 ...

  9. C# Self Injector into non managed process

    Hey all, I'm gonna explain you how make a self injecting program in C#.I hope you guys thinks its us ...

  10. 公司-IT-SanSan:SanSan

    ylbtech-公司-IT-SanSan:SanSan 毫不费力的组织.无缝简单.基于名片的联系人管理 SanSan是一个名片管理应用,为企业提供内部联系人管理和分享服务,此外该公司也是日本最大的.基 ...