Finding out what package a command came from
Is there a generalised way to find out what package caused the installation of a command?
- drop to a command prompt (Menu > Applications > Accessories > Terminal)
dpkg-query --search 'command'where ‘command’ is the command whose owning package you’re trying to find.
Open a terminal and try the following commands:
dpkg -S 'command name'
dpkg -S /bin/ls
You can also obtain detailed status information about coreutils package, enter:
dpkg -s coreutils
Package: coreutils Essential: yes Status: install ok installed Priority: required Section: utils Installed-Size: 9040 Maintainer: Ubuntu Core Developers Architecture: i386 Version: 5.97-5.3ubuntu3 Replaces: textutils, shellutils, fileutils, stat, debianutils (<= 2.3.1), dpkg (<< 1.13.2) Provides: textutils, shellutils, fileutils Pre-Depends: libacl1 (>= 2.2.11-1), libc6 (>= 2.6-1), libselinux1 (>= 2.0.15) Conflicts: stat Description: The GNU core utilities This package contains the essential basic system utilities. . Specifically, this package includes: basename cat chgrp chmod chown chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold groups head hostid id install join link ln logname ls md5sum mkdir mkfifo mknod mv nice nl nohup od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir sha1sum seq shred sleep sort split stat stty sum sync tac tail tee test touch tr true tsort tty uname unexpand uniq unlink users vdir wc who whoami yes Original-Maintainer: Michael Stone
From the command name you can use the ‘type’ and ‘dpkg’ commands to determine the package which is responsible for their installation. For example to find out which package installed the command ‘who’ you could do the following commands at a command prompt:
$ type who who is /usr/bin/who $ dpkg -S /usr/bin/who coreutils: /usr/bin/who
there is another one method, maybe a little silly, but faster than previous ones 🙂 just mistype a command and you will get correct command name and package it came from.
pawel@pawel-desktop:/var/www$ sfn No command 'sfn' found, did you mean: Command 'sn' from package 'mono-devel' (main) Command 'sfc' from package 'syfi-bin' (universe) Command 'svn' from package 'subversion' (main) sfn: command not found
You can also do it with one line:
dpkg -S $(which command)
For example, I want to know what package contains
dpkg -S $(which ls)
And here is the output:
So now I know that ls command, /bin/ls file, comes from coreutils package.
Now for a completely different approach.
Go to packages.ubuntu.com and follow your nose. In particular, scroll down to “Search the contents of packages” and enter the file name or system command.