How to find the installation method for a given command?
Is there a command in Ubuntu, given a command name, it will return that information?
No, there isn' t. You need to do some investigations. First, the type
command will reveal information about the nature of the command:
type <command>
This command will indicate whether it is a shell built-in, an alias, and if an executable, whether it is hashed, i.e. indexed for speedy retrieval –this indicates you have run the command at least once before in the session–, or where the binary is located.
The place where the executable is installed already hints towards how a package was installed. The command which
reveals its location:
which <command>
- Executables of packages installed using the regular APT system, i.e., from the Ubuntu software repositories, from a PPA you added or from a downloaded
.deb
installation file, will typically be installed in/usr/bin
or/bin
. Use the commanddpkg -S filename-search-pattern
to find out which package has installed the file (source). - Executables installed by Snap are exposed in a dedicated directory that is added to the
PATH
, i.e./snap/bin
. Confirm that this is a snap package by finding it in the output ofsnap list
. - No executable are exposed in the PATH by Flatpak. You can, however, tell whether a package is installed that way from the output of
flatpak list --app
. - Executable AppImages can be placed anywhere. There is thus no general method to recognized their source. Typically, however, they will not have been renamed and then can be easily recognized by their extension
.AppImage
.
In case your package was installed as a .deb
, you can further differentiate looking at the output of:
apt policy <package>
An URL in the output will directly hint from which source the package came if it was installed from a software source. The absence of an URL indicates the package was installed from a locally downloaded .deb
.