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 command dpkg -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 of snap 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
.
whereis
to find it's location. That detail alone can tell you the type of package in many cases & that outpu will decide if I need to go further.. ie. I mightdpkg -S
if the first result pointed to a deb installed etc.. but I'll also know my release details which influence how I interpret results. eg.whereis ls
gives me detail for thedpkg -S
, but for my releasewhereis chromium
tells me it's a snap so I have no need for any further searching... – guiverc Dec 24 '21 at 05:19apt policy <packagename>
might be useful for determining which – steeldriver Dec 24 '21 at 13:01