I'm working with a Raspberry Pi B+ and Raspbian 5/5/2015 and some guides that are a few years old. I've got an external NTFS HDD hooked up to the Pi. Due to the articles age(s), common practices have changed, and it turns out that certain packages and features and functions are now built-in and/or automatic.

For example, I found out that Raspbian will handle the automounting of an NTFS drive/volume if you just install ntfs-3g. All instructions and guidance I could find (IRC, raspberry pi forum, and a Linux dude I know) all went extremely technical doing who-knows-what to my system to try to assist me, when in reality we were all tripping over automatic features that no one knew about or thought to check. I've since installed Raspbian fresh to a new SD card and so far just turned on SSH, updated apt-get, and installed ntfs-3g.

This is the article I am using right now: http://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/?PageSpeed=noscript

My next step is to get Samba up and running. Yes, I know Linux people hate Windows, but I'm a Windows guy, so until I can know enough about Linux for a Linux system to be my fallback, Windows machines are my fallbacks. Eventually this Raspberry Pi will get a multi-TB drive, though for right now it's just a few GB; which is why it needs to be NTFS.

I would like to check if Samba is installed, since the next step in my instructions tell me how to install and configure it. I've tried a few commands and I'm not sure what to do with the results or how to use them. I searched here and the technical details are above my capabilities and I don't think they address my seemingly simple need to find out if a package is installed or not.

I tried:

apt-cache dump

this gave me way too much data. It scrolled down for a few minutes. I got this from The Raspberry Pi Handbook 3rd Edition (Link - Amazon)

I tried

apt-cache showpkg samba
Package: samba
2:3.6.6-6+deb7u5 (/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_                                  wheezy_main_binary-armhf_Packages)
 Description Language:
                 File: /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_d                                  ists_wheezy_main_binary-armhf_Packages
                  MD5: 0122ac62ef5f4ae21eb2e195eb45ad1d

Reverse Depends:
  winbind,samba 2.2.3-2
  swat,samba 2:3.6.6-6+deb7u5
  smbclient,samba 2.999+3.0.alpha21-4
  samba4-common-bin,samba 2:3.3.0~rc2-5
  samba4,samba 2:3.3.0~rc2-5
  samba-dbg,samba 2:3.6.6-6+deb7u5
  samba-common-bin,samba 3.0.20b-1
  samba-common,samba 3.0.20b-1
  nautilus-share,samba 3.0.27a
  libwbclient0,samba 2:3.4.1
  libpam-winbind,samba 2.2.3-2
  libnss-winbind,samba 2.2.3-2
2:3.6.6-6+deb7u5 - samba-common (5 2:3.6.6-6+deb7u5) libwbclient0 (5 2:3.6.6-6+d                                  eb7u5) libacl1 (2 2.2.51-8) libattr1 (2 1:2.4.46-8) libc6 (2 2.13-28) libcap2 (2                                   2.10) libcomerr2 (2 1.01) libcups2 (2 1.4.0) libgcc1 (2 1:4.4.0) libgssapi-krb5                                  -2 (2 1.10+dfsg~) libk5crypto3 (2 1.6.dfsg.2) libkrb5-3 (2 1.10+dfsg~) libldap-2                                  .4-2 (2 2.4.7) libpam0g (2 libpopt0 (2 1.14) libtalloc2 (2 2.0.4~git20                                  101213) libtdb1 (2 1.2.7+git20101214) zlib1g (2 1:1.1.4) debconf (18 0.5) debcon                                  f-2.0 (0 (null)) libpam-runtime (2 1.0.1-11) libpam-modules (0 (null)) lsb-base                                   (2 3.2-13) procps (0 (null)) update-inetd (0 (null)) adduser (0 (null)) dpkg (2                          openbsd-inetd (16 (null)) inet-superserver (0 (null)) smbldap-tools (0                                   (null)) ldb-tools (0 (null)) ctdb (0 (null)) logrotate (0 (null)) tdb-tools (0                                   (null)) samba4 (3 4.0.0~alpha6-2) samba-common (1 2.0.5a-2)
2:3.6.6-6+deb7u5 -
Reverse Provides:
pi@raspberrypi ~ $ apt-cache showpkg ntfs-3g
Package: ntfs-3g
1:2012.1.15AR.5-2.1+deb7u2 (/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_wheezy_main_binary-armhf_Packages) (/var/lib/dpkg/status)
 Description Language:
                 File: /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_wheezy_main_binary-armhf_Packages
                  MD5: b2df024e8627b5d253b85f35263376ef

Reverse Depends:
  ntfs-3g-dev,ntfs-3g 1:2012.1.15AR.5-2.1+deb7u2
  ntfs-3g-dbg,ntfs-3g 1:2012.1.15AR.5-2.1+deb7u2
1:2012.1.15AR.5-2.1+deb7u2 - debconf (18 0.5) debconf-2.0 (0 (null)) libc6 (2 2.13-28) libfuse2 (2 2.8.1) libgcc1 (2 1:4.4.0) libgcrypt11 (2 1.4.5) libgnutls26 (2 2.12.17-0) multiarch-support (0 (null)) fuse (0 (null)) libntfs-3g75 (0 (null)) ntfsprogs (3 1:2011.10.9AR.1-3~) libntfs-3g75 (0 (null)) ntfsprogs (0 (null))
1:2012.1.15AR.5-2.1+deb7u2 -
Reverse Provides:
pi@raspberrypi ~ $ apt-cache showpkg ntfsprogs
Package: ntfsprogs
1:2012.1.15AR.5-2.1+deb7u2 (/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_wheezy_main_binary-armhf_Packages)
 Description Language:
                 File: /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_wheezy_main_binary-armhf_Packages
                  MD5: 95f41af9cf1d0b5b66afb7d2a9e7c75d

Reverse Depends:
  ntfs-3g,ntfsprogs 1:2011.10.9AR.1-3~
1:2012.1.15AR.5-2.1+deb7u2 - ntfs-3g (0 (null))
1:2012.1.15AR.5-2.1+deb7u2 -
Reverse Provides:

but I'm not sure what to make of the results. I can't tell if it's going to apt-get the servers and getting information, or pulling it from my system.

I tried :

dpkg --get-selections

which I got from here: http://www.howtogeek.com/howto/linux/show-the-list-of-installed-packages-on-ubuntu-or-debian/?PageSpeed=noscript but I think I'm running into the same problem. It seems the syntax has changed since 2007. The man page / help file seems to lead me to believe that the command should work

Usage: dpkg [<option> ...] <command>

--get-selections [<pattern> ...] Get list of selections to stdout.

but I get an error:

dpkg –get-selections samba
dpkg: error: need an action option

I found a few wuestions here that are related, but don't give me what I am looking for. I am interested in just knowing what's installed, but I guess that's a topic for another question.

  • Are Raspban and Debian interchangeable? I would think not since Raspbian is specific to the Raspberry Pi and Debian probably can run on multiple hardware platforms. – YetAnotherRandomUser Jul 19 '15 at 22:49
  • Raspbian and Debian are not interchangeable, but Raspbian is a Debian derivative with the same package management mechanisms. The answers below using commands like apt-cache and dpkg apply equally to both (and to Ubuntu, Linux Mint, etc.) – Benjamin Staton Jul 11 '17 at 22:45

apt-cache showpkg shows detailed information about potentially installable packages. It does indicate whether the package is installed, kind of, but not in a very readable way:

2:3.6.6-6+deb7u5 (/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_wheezy_main_binary-armhf_Packages)

If the package was installed, you'd see (/var/lib/dpkg/status) at the end of the line. However, this isn't fully reliable, because you'd also see this indication if the package was known to your system but not fully installed, e.g. if it was in the “package uninstalled but configuration files left over” state.

A more useful apt-cache subcommand is apt-cache policy. It clearly shows the installed version (if any) and the available version(s). For example, here's output from a machine which has samba installed but not samba-dev:

  Installed: 2:4.1.17+dfsg-2
  Candidate: 2:4.1.17+dfsg-2
  Version table:
 *** 2:4.1.17+dfsg-2 0
        500 http://ftp.fr.debian.org/debian/ jessie/main amd64 Packages
        100 /var/lib/dpkg/status
  Installed: (none)
  Candidate: 2:4.1.17+dfsg-2
  Version table:
     2:4.1.17+dfsg-2 0
        500 http://ftp.fr.debian.org/debian/ jessie/main amd64 Packages

Alternatively, you can use the dpkg command to get information about your current system. APT is the software that manages the download of packages, dependency analysis, etc. Dpkg is the low-level software that carries out the actual installation of a package file.

dpkg -l samba

This shows a line beginning with i if the package is installed, and a line beginning with u or p or nothing at all if the package is not installed.

$ dpkg -l samba samba-dev
| 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  samba          2:4.1.17+dfs amd64        SMB/CIFS file, print, and login s
dpkg-query: no packages found matching samba-dev

(dpkg-query is the dpkg subcommand that returns information about the package database.)

Note that if you just want to ensure that a package is installed, you can simply run

apt-get install samba

This won't do anything if the latest version of the package that's available in your distribution is already installed. It will install the package if it isn't installed yet, and it will upgrade it if you have an older version.

dpkg -l | grep -e package1 -e package2 ....

Will list packages you are interested with their current insstallation stauts. The output will be something like this

bala@bala-laptop:~$ dpkg -l | grep apache2
ii  apache2                                2.4.10-10                            amd64        Apache HTTP Server

The first 2 characters tell the status - ii here means First i - marked for installation Second i - Successfully installed

There are other status codes like r meaning marked for removal, p meaning marked for purging etc.

  • +1 for power plus simplicity, and allowing partial matches if you don't know the exact package name. Partial in that dpkg -l|grep php might return php5, php5-cli, php5-common, etc. – Benjamin Staton Jul 11 '17 at 22:42
  • dpkg -l apache2 | grep '`^ii' – Corey Goldberg Sep 29 '17 at 3:37


is enough. The first two characters in the line will show the package status

  • specifically, the status ii means it is installed – Corey Goldberg Sep 29 '17 at 3:35
aptitude show foo

will show status of the pakage

root@srv:# aptitude show python-jmespath
Package: python-jmespath
Version: 0.9.0-2
State: not installed
Priority: optional
Section: python
Maintainer: Debian Python Modules Team python-modules-team@lists.alioth.debian.org
Architecture: all
Uncompressed Size: 97.3 k
Depends: python (>= 2.7)
Description: JSON Matching Expressions (Python 2)
 JMESPath is python library which allows you to declaratively specify how to extract elements from a JSON document.

 This package contains the module for Python 2.
Homepage: https://github.com/boto/jmespath


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.