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 -sdoes 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 gccprints:On a CentOS system,
rpm -q gccprints: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 snmpdprintspackage snmpd is not installed, that’s probably just the information you need.Both
dpkg -sandrpm -qset the exit status accordingly, reporting failure if the package isn’t installed.