Is there a method for find out information about an installed package? Such as how it was installed such as via a package manager such as DNF, snap or compiled by the user?

Sometimes I can't remember how I installed a specific package but I always need to include this kind of information in bug reports etc. Is a tool that can provide this kind of information? If not any help in write a script to do this job would be great appreciated.


You need to ask whatever package manager could have been used - only the package manager stores meta-information about what packages has been installed, and which files are in the package. There's no way to get such information from a naked file.

You didn't say what flavour of distribution you use, but I recommend always using a single package manager (apt for me), and putting stuff that is compiled by the user somewhere else (for me, /usr/local, managed with stow, and I keep a list of packages). This way it's easy to find out to which package a particular file belongs.

If you use a dozen package managers or so (why?), you could write a script that queries each of them in turn.


I keep track of stuff I compiled from source by making a file for each package I compiled in /usr/local/packages/<packagename>. I need this anyway because it contains information about how I compiled it (often you need to make adjustments, fix a few things that won't compile with a newer gcc etc.) in case I need to compile it again when I upgrade it. And since I have this file, I also add information about where I downloaded the source, what version it is, what it does, what the name of the source tarball is, etc. I keep track of the installed files by installing everything into /usr/local/stow/<packagename>-<version> (which also sometimes needs adjustments to Makefiles, or ./configure --prefix, etc.), and then use stow to make links to it in /usr/local. I've described this in detail here.

You can also make really deb or rpm packages out of stuff you compile yourself, but this is more work than keeping track of it with stow.

  • Okay I see. Thanks for the info. I didn't mention my distros because I was looking for a 'general' solution (I use Ubuntu/apt and Fedora/dnf). I'm mainly use F27 + dnf, but where no packages are available I need to use snaps or compile from source. I perhaps I'll write a script to ask apt, dnf for info on an argument supplied on the commandline and show whether if matches were found. How do you keep track of stuff that you've complied from source? Is there any way to 'manually' add an entry to a package manager? – Bprodz Apr 19 '18 at 11:57
  • 2
    This command will print a list with install time / with the last installed rpm package at line 1 : $ rpm -qa --last > last-packages.txt – Knud Larsen Apr 19 '18 at 16:30
  • 1
    And similar for Ubuntu : $ ls -tl /var/lib/dpkg/info | grep list > list-deb.txt – Knud Larsen Apr 19 '18 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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