Preloader
Ubuntu
  • Estimated reading time: 1 Minute

How to check if a package is installed with the CLI in Ubuntu 16.04

If you manage the installed packages on your ubuntu server, you may know that the installation of a package that is already installed may lead in some circunstances to data loss. That's why is pretty useful to verify wheter a package has been already installed or not. This can be easily done in Ubuntu using the debian package manager (dbpk).

To verify if a package has been installed with a verbose output, you can use the following command:

dpkg -s <package name> | grep Status

# example with the potrace package
dpkg -s potrace | grep Status

For example, running the previous command will show the following output in the terminal (as long as potrace isn't installed):

dpkg-query: package 'potrace' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.

If you feel uncomfortable with all the generated output, you can use even a shorter variant that generates less output:

dpkg -l <package name>

# example with the potrace package
dpkg -l potrace

Running the previous command on a system (assuming that potrace isn't installed) would generate the following output:

dpkg-query: no packages found matching potrace

Happy server management !

Share:
Carlos Delgado

Carlos Delgado

Senior Software Engineer at Corvix. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Related articles
How to install the latest version of Git in Ubuntu 20.04
26 Aug, 2022
  • Estimated reading time: 1 Minute
How to install aapanel in Ubuntu 20.04
14 Aug, 2022
  • Estimated reading time: 1 Minute
How to install Prometheus Node Exporter on Ubuntu 20.04
27 Mar, 2022
  • Estimated reading time: 4 Minutes
How to extract the content of a tar.gz file in Ubuntu
16 Nov, 2021
  • Estimated reading time: 1 Minute
How to install Anaconda in Ubuntu 20.04
6 Nov, 2021
  • Estimated reading time: 3 Minutes
How to install Elasticsearch 7 in Ubuntu 20.04
29 Apr, 2021
  • Estimated reading time: 5 Minutes
Our Sponsors

Our blog is proudly supported by industry-leading sponsors.