I'm adapting a prepare script for CentOS that was previously written for Ubuntu.
In the Ubuntu script, the command dpkg -s {some program}
is called frequently. For example, one such command is dpkg -s snmpd
to check if the SNMP Daemon is installed.
What is the equivalent in CentOS? I know that RPM is the package manager. The command rpm -q
is similar, but it looks for packages and not programs.
For example, running rpm -q snmpd
returns:
package snmpd is not installed
My question is, what is the CentOS equivalent of the Ubuntu command dpkg -s
?
dpkg -s
does take a package name, not a file or program, as an argument. (In many cases, a program will have the same name as the package that provides it.)
For example, on my Ubuntu system, dpkg -s gcc
prints:
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]>
On a CentOS system, rpm -q gcc
prints:
gcc-4.1.2-50.el5
It doesn't print as much information, but if all you're doing is checking whether a package is installed, it should be ok. If you need more information or other options, man rpm
; other queries are available.
If rpm -q snmpd
prints package snmpd is not installed
, that's probably just the information you need.
Both dpkg -s
and rpm -q
set the exit status accordingly, reporting failure if the package isn't installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With