1

I found this exact question for Debian here: List all commands of a specific Debian package

But it seems no one has ever asked this for RHEL/CentOS (or OpenSUSE for that matter).

For instance, I can run rpm -qf $(which dig) to find out that dig comes from the bind-utils package. I can run yum -C info bind-utils to quickly see the data on that package...but how can I see what other commands are included in the bind-utils package?

Ideally the solution should be independent of my $PATH variable, as even with a broken path or a non-system user path (e.g. not including /sbin), I might simply want to know what commands were installed from a given package.

3
  • 1
    Someone else will have something better, but here's something quick & dirty: rpm -ql $package | grep bin/ -- which simply lists the files in the package and greps for a binary path (sbin or bin).
    – Jeff Schaller
    Oct 14, 2015 at 1:46
  • Yep, and yours is simpler than mine. Mine handles the small edge case of executable files being included elsewhere than bin directories, but yours is probably totally sufficient in practice.
    – Wildcard
    Oct 14, 2015 at 1:56
  • 1
    It's not at all uncommon for executables to be in non- bin/ directories. Many packages have wrappers or symlinks in /bin or /usr/bin and executables somewhere under /usr/lib or /usr/share. mailman, for example, has many executables under /usr/lib/mailman - most of them are intended to be executed by the mailman system itself rather than on the command line.
    – cas
    Oct 14, 2015 at 2:11

2 Answers 2

2

Ha, I already found it; it's rpm -ql bind-utils as Jeff Schaller noted in the comments.

A slightly more polished version that filters out non-executables from the list is:

for file in $(rpm -ql packagename) ; do test -x $file && test -f $file && echo $file ; done

3
  • 1
    test -f is redundant once you have test -x (which says "file exists -and- is executable)
    – Jeff Schaller
    Oct 14, 2015 at 2:09
  • 1
    Nope; I checked the manual and also tested it—test -x will return directories as well as files.
    – Wildcard
    Oct 14, 2015 at 2:17
  • good catch -- packages do list directories, so your test is good
    – Jeff Schaller
    Oct 14, 2015 at 2:20
0

Use below one liner command for listing a package's command:

 rpm -ql systemd | grep -w 'bin\|sbin' | awk -F '/' '{print $NF}' | xargs man head | grep ' - ' | grep -vi 'No manual' 2> /dev/null 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .