Use the rpm linux package

 

 

 

 

 

 

 

 

A rpm package manager

 

 

(A) rpm introduction

 

 

rpm is not only a file extension, is a tool, an external command, Package Manager

Function: constituent documents compiled application package or several packages a file, thus quickly and easily implement the installation package, uninstall, query, update and verify other management operations.

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

 

 

 

 

 

 

 

(B) the package files (unique to each package) 

 

 

Files in the package 1RPM    

 

2RPM metadata, such as the name, version, dependency, and the like is described. Package but no compression.  

 

3 install or uninstall script to run.

 

Most rpm so-called installation package decompressed and provided good copied to the path.

 

To copy a file or directory corresponding set of attributes, such as file owner and group.

 

If the system does not create this account then it would come out to write scripts. This is the script before installation.

 

Software installed on the system is installed rpm's.

 

So Linux database will record all packets of information in this way rpm installed after installed.

 

Queries can be installed in the system which rpm package, which when installed, what files are generated, which in the directory.

 

 

 

 Copy a file from a CD inside

[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

 

 

 

 

 

 

 

 

(C) databases (public): / var / lib / rpm

 


Package name and version
dependencies
Function
of each file path and check information generated after the installation package

 

 

 

 / Var / lib / rpm / The following files are very important, for safety can do a backup.

[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

 

 

 

 

 

 

 

View 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

 

 

 

 

 

 

 

 

Source (four) packages

 

(1) or CD-ROM version of the system made the official server


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

 


(2) Project official site

 

 

(3) a third party organization


Fedora-EPEL:Extra Packages for Enterprise Linux

After Red Hat are tested, safe to use.

 

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!

 

 

 

 

 

 

 

 Enter the following picture will appear sl

 

 

 

 

 

 

 

 

 

Rpmforge: RHEL recommendation, the whole package is very
search engine:
http://pkgs.org
http://rpmfind.net
http://rpm.pbone.net
https://sourceforge.net/

Note that the search out of the package may be a problem.

 


(4) to produce their own. Note: Third-party package is recommended to check its legitimacy, the legitimacy of sources, the integrity of the package

 

 

 

 

 

 

 

 

 

 

 

 

 

Two rpm package management

 

 

CentOS system using the command rpm package management: installing, uninstalling, upgrading, querying, validation, database maintenance

 

 

 

(A) the installation package using the command rpm

 

 


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


-v: verbose Show Details


-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

Guess you like

Origin www.cnblogs.com/wang618/p/11117771.html
Recommended