Checking installed packages in linux

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

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.

Читайте также:  Oracle linux postgresql odbc

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.

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

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

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.

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.

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

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.

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.

Источник

How do I check if a package is installed on my server?

dialog offering packages

I recently installed Ubuntu Server edition 13.10 (Saucy Salamander). But I have run into a bit of problem. At the end of the installation, it asks about several extra packages whether you want them or not, like OpenSSH server and virtual machine host. Here’s what I’m looking at: Now, my problem is that I can’t remember if I have checked the «virtual machine host» checkbox. How do I check if my server has the corresponding packages? What packages come with the virtual machine host?

$ apt-cache policy , e.g. $ apt-cache policy dillo

14 Answers 14

Are you looking to know about all dpkg commands with options? Have a read from the below link.

To List all Installed Packages

Here less is a simple text reader used to scroll through the list of packages in a new buffer that opens in the existing terminal window. The list will not be mixed with other terminal commands and output. Hit q to return to the terminal prompt. See man less for more info.

Читайте также:  Linux обзор всех окружений

To check whether a package is installed or not:

To check if the package is installed or not (for example, vlc ). If installed, launch the package:

Show the location where the package is installed. The -S (capital S) stands for «search»

sudo dpkg -S sudo dpkg -S skype 
dpkg -l | grep dpkg -l | grep pdf 

Do not depend on the exit code of dpkg -l packagename , as it might return with a 0 exit code even if the package is not fully installed — see: github.com/bitrise-io/bitrise/issues/433

@heypaleblue They are the same. From manual page: » dpkg can also be used as a front-end to dpkg-deb(1) and dpkg-query(1). The list of supported actions can be found later on in the ACTIONS section. If any such action is encountered dpkg just runs dpkg-deb or dpkg-query with the parameters given to it. «

What the answer does not mention is: which output of dpkg -l would inform that the package is installed?

How can an answer that suggests using dpkg -l to check whether a package is installed get over 300 upvotes without explaining which part of the output actually tells the user whether a package is installed or not? Please annotate your answer to explain that the first column of dpkg -l has to say ii or otherwise the package is not installed.

apt -qq list PACKAGE can also be used for checking whether the PACKAGE is installed.

If installed it’ll print something like (with [installed] at the end of the line):

$ apt -qq list awscli awscli/stable,now 1.4.2-1 all [installed] 

If not installed the output will be:

$ apt -qq list awscli awscli/stable 1.4.2-1 all 

You can also use the —installed option for that command to limit to matches which are actually installed.

What’s the -qq for? It seems to work identically without it, and that option isn’t in the manual man apt

@GabrielStaples It looks like the apt list command isn’t yet fully documented. Some quick testing on 16.04 seems to indicate that -q is a synonym for —quiet option. The first -q prevents the word «Done» being printed. The second also prevents «Listing. » from being printed.

Even on Bionic, apt list still seems to be «WIP». Anyway for interactive use it does the job. I think in general apt family isn’t meant for scripting, in which case you would still want dpkg .

This command is the Debian package manager.

You can list all the installed packages with

You can see details for a specific package with

And to learn if it is installed, use

dpkg -s packagename | grep Status 

You can learn which package contains the software you want with

In your case you should use this command to search the package name you want

apt-cache search virtual machine host 

Also apt-cache show to show detailed information about installed and installable versions of a package.

Simpler solution:

There is now an apt list command that lists available packages, and the —installed command will show only installed packages. You can also search for a specific package with

Читайте также:  Veeam proxy server linux

Or to see only the matching installed packages

There are also the —upgradeable and —all-versions flags.

If you do not know the exact package name, you can use apt search followed by part of it to see a list of related packages. This will allow you to use a partial name or regex term(s) to filter a list of available packages, but it does not have the nifty flags for filtering that apt list has.

Also see man apt for more information.

Really is apt list —installed | grep , the —installed part is mandatory

@ManuelJordan Yes and no. Technically the —installed is needed to see only installed packages (I’ve updated my post to make this clearer), but the grep is excessive since you can specify the package to the command directly.

Agree, ‘grep’ is a secondary filter . would be nice indicate the explicit difference between list and search .

I’ve found a way to check for package installation with just dpkg-query command and no pipes.

I searched for such solution while writing a task for ansible playbook.

You can do something like this:

/usr/bin/dpkg-query --show --showformat='$\n' '' 

This is just one another way to do the thing.

I am writing a new answer as Tasksel ‘Task names’ DO NOT show up in dpkg or apt queries. Meaning the other answers are incomplete (or wrong).

«I can’t remember If I have checked the ‘virtual machine host’ checkbox..»

Check if there is an asterisk by the name after re-running sudo tasksel (or an ‘ i ‘ if running tasksel —list-tasks ).

If you do not see this, then you probably do not have the ‘tasksel meta-package’ installed.

«..How do I check if my server has the corresponding packages?»

If you want to find out what is installed under the Virtual Machine Host tasksel meta-package:

(in your case tasksel —list-tasks | grep virt is enough)

This gives the proper task name and an indication as to whether it is installed.

In your case this tasksel name is virt-host .

«What packages come with the virtual machine host?»

From the last command, find the tasksel task name. This is needed for the next command:

tasksel --task-packages virt-host 

This lists the individual Tasksel meta-package (denoted by appended ‘^’) that make up the name. In your case it’s virt-host^ .

Once you find proper meta-name you can use apt:

 apt show virt-host^ | grep "Package:" 

(or apt-cache show . if apt show doesn’t work.)

This will show all packages making up the given meta package.

This will tell you if the individual package is installed/uninstalled (noted by 2nd letter: ‘i’ status means installed). Do this for all packages listed under the task/meta package.

This should answer the original questions.

Side note: /usr/share/tasksel/descs/ubuntu-tasks.desc also holds descriptions of Tasksel meta-packages. If you: grep «virt» /usr/share/tasksel/descs/ubuntu-tasks.desc it will show the proper APT meta-package name. (In your case this is ubuntu-virt-server ). You can also use apt commands with this meta-name.

If you are wanting to remove tasksel packages, this gets into the weeds a bit. Please consult this Ask Ubuntu answer or any number of other answers out there.

Please note that «meta» apt packages do not match Tasksel package names. Please consult the Tasksel Community Page for more info.

Источник

Оцените статью
Adblock
detector