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.  So, as I'm trying to follow along n00bish guides (because I'm a n00b when it comes to Linux stuff), and I'm having to experiment to see what from the guide actually needs to be done.  Fun right?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=noscriptMy 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 dumpthis 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 sambaPackage: sambaVersions: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: 0122ac62ef5f4ae21eb2e195eb45ad1dReverse Depends:  winbind,samba 2.2.3-2  task-file-server,samba  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  qtsmbstatus-server,samba  qemu-system,samba  nautilus-share,samba 3.0.27a  libwbclient0,samba 2:3.4.1  libpam-winbind,samba 2.2.3-2  libpam-smbpass,samba  libnss-winbind,samba 2.2.3-2  gadmin-samba,samba  education-main-server,samba  dpsyco-samba,sambaDependencies: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 0.99.7.1) 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                                   1.15.7.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)Provides:2:3.6.6-6+deb7u5 -Reverse Provides:pi@raspberrypi ~ $ apt-cache showpkg ntfs-3gPackage: ntfs-3gVersions: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: b2df024e8627b5d253b85f35263376efReverse Depends:  udisks,ntfs-3g  ntfsprogs,ntfs-3g  ntfs-config,ntfs-3g  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  kvpm,ntfs-3g  fsarchiver,ntfs-3gDependencies: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))Provides:1:2012.1.15AR.5-2.1+deb7u2 -Reverse Provides:pi@raspberrypi ~ $ apt-cache showpkg ntfsprogsPackage: ntfsprogsVersions: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: 95f41af9cf1d0b5b66afb7d2a9e7c75dReverse Depends:  partitionmanager,ntfsprogs  ntfs-3g,ntfsprogs  ntfs-3g,ntfsprogs 1:2011.10.9AR.1-3~  gparted,ntfsprogs  fsarchiver,ntfsprogs  fai-setup-storage,ntfsprogsDependencies:1:2012.1.15AR.5-2.1+deb7u2 - ntfs-3g (0 (null))Provides: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-selectionswhich I got from here:http://www.howtogeek.com/howto/linux/show-the-list-of-installed-packages-on-ubuntu-or-debian/?PageSpeed=noscriptbut 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 workUsage: dpkg [<option> ...] <command>--get-selections [<pattern> ...] Get list of selections to stdout.but I get an error:dpkg get-selections sambadpkg: error: need an action optionI 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.What packages are installed by default in Debian? Is there a term for that set? Why some of those packages are `automatically installed` and some not?How do we know what applications are installed in Linux?Loop to check whether a Debian package is installed or notDetermine if a package is provided by an installed packagein Arch Linux
How to find out if a specific package is installed on Debian?
debian;apt;package management;dpkg
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:Versions: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:samba:  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/statussamba-dev:  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 PackagesAlternatively, 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 sambaThis 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-devDesired=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  samba          2:4.1.17+dfs amd64        SMB/CIFS file, print, and login sdpkg-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 runapt-get install sambaThis 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.