Identifying the system package manager
35
votes
6
answers
101490
views
Is there a way (from a script) to identify the default system package manager?
To clarify, what I want to do is run a given command and, on Debian or any of its derivatives it'll return something like "apt", on openSUSE it'll return "zypp", on Fedora et al it'll return "yum", on Arch Linux it'll return "pacman" etc.
I know I can do this with something like the following, I just wondered if there was a more robust method that won't break as soon as there is an executable with the same name.
which apt >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "apt"
fi
# etc...
Asked by DrAl
(453 rep)
Aug 22, 2012, 02:49 PM
Last activity: Mar 15, 2025, 05:53 PM
Last activity: Mar 15, 2025, 05:53 PM