23.6 C
Jaipur
Tuesday, October 19, 2021

How do I check if a package is installed on Debian and Ubuntu – Linux Hint

Must read

By reading this tutorial, you’ll learn how to check if a package is installed on Debian-based Linux distributions, including Ubuntu.

Checking if a specific package is installed using dpkg:

To check if a specific package is installed on Debian based Linux distributions, you can use the dpkg command followed by the -s (status) flag and the package name. The command below shows an example of dpkg, used to check the status of the package Steam.

As you can see, the command returns information on the package, including the following:

Package name: Package name.

Package status: Here, you can see the package status on your system.

Priority: There are 5 possible priority levels for packages: The priority ‘Required’ belongs to packages that are essential for the system; removing packages marked as ‘Required’ may lead to a system failure. The second possible priority mode for a is the ‘Important’ priority for packages that are not essential for the system but the user, for example, a text editor like nano or net-tools. The third priority is ‘Standard’, which includes packages that are defined to be installed by default. The fourth priority level is the ‘Optional’, which includes optional packages in Debian/Ubuntu installations. Finally, the fifth priority is ‘Extra’, which is deprecated and is replaced by ‘Optional’. The status ‘Extra’ was used for specialized packages.

Section: Packages are classified by categories; currently available categories include admin, database, cli-mono, debug, devel, doc, editors, education, gnustep, embedded, fonts, games, gnome, gnu-r, electronics, graphics, interpreters, hamradio, haskell, httpd, python, introspection, javascript, java, ruby, kde, localization, kernel, libdevel, libs, lisp, mail, math, metapackages, ocaml, net, news, misc, comm, oldlibs, otherosfs, perl, php, rust, science, shells, sound, text, video, tasks, tex, utils, vcs, web, x11, xfce, and zope.

Installed size: You can see the estimated required disk space in bytes to install the package.

Maintainer: This field shows the information on the package’s developer.

Architecture: Here, you can see the package architecture.

Version: Package version.

Depends: Package dependencies.

Description: Package description.

Homepage: Package/Developer website.

The screenshot below shows the output when you check a package that isn’t installed.

You can also use the dpkg command followed by the -l flag to check a specific package status, as shown in the example below.

Checking if a specific package is installed using dpkg-query:

The dpkg-query command can be used to show if a specific package is installed in your system. To do it, run dpkg-query followed by the -l flag and the name of the package you want information about. The example below shows how to check if the Steam package is installed.

You can use the same command to list all installed packages by omitting the package name, as shown in the example below.

Check if a package is installed using apt-cache:

The apt-cache command can also show information on packages, installed versions, and more. To get this output, you need to add the policy option followed by the package name, as shown in the example below.

Get a list of all installed packages using apt:

If you want to print a list of all installed packages on your system instead of checking if a specific package was installed, you can achieve it using the apt command as shown in the example below.

Get a list of all installed packages reading logs:

Another method widely used to get a list of all installed packages is reading apt or dpkg logs.

To read the apt log, run the following command.

cat /var/log/apt/history.log

To read the dpkg log to get information on installed packages, run the command below.

grep ” install “ /var/log/dpkg.log

You also can read compressed dpkg logs using the zgrep command instead of grep, as shown in the example below.

zgrep ” install “ /var/log/dpkg.log.11.gz

As you can see, compressed logs will give you partial information, but you can implement a wildcard (*) to read all compressed logs at once, as shown in the following example.

zgrep ” install “ /var/log/dpkg.log.*.gz

How to check upgraded and removed packages:

If you want to display information on upgraded packages only, you can achieve it using the command below.

As explained previously, with installed packages, you also can check compressed logs for upgraded packages using the wildcard, as shown in the following example.

zgrep “upgrade “ /var/log/dpkg.log.*.gz

If you want to list removed packages, the method is similar; just replace “upgrade” with “remove,” as shown below.

grep “remove “ /var/log/dpkg.log

Conclusion:

As you can see, Debian-based Linux distributions offer various ways to check a specific package status or list all installed, upgraded and removed packages. Commands explained in this tutorial are easy to apply and learning them is mandatory for any Debian-based distribution user. As you saw, these commands can also provide information on software versions, needed disk space, and more. You can get additional tips to list packages information with the tutorial See dpkg and apt history.

I hope this tutorial explaining how to check if a package is installed on Debian or Ubuntu was useful. Keep following Linux Hint for more Linux tips and tutorials.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest article