Linux系统卸载软件包忽略其依赖性

      今天搭建了RHEL4环境想把LAMP做一下,默认RHEL4系统中已经安装了apachephpmysql,我们必须把他卸载掉。大家可能知道卸载软件包可以使用rpm —e,其实我和大家想的一样,但是基于包之间的依赖性无法使用rpm -e直接卸载。如下图所示:

 


 

这可怎么办呢?可把我急坏了。有一个坏的想法在我脑海中浮现,把这个虚拟机删除掉从新建立一个新的虚拟机,可是这个方法太笨了、太土了、也不太显示。

于是使用rpm --help查看了rpm命令查找帮助。如下所示

[root@localhost ~]# rpm --help

Usage: rpm [OPTION...]

Query options (with -q or --query):

  -c, --configfiles                list all configuration files

  -d, --docfiles                   list all documentation files

  --dump                           dump basic file information

  -l, --list                       list files in package

  --queryformat=QUERYFORMAT        use the following query format

  -s, --state                      display the states of the listed files

  -a, --all                        query/verify all packages

  -f, --file                       query/verify package(s) owning file

  -g, --group                      query/verify package(s) in group

  -p, --package                    query/verify a package file

  --specfile                       query a spec file

  --whatrequires                   query/verify the package(s) which require a

                                   dependency

  --whatprovides                   query/verify the package(s) which provide a

                                   dependency

Verify options (with -V or --verify):

  --nomd5                          don't verify MD5 digest of files

  --nofiles                        don't verify files in package

  --nodeps                         don't verify package dependencies

  --noscript                       don't execute verify script(s)

  -a, --all                        query/verify all packages

  -f, --file                       query/verify package(s) owning file

  -g, --group                      query/verify package(s) in group

  -p, --package                    query/verify a package file

  --specfile                       query a spec file

  --whatrequires                   query/verify the package(s) which require a

                                   dependency

  --whatprovides                   query/verify the package(s) which provide a

                                   dependency

Signature options:

  --addsign                        sign package(s) (identical to --resign)

  -K, --checksig                   verify package signature(s)

  --import                         import an armored public key

  --resign                         sign package(s) (identical to --addsign)

  --nodigest                       don't verify package digest(s)

  --nosignature                    don't verify package signature(s)

Database options:

  --initdb                         initialize database

  --rebuilddb                      rebuild database inverted lists from

                                   installed package headers

Install/Upgrade/Erase options:

  --aid                            add suggested packages to transaction

  --allfiles                       install all files, even configurations

                                   which might otherwise be skipped

  --allmatches                     remove all packages which match <package>

                                   (normally an error is generated if

                                   <package> specified multiple packages)

  --badreloc                       relocate files in non-relocatable package

  -e, --erase=<package>+           erase (uninstall) package

  --excludedocs                    do not install documentation

  --excludepath=<path>             skip files with leading component <path>

  --fileconflicts                  detect file conflicts between packages

  --force                          short hand for --replacepkgs --replacefiles

  -F, --freshen=<packagefile>+     upgrade package(s) if already installed

  -h, --hash                       print hash marks as package installs (good

                                   with -v)

  --ignorearch                     don't verify package architecture

  --ignoreos                       don't verify package operating system

  --ignoresize                     don't check disk space before installing

  -i, --install                    install package(s)

  --justdb                         update the database, but do not modify the

                                   filesystem

  --nodeps                         do not verify package dependencies

  --nomd5                          don't verify MD5 digest of files

  --nocontexts                     don't install file security contexts

  --noorder                        do not reorder package installation to

                                   satisfy dependencies

  --nosuggest                      do not suggest missing dependency

                                   resolution(s)

  --noscripts                      do not execute package scriptlet(s)

  --notriggers                     do not execute any scriptlet(s) triggered

                                   by this package

  --oldpackage                     upgrade to an old version of the package

                                   (--force on upgrades does this

                                   automatically)

  --percent                        print percentages as package installs

  --prefix=<dir>                   relocate the package to <dir>, if

                                   relocatable

  --relocate=<old>=<new>           relocate files from path <old> to <new>

  --repackage                      save erased package files by repackaging

  --replacefiles                   ignore file conflicts between packages

  --replacepkgs                    reinstall if the package is already present

  --test                           don't install, but tell if it would work or

                                   not

  -U, --upgrade=<packagefile>+     upgrade package(s)

Common options for all rpm modes:

  -D, --define='MACRO EXPR'        define MACRO with value EXPR

  -E, --eval='EXPR'                print macro expansion of EXPR

  --macros=<FILE:...>              read <FILE:...> instead of default file(s)

  --nodigest                       don't verify package digest(s)

  --nosignature                    don't verify package signature(s)

  --rcfile=<FILE:...>              read <FILE:...> instead of default file(s)

  -r, --root=ROOT                  use ROOT as top level directory (default:

                                   "/")

  --querytags                      display known query tags

  --showrc                         display final rpmrc and macro configuration

  --quiet                          provide less detailed output

  -v, --verbose                    provide more detailed output

  --version                        print the version of rpm being used

Options implemented via popt alias/exec:

  --scripts                        list install/erase scriptlets from

                                   package(s)

  --setperms                       set permissions of files in a package

  --setugids                       set user/group ownership of files in a

                                   package

  --conflicts                      list capabilities this package conflicts

                                   with

  --obsoletes                      list other packages removed by installing

                                   this package

  --provides                       list capabilities that this package provides

  --requires                       list capabilities required by package(s)

  --info                           list descriptive information from package(s)

  --changelog                      list change logs for this package

  --triggers                       list trigger scriptlets from package(s)

  --last                           list package(s) by install time, most

                                   recent first

  --filesbypkg                     list all files from each package

  --fileclass                      list file names with classes

  --filecolor                      list file names with colors

  --filecontext                    list file names with security context from

                                   header

  --fscontext                      list file names with security context from

                                   file system

  --recontext                      list file names with security context from

                                   policy RE

  --fileprovide                    list file names with provides

  --filerequire                    list file names with requires

  --redhatprovides                 find package name that contains a provided

                                   capability (needs rpmdb-redhat package

                                   installed)

  --redhatrequires                 find package name that contains a required

                                   capability (needs rpmdb-redhat package

                                   installed)

  --buildpolicy=<policy>           set buildroot <policy> (e.g. compress man

                                   pages)

  --with=<option>                  enable configure <option> for build

  --without=<option>               disable configure <option> for build

Help options:

  -?, --help                       Show this help message

  --usage                          Display brief usage message

***************************************************************

   在帮助文档的第二十行,发现了一条帮助信息,如下所示:

--nodeps                         don't verify package dependencies

这个参数的意思是:忽略包之间的依赖性。
哈哈!这就是我要找的功能,真是踏破铁鞋无觅处;得来全不费工夫!说时迟那时快,于是使用rpm -e --nodeps+包名开始卸载这三个软件。在卸载的过程当中如果没有任何提示说明已经成功卸载。还好!一切万事大吉,现在我就可以开始我的LAMP之旅了!
希望这点小经验可以帮助更多迷茫中的人们!

——————————————————————————————————

特别声明:--

一、本文为原创,著作权及使用权为(作者笔名:闪电cto)本人所有。 ­

二、本文首发于51cto个人博客(http://xudeqiang.blog.51cto.com)。  ­

三、本文只供互联网上的读者分享,不供共享范畴,希知。 ­

四、未经许可严禁对本文作修改、节选、断章性质的处理。 ­

五、可转载,但必须注明原文章首发的出处网址,及文章作者,严禁复制。 ­

六、如若转摘用于杂志网络媒体新闻,必须通知作者得到允许后方可,需收稿费。­

七、作者联系信息:QQ:306718122   邮箱levinboy@foxmail.com

——————————————————————————————