linux软件包rpm的使用
一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的使用的更多相关文章
- linux 软件包 rpm命令之安装、更新、卸载、依赖
软件包分类1.源码包2.二进制包二进制包是源码包编译后产生的文件..exe文件是适用于windows平台的二进制包:RPM包适用于redhat系列的二进制包:deb包是适用于ubuntu平台的二进制包 ...
- Linux下RPM软件包的安装及卸载
http://os.51cto.com/art/201001/177866.htm 在 Linux 操作系统下,几乎所有的软件均通过RPM 进行安装.卸载及管理等操作.RPM 的全称为Redhat P ...
- Linux系列教程(十一)——Linux软件包管理之RPM命令
前面我们介绍了Linux系统的常用命令介绍和文本编辑器vim命令的介绍.那么从这篇博客开始,我们会正式的讲解Linux的系统管理,首先要讲的是Linux的软件包管理. 1.Linux软件包分类 一.源 ...
- Linux软件包管理之RPM命令
目录 1.Linux软件包分类 一.源码包 二.二进制包 2.rpm 包命名规则 3.rpm包安装 4.rpm包升级 5.rpm包卸载 6.查询rpm包是否安装 7.查询软件包的详细信息 8.查询软件 ...
- [转]Linux下RPM软件包的安装及卸载 yum操作
在 Linux 操作系统下,几乎所有的软件均通过RPM 进行安装.卸载及管理等操作.RPM 的全称为Redhat Package Manager ,是由Redhat 公司提出的,用于管理Linux 下 ...
- Linux软件包管理
Linux软件包管理 Linux软件包管理主要有2类:是二进制包管理.源码包管理 二进制包管理 主要有RPM和YUM两种 RPM包管理 安装 --ivh:-v ,-vv,-vvv显示的安装信息依次详细 ...
- Linux 软件包管理
简介: linux中软件包的管理随着linux版本的不同而不同,一般RPM和DPKG是最常见的两类软件包管理工具.分别应用基于rpm软件包的linux发行版本和基于deb软件包的linux发行版本. ...
- linux软件包管理(下)
在vi配置文件的编写的时候我们发现#并不能注释掉一行的信息 那什么才是linux标准的注释信息呢 查看软件对应的软件包命令 rpm –ap| grep vim 大多example是需要的事例文档 双 ...
- linux软件包管理(上)
1.二进制包管理(RPM,yum) 2.源代码包的安装 3.脚本安装(shell或java) 4.Debian系列的linux软件包管理简介 在下载rmp包的时候注意检查硬件平台是否正确,如果硬件平台 ...
随机推荐
- php pow()函数 语法
php pow()函数 语法 作用:pow()函数的作用是将一个数进行n次方计算后返回,广东大理石平台 语法:pow(X,Y); 参数: 参数 描述 X 要做处理的数字 Y 指定n次方中的n数值 说明 ...
- JSON对象及方法
1.JSON JSON 包括 JSON 字符串和 JSON 对象.JSON 通常用于与服务端交换数据,在给服务器接收和发送数据时用的都是字符串,可以是 JSON 字符串或者一般的键值对字符串.把Jav ...
- 自定义combiner实现文件倒排索引
package com.zuoyan.hadoop; import java.io.IOException; import org.apache.hadoop.conf.Configuration; ...
- Mac上VMWare Fusion配置多台cent os
一.创建虚拟机(准备工作) 1.使用VMWare Fusion 创建第一台虚拟机 2.选择操作系统(本次使用的是使用cent os 6.5 64bit 系统) 3.选择磁盘大小(楼主mac上的磁盘大小 ...
- 小白学 Python 爬虫(26):为啥上海二手房你都买不起
人生苦短,我用 Python 前文传送门: 小白学 Python 爬虫(1):开篇 小白学 Python 爬虫(2):前置准备(一)基本类库的安装 小白学 Python 爬虫(3):前置准备(二)Li ...
- 抓包工具fiddler下载配置(一):下载/安装&信任证书
简介 Fiddler一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网之间的http通讯,设置断点,查看所有的“进出”Fiddler的数据(指cookie,html,js,css等文件 ...
- Python异或加密字符串
import os import sys import struct def enc(path, key): path_ret = "" for i in range(0, len ...
- 【计算机网络】两个网络模型——OSI参考模型和TCP/IP模型
计算机网络 两个网络模型 计算机网络模型 分层机制----规划通讯细节 层与层之间之间是独立的.屏蔽的,下层为上层提供服务. 一些概念 实体: 任何发送/接收信息的软件/硬件进程. 对等层: 两个不同 ...
- oracle Notes
1. selecting distinct values from an assocaitive array 2. Setting the NLS_LANG Environment Variable ...
- Java常用的几个Json库,性能强势对比!
作者:飞污熊 https://xncoding.com/2018/01/09/java/jsons.html 本篇通过JMH来测试一下Java中几种常见的JSON解析库的性能.每次都在网上看到别人说什 ...