I'm looking for some standard way to get all installed packages in my Linux machines, but I'd like to achieve it independently of the distro.
I found some very good answers here for some specific distros like Debian/Ubuntu, Fedora/CentOS, etc., but I had no success in a distro-independent way to get this info.
My first option was:
List all directories in some specific places like /opt
or /usr/bin
.
But using this approach, I don't have the information about the version installed.
In the best case, I can get the names of installed packages and just that.
Some background:
I have a list of IP addresses and ports (in a spreadsheet) and need to SSH into each system and get the installed packages and their versions, but the distros may vary a lot.
It will be a one-time task, but other spreadsheets will come in the future, so I will use the same solution more than one time.
As I know some of the machines in the spreadsheet and based on the clients’ information, I can infer that the list are for servers, with just a few desktops. As I said before, the distros may vary a lot, but it’s safe to say that I have a great number of Ubuntu, Debian and CentOS machines.
For desktops, most are Ubuntu with some macOS.
I can use some Bash, Python or PHP script if that helps.
For the first version, I decided to ignore language-specific package managers such as npm
,rvm
, composer
, etc, even if the packages were installed globally.
In short: Is there any standard way to get all installed packages independent of the distro?