Closed. This question is off-topic。它当前不接受答案。
想要改善这个问题吗? Update the question,所以它是用于堆栈溢出的on-topic。
9年前关闭。
Improve this question
我正在为以前为Ubuntu编写的CentOS修改一个准备脚本。
在Ubuntu脚本中,经常调用
CentOS中的等效功能是什么?我知道RPM是程序包管理器。命令
例如,运行
我的问题是,CentOS与Ubuntu命令
在CentOS系统上,
它不会打印太多信息,但是如果您只是检查软件包是否已安装,就可以了。如果您需要更多信息或其他选项,请
如果
想要改善这个问题吗? Update the question,所以它是用于堆栈溢出的on-topic。
9年前关闭。
Improve this question
我正在为以前为Ubuntu编写的CentOS修改一个准备脚本。
在Ubuntu脚本中,经常调用
dpkg -s {some program}
命令。例如,dpkg -s snmpd
是一个这样的命令,用于检查是否已安装SNMP守护程序。CentOS中的等效功能是什么?我知道RPM是程序包管理器。命令
rpm -q
与之类似,但是它查找软件包而不是程序。例如,运行
rpm -q snmpd
返回:package snmpd is not installed
我的问题是,CentOS与Ubuntu命令
dpkg -s
等效吗? 最佳答案
dpkg -s
确实将软件包名称(而不是文件或程序)作为参数。 (在许多情况下,程序将与提供该程序的程序包具有相同的名称。)
例如,在我的Ubuntu系统上,dpkg -s gcc
打印:
Package: gcc
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 64
Maintainer: Ubuntu Developers <[email protected]>
Architecture: i386
Source: gcc-defaults (1.98ubuntu3)
Version: 4:4.5.2-1ubuntu3
Provides: c-compiler
Depends: cpp (>= 4:4.5.2-1ubuntu3), gcc-4.5 (>= 4.5.2-1~)
Recommends: libc6-dev | libc-dev
Suggests: gcc-multilib, make, manpages-dev, autoconf, automake1.9, libtool, flex, bison, gdb, gcc-doc
Conflicts: gcc-doc (<< 1:2.95.3)
Description: The GNU C compiler
This is the GNU C compiler, a fairly portable optimizing compiler for C.
.
This is a dependency package providing the default GNU C compiler.
Original-Maintainer: Debian GCC Maintainers <[email protected]>
在CentOS系统上,
rpm -q gcc
打印:gcc-4.1.2-50.el5
它不会打印太多信息,但是如果您只是检查软件包是否已安装,就可以了。如果您需要更多信息或其他选项,请
man rpm
;其他查询可用。如果
rpm -q snmpd
显示package snmpd is not installed
,则可能只是您需要的信息。dpkg -s
和rpm -q
都相应地设置了退出状态,如果未安装该软件包,则报告失败。关于ubuntu - 相当于dpkg -s的CentOS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7303745/
10-12 16:50