Skip to content

Check if a given package is installed in constant time

I usually use apt list --installed | grep package.

But #6 runs this in a loop which is inefficient. An alternative could be to save it and search in it.

DuckDuckGo and Google search APT check if a file is installed.

apt list --installed -qq python3.10
echo $?
python3.10/jammy-updates,jammy-security,now 3.10.12-1~22.04.9 amd64 [installed,automatic]
0

Source: The Ask Ubuntu answer 823630

-qq is necessary to get rid of Listing... Done.

apt list --installed -qq python3.11
echo $?
0

Related to #26 and #9.

Edited by Benjamin Loison