CentOS equivalent of dpkg -s

I am adapting a ready-made script for CentOS that was previously written for Ubuntu.

In the Ubuntu script, the dpkg -s {some program} command is often called. 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 a package manager. The rpm -q command is similar, but it searches for packages, 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 dpkg -s command?

+6
source share
1 answer

dpkg -s takes the package name as an argument, not a file or program. (In many cases, the 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 < ubuntu-devel-discuss@lists.ubuntu.com > 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 < debian-gcc@lists.debian.org > 

On a CentOS system, rpm -q gcc prints:

 gcc-4.1.2-50.el5 

It does not print so much information, but if everything you do checks to see if the package is installed, this should be fine. If you need more information or other options, man rpm ; Other requests are available.

If rpm -q snmpd displays package snmpd is not installed , this may be the information you need.

Both dpkg -s and rpm -q respectively set the exit status, reporting a failure if the package is not installed.

0
source

Source: https://habr.com/ru/post/896616/


All Articles