How can I get such a list from command line, including the version of each utility? Are they by default in the same file by any chance?


They're [probably] all the same (gold has an extra version -- see the end of this post).
But consider the rest of this answer code-golf for the best way to extract the versions.

dpkg -L binutils | grep "/usr/bin/" | xargs -i sh -c "{} --version"

Does pretty much what roadmr's does.

dpkg -L binutils | xargs -i sh -c "{} --version 2>/dev/null || exit 0"

Tries to run everything dpkg -L ... outputs. Obviously only the executables will run so we just need to redirect error (and make xargs ignore them).

dpkg -L binutils | xargs -i bash -c '[[ -x "{}" && -f "{}" ]] && {} --version'

Test that we're dealing with an executable file rather than filtering path.

sudo apt-get install parallel
dpkg -L binutils | grep /usr/bin/ | parallel {} --version
dpkg -L binutils | parallel {} --version 2>/dev/null
dpkg -L binutils | parallel '[[ -x "{}" && -f "{}" ]] && {} --version'

This time we use GNU parallel to do the same approaches. parallel lets us skip over certain inconveniences in xargs (like it not being able to skip over any non-zero exit code. man parallel is a genuinely good read.

With all that said, while shorter, all my examples fork out into a new shell (unavoidable with xargs, and sort of the point of parallel) so they're all somewhat slower than roadmr's. The first is the quickest.

Edit: Until now...

sh <(dpkg -L binutils | awk '/bin\// {print $0 " --version"}')

Only two forks (sort of) and it's as fast as the for loop (while much shorter).

Edit: They're actually not quite the same. gold has a secondary version (1.11) which the other commands don't.

$ sh <(dpkg -L binutils | awk '/bin\// {print $0 " --version"}') | \
    grep Binutils | sort -u | column -t
GNU  addr2line  (GNU  Binutils  for  Ubuntu)
GNU  ar         (GNU  Binutils  for  Ubuntu)
GNU  assembler  (GNU  Binutils  for  Ubuntu)
GNU  c++filt    (GNU  Binutils  for  Ubuntu)
GNU  dwp        (GNU  Binutils  for  Ubuntu)
GNU  elfedit    (GNU  Binutils  for  Ubuntu)
GNU  gold       (GNU  Binutils  for  Ubuntu  1.11
GNU  gprof      (GNU  Binutils  for  Ubuntu)
GNU  ld         (GNU  Binutils  for  Ubuntu)
GNU  nm         (GNU  Binutils  for  Ubuntu)
GNU  objcopy    (GNU  Binutils  for  Ubuntu)
GNU  objdump    (GNU  Binutils  for  Ubuntu)
GNU  ranlib     (GNU  Binutils  for  Ubuntu)
GNU  readelf    (GNU  Binutils  for  Ubuntu)
GNU  size       (GNU  Binutils  for  Ubuntu)
GNU  strings    (GNU  Binutils  for  Ubuntu)
GNU  strip      (GNU  Binutils  for  Ubuntu)

Try this:

for util in `dpkg --listfiles binutils |grep "\/usr\/bin\/"`; do
    echo -n "$util -> "; echo "" | $util --version

This gets all the binaries in the binutils packages and queries each one with its --version parameter. I echo an empty string for those that expect input in the terminal.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.