How can I know what programs some apt-get package contains?

I would like to know what some specific package installs, for example, when installing ncurses, I have found that TAB key expands:

sudo apt-get install ncurses-

to show:

ncurses-base      ncurses-doc       ncurses-hexedit
ncurses-bin       ncurses-examples  ncurses-term

How could I know what, say, ncurses-term installs? I am interested mainly in programs, but libraries and any other filetypes could be useful too.

Command-line method, if possible, would be preferred (any others accepted too).


Here are a few options, these will list all the files installed by a package:

A. Listing all files included in a package

  1. For installed packages

    dpkg -L ncurses-term
    
  2. For all packages, installed or not

    apt-file -F list ncurses-term
    

    The -F turns of pattern matching so that only packages whose exact name matches are returned. You may need to install apt-file with sudo apt-get install apt-file and then update its database with sudo apt-file update.

B. Listing only executable files included in a package

  1. For installed packages

    Just install dlocate (sudo apt-get dlocate) and run:

    dlocate -lsbin ncurses-term 
    

    As explained in man dlocate:

    -lsbin List full path/filenames of executable files (if any) in package

    If you don't want to install additional packages, you can do this manually. Just collect the list of files and find any among them that have the executable bit set:

    apt-file -F list ncurses-term | cut -d ' ' -f 2 | 
        while read file; do [[ -x $file && -f $file ]] && echo "$file"; done
    

    The little scriptlet above will print the path only (cut -d ' ' -f 2) and then pass it through a while loop that checks if the file is executable (-x $file) and if it is a regular file, no directories or symlinks (-f $file) and prints its name only if passes both tests.

  2. For all packages, installed or not

    There is no way I know of to list only executables included in an uninstalled package. However, since most executables are installed to bin directories, you can get most of them by parsing the output:

     apt-file -F list ncurses-term | grep -Ew "bin|sbin"
    

    The -w option matches entire words, so you don't get things installed in, for example, trashbin or whatever.


NOTE: None of the above commands will produce any output for ncurses-term but that is because this package installs no executable files. The commands work nevertheless, try with a different package.


You could use apt-file:

sudo apt-file update        
apt-file list package_name

There's a possibility using your browser (therefore not requiring access to a APT-system). For example, to list the file contents of package "ncurses-term", just type

https://packages.debian.org/wheezy/all/ncurses-term/filelist

into your browser's address bar (replace "wheezy" as needed) for Debian or

http://packages.ubuntu.com/saucy/all/ncurses-term/filelist

for Ubuntu (replace "saucy" as needed).