If you have dlocate
installed, there's an easy way to list all the commands in an installed package:
dlocate -lsbin PACKAGE-NAME
With just dpkg
, you can list the files in the standard PATH directories (they're almost all executable programs, with very few exceptions):
dpkg -L PACKAGE-NAME… | sed -n 's!^\(/s\?bin\|/usr/s\?bin\|/usr/games\)/!!p' | sort -u
The exceptions are a couple directories — as of Debian wheezy, just two: /usr/bin/mh
and /usr/bin/nu-mh
.
If the package isn't installed, replace dpkg -L
by apt-file -F list
:
apt-file -F list PACKAGE-NAME… | sed -n 's!^\(/s\?bin\|/usr/s\?bin\|/usr/games\)/!!p' | sort -u
While there are executable files in other directories, they are not meant to be executed directly, which makes them irrelevant here.
These methods all miss a set of programs: those that are provided through the alternatives mechanism. For example, for the ftp
package, only netkit-ftp
and pftp
are provided, but this package actually provides the ftp
command, because /usr/bin/ftp
is a symbolic link to /etc/alternatives/ftp
which is a symbolic link to one of the ftp
implementations on the system, potentially /usr/bin/netkit-ftp
. The following command (which isn't an example of good programming, just a big one-liner) lists the commands provided by a package via the alternatives mechanism, as currently configured.
perl -lwe 'foreach (`dpkg -L @ARGV`) {chomp; ++$p{$_}} foreach (</bin/* /sbin/* /usr/bin/* /usr/sbin/*>) {$e = readlink; next unless defined $e and $e =~ m!^/etc/alternatives/!; $t = readlink $e; print if $p{$t}}' PACKAGE_NAME…
If you want to list the commands that could be provided via an alternative which is currently configured to point to a different package, you need to parse the files in /var/lib/dpkg/alternatives
.
Symbolic links and configuration files that implement the alternatives mechanisms are not registered in packages but registered automatically in postinst
, which makes it difficult (and in fact technically impossible if a package's installation script doesn't follow conventions) to query the alternatives provided by an uninstalled package.