linux环境中,如何查看某个软件包,都依赖哪些软件包?被哪些软件包依赖?

需求描述:

今天查看主机上的一个软件ghostscript,准备删除,就先看下这个软件都依赖哪些软件,

然后呢被哪些软件依赖

操作过程:

1.查看这个软件依赖哪些软件(rpm方式查询)

[root@testvm02 ~]# rpm -q ghostscript   #查看对应的rpm包.
ghostscript-8.70-19.el6.x86_64
[root@testvm02 ~]# rpm -qR ghostscript  #R的意思就是requires就是依赖哪些软件包.
/bin/sh  
/sbin/ldconfig  
/sbin/ldconfig  
config(ghostscript) = 8.70-19.el6
ghostscript-fonts  
libICE.so.6()(64bit)  
libSM.so.6()(64bit)  
libX11.so.6()(64bit)  
libXext.so.6()(64bit)  
libXt.so.6()(64bit)  
libc.so.6()(64bit)  
libc.so.6(GLIBC_2.11)(64bit)  
libc.so.6(GLIBC_2.2.5)(64bit)  
libc.so.6(GLIBC_2.3)(64bit)  
libc.so.6(GLIBC_2.3.4)(64bit)  
libc.so.6(GLIBC_2.4)(64bit)  
libc.so.6(GLIBC_2.7)(64bit)  
libcairo.so.2()(64bit)  
libcom_err.so.2()(64bit)  
libcrypt.so.1()(64bit)  
libcups.so.2()(64bit)  
libcupsimage.so.2()(64bit)  
libdl.so.2()(64bit)  
libdl.so.2(GLIBC_2.2.5)(64bit)  
libfontconfig.so.1()(64bit)  
libgs.so.8()(64bit)  
libgssapi_krb5.so.2()(64bit)  
libjasper.so.1()(64bit)  
libjpeg.so.62()(64bit)  
libjpeg.so.62(LIBJPEG_6.2)(64bit)  
libk5crypto.so.3()(64bit)  
libkrb5.so.3()(64bit)  
libm.so.6()(64bit)  
libm.so.6(GLIBC_2.2.5)(64bit)  
libpng12.so.0()(64bit)  
libpng12.so.0(PNG12_0)(64bit)  
libpthread.so.0()(64bit)  
libpthread.so.0(GLIBC_2.2.5)(64bit)  
libpthread.so.0(GLIBC_2.3.2)(64bit)  
libstdc++.so.6()(64bit)  
libz.so.1()(64bit)  
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)  
urw-fonts >= 1.1
rpmlib(PayloadIsXz) <= 5.2-1
备注:以上查询出来的就是依赖的软件包.

2.通过yum方式来查询依赖的程序

[root@testvm02 ~]# yum deplist ghostscript
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Finding dependencies: 
package: ghostscript.i686 8.70-19.el6
  dependency: libc.so.6(GLIBC_2.11)       #依赖的库或者程序
   provider: glibc.i686 2.12-1.149.el6    #这个库是通过哪个rpm包安装的.
  dependency: libXext.so.6
   provider: libXext.i686 1.3.2-2.1.el6
  dependency: libpng12.so.0
   provider: libpng.i686 2:1.2.49-1.el6_2
  dependency: libpng12.so.0(PNG12_0)
   provider: libpng.i686 2:1.2.49-1.el6_2
  dependency: libpthread.so.0(GLIBC_2.1)
   provider: glibc.i686 2.12-1.149.el6
  dependency: libdl.so.2
   provider: glibc.i686 2.12-1.149.el6
  dependency: /sbin/ldconfig
   provider: glibc.x86_64 2.12-1.149.el6
   provider: glibc.i686 2.12-1.149.el6
  dependency: libkrb5.so.3
   provider: krb5-libs.i686 1.10.3-33.el6
  dependency: libdl.so.2(GLIBC_2.0)
   provider: glibc.i686 2.12-1.149.el6
  dependency: libfontconfig.so.1
   provider: fontconfig.i686 2.8.0-5.el6
  dependency: libcrypt.so.1
   provider: glibc.i686 2.12-1.149.el6
  dependency: libICE.so.6
   provider: libICE.i686 1.0.6-1.el6
  dependency: libSM.so.6
   provider: libSM.i686 1.2.1-2.el6
  dependency: libpthread.so.0(GLIBC_2.0)
   provider: glibc.i686 2.12-1.149.el6
  dependency: libcairo.so.2
   provider: cairo.i686 1.8.8-3.1.el6
  dependency: libcupsimage.so.2
   provider: cups-libs.i686 1:1.4.2-67.el6
  dependency: libjpeg.so.62
   provider: libjpeg-turbo.i686 1.2.1-3.el6_5
  dependency: libjasper.so.1
   provider: jasper-libs.i686 1.900.1-15.el6_1.1
  dependency: libz.so.1
   provider: zlib.i686 1.2.3-29.el6
  dependency: libstdc++.so.6
   provider: libstdc++.i686 4.4.7-11.el6
  dependency: libm.so.6
   provider: glibc.i686 2.12-1.149.el6
  dependency: rtld(GNU_HASH)
   provider: glibc.i686 2.12-1.149.el6
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: ghostscript-fonts
   provider: ghostscript-fonts.noarch 5.50-23.2.el6
  dependency: libjpeg.so.62(LIBJPEG_6.2)
   provider: libjpeg-turbo.i686 1.2.1-3.el6_5
  dependency: libcom_err.so.2
   provider: libcom_err.i686 1.41.12-21.el6
  dependency: urw-fonts >= 1.1
   provider: urw-fonts.noarch 2.4-10.el6
  dependency: /bin/sh
   provider: bash.x86_64 4.1.2-29.el6
  dependency: libdl.so.2(GLIBC_2.1)
   provider: glibc.i686 2.12-1.149.el6
  dependency: libXt.so.6
   provider: libXt.i686 1.1.4-6.1.el6
  dependency: libX11.so.6
   provider: libX11.i686 1.6.0-2.2.el6
  dependency: libpthread.so.0(GLIBC_2.3.2)
   provider: glibc.i686 2.12-1.149.el6
  dependency: libpthread.so.0
   provider: glibc.i686 2.12-1.149.el6
  dependency: libm.so.6(GLIBC_2.0)
   provider: glibc.i686 2.12-1.149.el6
  dependency: libgssapi_krb5.so.2
   provider: krb5-libs.i686 1.10.3-33.el6
  dependency: libcups.so.2
   provider: cups-libs.i686 1:1.4.2-67.el6
  dependency: libk5crypto.so.3
   provider: krb5-libs.i686 1.10.3-33.el6
package: ghostscript.x86_64 8.70-19.el6
  dependency: libcairo.so.2()(64bit)
   provider: cairo.x86_64 1.8.8-3.1.el6
  dependency: libstdc++.so.6()(64bit)
   provider: libstdc++.x86_64 4.4.7-11.el6
  dependency: libz.so.1()(64bit)
   provider: zlib.x86_64 1.2.3-29.el6
  dependency: libcupsimage.so.2()(64bit)
   provider: cups-libs.x86_64 1:1.4.2-67.el6
  dependency: /sbin/ldconfig
   provider: glibc.x86_64 2.12-1.149.el6
   provider: glibc.i686 2.12-1.149.el6
  dependency: libcrypt.so.1()(64bit)
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: urw-fonts >= 1.1
   provider: urw-fonts.noarch 2.4-10.el6
  dependency: libm.so.6(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: /bin/sh
   provider: bash.x86_64 4.1.2-29.el6
  dependency: libX11.so.6()(64bit)
   provider: libX11.x86_64 1.6.0-2.2.el6
  dependency: libpng12.so.0(PNG12_0)(64bit)
   provider: libpng.x86_64 2:1.2.49-1.el6_2
  dependency: libk5crypto.so.3()(64bit)
   provider: krb5-libs.x86_64 1.10.3-33.el6
  dependency: libm.so.6()(64bit)
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit)
   provider: libjpeg-turbo.x86_64 1.2.1-3.el6_5
  dependency: libXt.so.6()(64bit)
   provider: libXt.x86_64 1.1.4-6.1.el6
  dependency: libpng12.so.0()(64bit)
   provider: libpng.x86_64 2:1.2.49-1.el6_2
  dependency: libpthread.so.0(GLIBC_2.3.2)(64bit)
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: libfontconfig.so.1()(64bit)
   provider: fontconfig.x86_64 2.8.0-5.el6
  dependency: libdl.so.2()(64bit)
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: libICE.so.6()(64bit)
   provider: libICE.x86_64 1.0.6-1.el6
  dependency: libkrb5.so.3()(64bit)
   provider: krb5-libs.x86_64 1.10.3-33.el6
  dependency: libcom_err.so.2()(64bit)
   provider: libcom_err.x86_64 1.41.12-21.el6
  dependency: libXext.so.6()(64bit)
   provider: libXext.x86_64 1.3.2-2.1.el6
  dependency: libdl.so.2(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: ghostscript-fonts
   provider: ghostscript-fonts.noarch 5.50-23.2.el6
  dependency: rtld(GNU_HASH)
   provider: glibc.i686 2.12-1.149.el6
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: libcups.so.2()(64bit)
   provider: cups-libs.x86_64 1:1.4.2-67.el6
  dependency: libc.so.6(GLIBC_2.11)(64bit)
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: libpthread.so.0()(64bit)
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: libgssapi_krb5.so.2()(64bit)
   provider: krb5-libs.x86_64 1.10.3-33.el6
  dependency: libpthread.so.0(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.12-1.149.el6
  dependency: libSM.so.6()(64bit)
   provider: libSM.x86_64 1.2.1-2.el6
  dependency: libjpeg.so.62()(64bit)
   provider: libjpeg-turbo.x86_64 1.2.1-3.el6_5
  dependency: libjasper.so.1()(64bit)
   provider: jasper-libs.x86_64 1.900.1-15.el6_1.1

3.查看这个软件被哪些软件依赖(即如果我要删除了会对哪些软件的运行有影响)

[root@testvm02 ~]# rpm -q nfs-utils         #查看这个软件是否安装.
nfs-utils-1.2.3-54.el6.x86_64
[root@testvm02 ~]# rpm -e --test nfs-utils  #通过--test进行测试删除,查看是否有依赖关系,如果有会阻止删除.测试是否能够删除.
error: Failed dependencies:
    nfs-utils >= 1.2.1-11 is needed by (installed) nfs-utils-lib-1.1.5-9.el6.x86_64  #有其他的软件包依赖这个软件包,如果删除可能对这个程序有影响.
[root@testvm02 ~]# rpm -e --test nfs-utils
error: Failed dependencies:
    nfs-utils >= 1.2.1-11 is needed by (installed) nfs-utils-lib-1.1.5-9.el6.x86_64
[root@testvm02 ~]# rpm -e --test gcc  #测试删除gcc,没有报错,也就是没有别的地方依赖它,可以进行删除.
[root@testvm02 ~]# rpm -q gcc         #上面的--test并没有真正删除
gcc-4.4.7-11.el6.x86_64
[root@testvm02 ~]# rpm -e gcc         #不带--test参数,进行真正的删除.
[root@testvm02 ~]# rpm -q gcc         #再次查询没有这个gcc已经被删除掉了.
package gcc is not installed

你可能感兴趣的:(linux环境中,如何查看某个软件包,都依赖哪些软件包?被哪些软件包依赖?)