| |
从误删除/etc/apache2目录谈rpm与dpkg的包对比管理。

那天一个同事由于不爽配置文件出错。一怒之下将ubnut 7.04下/etc/apache2目录删除了。我当时好奇做过去研究了一下。发现/etc/apache2目录下多半是由apache2-common这个包产生的。于是想到了覆盖安装。心想,这个还不简单。在rpm使用下,可以一个--froce搞定。先不说如何解决的。先来复习一下rpm的常用查询命令。并且做了个列表用来对比。

1:查询某个文件属于哪个软件包
-------------------------------------------------------------------------------------
[root@server ~]# rpm -qf /etc/httpd/conf/httpd.conf
httpd-2.2.3-6.el5
-------------------------------------------------------------------------------------
root@fixip:/etc/apache2# dpkg -S /etc/apache2/apache2.conf
apache2.2-common: /etc/apache2/apache2.conf
-------------------------------------------------------------------------------------
2:查询某个包产生的文件列表
-------------------------------------------------------------------------------------
[root@server Server]# rpm -ql tree  (未安装的包可以用p参数:-qpl 完整包名)
/usr/bin/tree
/usr/share/doc/tree-1.5.0
/usr/share/doc/tree-1.5.0/README
/usr/share/man/man1/tree.1.gz
-------------------------------------------------------------------------------------
root@fixip:/var/cache/apt/archives# dpkg -L tree (可以用-c 必须用完整包名)
/.
/usr
/usr/bin
/usr/bin/tree
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/tree.1.gz
/usr/share/doc
/usr/share/doc/tree
/usr/share/doc/tree/README
/usr/share/doc/tree/copyright
/usr/share/doc/tree/changelog.gz
/usr/share/doc/tree/changelog.Debian.gz
-------------------------------------------------------------------------------------
3:查询已所有的安装包
[root@server Server]# rpm -qa
-------------------------------------------------------------------------------------
root@fixip:/var/cache/apt/archives# dpkg -l
.......

ii  time                   1.7-21build1           The GNU time program for measuring cpu resource usage
ii  tzdata                 2007f-3ubuntu1         time zone and daylight-saving time data
ii  ubuntu-keyring         2007.06.11             GnuPG keys of the Ubuntu archive
ii  ubuntu-minimal         1.79                   Minimal core of Ubuntu
ii  ubuntu-standard        1.79                   The Ubuntu standard system
ii  ucf                    3.001                  Update Configuration File: preserves user changes to config
.......
-------------------------------------------------------------------------------------
4:查询安装包的信息
-------------------------------------------------------------------------------------
[root@server Server]# rpm -qi tree
Name        : tree                         Relocations: /usr
Version     : 1.5.0                             Vendor: Red Hat, Inc.
Release     : 4                             Build Date: Sat 15 Jul 2006 11:08:46 AM CST
Install Date: Mon 15 Oct 2007 10:07:08 AM CST      Build Host: hs20-bc2-2.build.redhat.com
Group       : Applications/File             Source RPM: tree-1.5.0-4.src.rpm
Size        : 41796                            License: GPL
Signature   : DSA/SHA1, Fri 19 Jan 2007 12:22:37 AM CST, Key ID 5326810137017186
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL         : http://mama.indstate.edu/users/ice/tree/
Summary     : A utility which displays a tree view of the contents of directories.
Description :
The tree utility recursively displays the contents of directories in a
tree-like format.  Tree is basically a UNIX port of the DOS tree
utility.
-------------------------------------------------------------------------------------
root@fixip:/var/cache/apt/archives# dpkg -p tree  (当查询未安装包,用I)
Package: tree
Priority: optional
Section: utils
Installed-Size: 92
Maintainer: Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>
Architecture: i386
Version: 1.5.1.1-1
Depends: libc6 (>= 2.6-1)
Size: 28414
Description: displays directory tree, in color
Displays an indented directory tree, using the same color assignments as
ls, via the LS_COLORS environment variable.
.
 Homepage: http://mama.indstate.edu/users/ice/tree/
Original-Maintainer: Florian Ernst <florian@debian.org>
-------------------------------------------------------------------------------------
5:检验包完整
rpm -V
dpkg -s

下面说一下,处理那个安装包的问题。google了半天没有解决办法。自己man解决掉了。

1:首先判断一下/etc/apache2是谁提供的。(切忌:目录后面不要加"/".)
root@fixip:~# dpkg -S /etc/apache2
apache2.2-common: /etc/apache2
2:那就查一下覆盖命令(从dpkg -h获取):
root@fixip:~# dpkg --force-help
dpkg forcing options - control behaviour when problems found:
 warn but continue:  --force-<thing>,<thing>,...
 stop with error:    --refuse-<thing>,<thing>,... | --no-force-<thing>,...
Forcing things:
 all [!]                Set all force options
 downgrade [*]          Replace a package with a lower version
 configure-any          Configure any package which may help this one
 hold                   Process incidental packages even when on hold
 bad-path               PATH is missing important programs, problems likely
 not-root               Try to (de)install things even when not root
 overwrite              Overwrite a file from one package with another
 overwrite-diverted     Overwrite a diverted file with an undiverted version
 bad-verify             Install a package even if it fails authenticity check
 depends-version [!]    Turn dependency version problems into warnings
 depends [!]            Turn all dependency problems into warnings
 confnew [!]            Always use the new config files, don't prompt
 confold [!]            Always use the old config files, don't prompt
 confdef [!]            Use the default option for new config files if one
                        is available, don't prompt. If no default can be found,
                        you will be prompted unless one of the confold or
                        confnew options is also given
 confmiss [!]           Always install missing config files
 conflicts [!]          Allow installation of conflicting packages
 architecture [!]       Process even packages with wrong architecture
 overwrite-dir [!]      Overwrite one package's directory with another's file
 remove-reinstreq [!]   Remove packages which require installation
 remove-essential [!]   Remove an essential package

WARNING - use of options marked [!] can seriously damage your installation.
Forcing options marked [*] are enabled by default.
3:





本文链接:http://www.52zhe.cn/read.php/123.htm
本文作者:kook(若就博客内所涉及的技术问题交流,请用下面的MSN或Gmail联系我)
联系方式:(MSN:kook#live.com) (Google talk:kookliu)
没有版权:GNU,转载时请注明“转载人”欠本人一顿饭,来日见面之时兑现!谢谢合作!
by kook | 分类: Ubuntu | 评论(0) | 引用(0) | 阅读(1258)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]