A way to check if a package is installed on Linux in the Debian system _linux

Source: Internet
Author: User

If you are managing a Debian or Ubuntu server, you may often use dpkg or apt-get commands. These two commands are used to install, uninstall, and update packages.

In this article, let's look at how to check if a package is installed under a Deb based system.

To check for specific packages, such as whether Firefox is installed, use this command:

  Dpkg-s Firefox

Sample output:

  Package:firefox status:install OK installed priority:optional section:web installed-size:93339 Maintaine R:ubuntu Mozilla Team <ubuntu-mozillateam@lists.ubuntu.com> architecture:amd64 version:35.0+build3-0ubuntu0.1  4.04.2 Replaces:kubuntu-firefox-installer Provides:gnome-www-browser, Iceweasel, Www-browser depends:lsb-release, Libasound2 (>= 1.0.16), libatk1.0-0 (>= 1.12.4), Libc6 (>= 2.17), Libcairo2 (>= 1.2.4), Libdbus-1-3 (>= 1. 0.2), Libdbus-glib-1-2 (>= 0.78), LIBFONTCONFIG1 (>= 2.9.0), Libfreetype6 (>= 2.2.1), LIBGCC1 (>= 1:4.1.1), Li bgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.37.3), libgtk2.0-0 (>= 2.24.0), libpango-1.0-0 (>= 1.22.0), l ibpangocairo-1.0-0 (>= 1.14.0), Libstartup-notification0 (>= 0.8), Libstdc++6 (>= 4.6), libx11-6, Libxcomposite1 (>= 1:0.3-1), Libxdamage1 (>= 1:1.1), Libxext6, Libxfixes3, Libxrender1, Libxt6 Recommends:xul-ext -ubufox, LIBCANBERRA0, Libdbusmenu-glib4, Libdbusmenu-gtk4 suggests:ttf-lyx conffiles:/etc/firefox/syspref.js 09e457e65435a1a043521f2bd19cd2a1/etc/app Ort/blacklist.d/firefox Ee63264f847e671832d42255912ce144/etc/apport/native-origins.d/firefox 7c26b75c7c2b715c89cc6d85338252a4/etc/apparmor.d/usr.bin.firefox F54F7A43361C7ECFA3874ABCA2F292CF Description: Safe and easy Web browser to Mozilla Firefox delivers safe, easy web browsing. A familiar user interface, enhanced security features including protection from online identity theft, and integrated
  Search let's most out of the web.

 Xul-appid: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}

As you can see, Firefox has been installed.

Again, you can use the Dpkg-query command. This command will have a better output, of course, you can use the wildcard character.

  Dpkg-query-l Firefox

Sample output:

  Desired=unknown/install/remove/purge/hold
  | Status=not/inst/conf-files/unpacked/half-conf/half-inst/trig-await/trig-pend
  |/Err?= (none)/Reinst-required (Status,err:uppercase=bad)
  | | /Name Version Architecture Description
  +++-====================================-=======================-===== ==================-=============================================================================
  II Firefox 35.0+build3-0ubuntu0.14 AMD64 Safe and easy Web browser from Mozilla

To list all the packages installed in your system, enter the following command:

  Dpkg--get-selections

Sample output:

  AbiWord Install
  Abiword-common install
  accountsservice install
  ACL install
  adduser Install Alsa-base Install
  alsa-utils install
  anacron install
  app-install-data install
  apparmor Install
  .
  .
  .
  Zeitgeist install
  zeitgeist-core install
  zeitgeist-datahub
  install zenity Install Zenity-common Install
  Zip install
  zlib1g:amd64 install zlib1g:i386 install
  

The above output can be very long, depending on the package that your system has installed.

You can also filter through grep to cut to more precise packages. For example, I want to use the dpkg command to view the GCC packages installed in the system:

  Dpkg--get-selections | grep gcc

Sample output:

  GCC install
  gcc-4.8 install
  gcc-4.8-base:amd64 install gcc-4.8-base:i386 install
  : AMD64 Install
  gcc-4.9-base:i386 install
  libgcc-4.8-dev:amd64
  install libgcc1:amd64 Install libgcc1:i386 Install

In addition, you can use the "-L" parameter to find the location of the files in the package.

Dpkg-l gcc-4.8

Sample output:

  /.
  /usr
  /usr/share
  /usr/share/doc
  /usr/share/doc/gcc-4.8-base
  /usr/share/doc/gcc-4.8-base/readme. Bugs
  /usr/share/doc/gcc-4.8-base/news.html
  /usr/share/doc/gcc-4.8-base/quadmath
  /usr/share/doc/ gcc-4.8-base/quadmath/changelog.gz
  /usr/share/doc/gcc-4.8-base/gcc
  ...
  /usr/bin/x86_64-linux-gnu-gcc-4.8
  /usr/bin/x86_64-linux-gnu-gcc-ar-4.8
  /usr/bin/x86_64- linux-gnu-gcov-4.8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.