Check if a package is installed QUICKLY!

How can I check if a package is installed by only checking the local system, not querying online repository and the like?

So fare I found this command:

zypper search --file-list fdisk

But it’s still very slow, 1.6 seconds

On my Debian box I can run:

dpkg-query --show --showformat=' ${db:Status-Status} ' fdisk

It’s done in 0.05 seconds!

(I’m checking for installed packages in scripts so the time matters)


mariatest-gcn1:~ # time rpm -q mariadb
mariadb-10.4.13-4.1.x86_64


real	0m0.014s
user	0m0.013s
sys	0m0.000s

I win.

YES, openSUSE always win lol!
Just switched from Debian - I cry for not moving to SUSE many year ago! It’s really an improvement in so many ways (server use, no idea about desktop)

I keep results I wouldn’t have interest in out of my search results, while versions are typically as much my interest as yes or no:

# cat /usr/local/bin/zypsei
#!/bin/sh
zypper --no-refresh se -s -i $*  | egrep -v 'debug|devel|srcp|openSUSE-20' | egrep 'x86|noarch'| sort
# time zypsei fdisk
i | gptfdisk  | package | 1.0.1-lp151.3.4    | x86_64 | OSS
i | libfdisk1 | package | 2.33.1-lp151.3.6.1 | x86_64 | Update

real    0m3.672s
user    0m2.571s
sys     0m0.065s

I would suggest a tie – “normal user” – not the user “root” –


 > time rpm -q mariadb
mariadb-10.4.17-lp152.2.8.1.x86_64

real    0m0,017s
user    0m0,010s
sys     0m0,005s
 >