dpkg
command at a
shell prompt,
i.e., a
command line interface.
dpkg is a tool to install, build, remove and manage Debian packages. The primary and more user-friendly front-end for dpkg is aptitude. dpkg itself is controlled entirely via command line parameters, which consist of exactly one action and zero or more options. The action- parameter tells dpkg what to do and options control the behavior of the action in some way.
To determine the installed package to which a file belongs use the
-S
or --search
option with the dpkg
command.
-S, --search filename-search-pattern...
Search for a filename from installed packages.
For example:
$ dpkg -S /usr/share/samba/smb.conf samba-common: /usr/share/samba/smb.conf $ dpkg -S smb.conf samba-common-bin: /usr/share/man/man5/smb.conf.5.gz samba-common: /usr/share/samba/smb.conf nautilus-share: /usr/share/doc/nautilus-share/examples/smb.conf
For a file for which you wish to determine the package to which it belongs,
you can specify the full path to where the file is located followed by
the filename or you can just put the filename after the -S
option.
In the latter case, as shown in the second command above where only
smb.conf
was specified, dpkg -S
will list all
packages providing a file by the name listed.
If you want to list all the files provided by an installed package,
you can use the -L
or --listfiles
option.
-L, --listfiles package-name...
List files installed to your system from package-name.
For example:
$ dpkg -L samba-common-bin /. /usr /usr/bin /usr/bin/net.samba3 /usr/bin/nmblookup.samba3 /usr/bin/smbpasswd /usr/bin/testparm.samba3 /usr/share /usr/share/man /usr/share/man/man1 /usr/share/man/man1/testparm.samba3.1.gz /usr/share/man/man1/nmblookup.samba3.1.gz /usr/share/man/man5 /usr/share/man/man5/smbpasswd.5.gz /usr/share/man/man5/lmhosts.5.gz /usr/share/man/man5/smb.conf.5.gz /usr/share/man/man7 /usr/share/man/man7/samba.7.gz /usr/share/man/man8 /usr/share/man/man8/net.samba3.8.gz /usr/share/man/man8/smbpasswd.8.gz /usr/share/doc /usr/share/doc/samba-common-bin /usr/share/doc/samba-common-bin/copyright /usr/share/doc/samba-common-bin/NEWS.Debian.gz
If you want to know what package provides a file when the package
is not installed, you will need to install the apt-file
package.
$ sudo apt-get install apt-file
The cache file for apt-install which has information about the files
contained in packages will need to be updated once you install apt-file
. You should be prompted to update the cache file when you install
apt-file
. You can update it manually from the command line
using the command sudo apt-file update
. Once apt-file
is installed, you can check on what package contains a file using the
command apt-file search filename
. For instance, suppose
the file httpd.conf
isn't on the system, which is shown
by dpkg -S httpd.conf
, but you wished to know which package
does provide the file. Then you could use apt-file search httpd.conf
to obtain a list of packages that contain the file httpd.conf
or a file pattern matching it, e.g. lighthttpd.conf
$ dpkg -S httpd.conf dpkg-query: no path found matching pattern *httpd.conf*. jim@Didymus:~/Downloads$ apt-file search httpd.conf 389-admin: /etc/dirsrv/admin-serv/httpd.conf 389-dsgw: /etc/dirsrv/dsgw/dsgw-httpd.conf cacti: /usr/share/doc/cacti/cacti.lighttpd.conf cipux-cat-web: /etc/cipux-cat-web/lighttpd.conf cvsweb: /usr/share/doc/cvsweb/examples/cvsweb-httpd.conf d-push: /etc/d-push/lighttpd.conf dotclear: /etc/dotclear/lighttpd.conf <text sniped> roundcube-core: /etc/roundcube/lighttpd.conf samizdat: /usr/share/doc/samizdat/examples/lighttpd.conf smbind: /etc/smbind/lighttpd.conf spl-core: /usr/share/doc/spl-core/examples/httpd.conf sql-ledger: /etc/sql-ledger/sql-ledger-httpd.conf sympa: /etc/sympa/httpd.conf-cgi sympa: /etc/sympa/httpd.conf-fcgi torrentflux: /etc/torrentflux/lighttpd.conf ukolovnik: /etc/ukolovnik/lighttpd.conf w3c-markup-validator: /etc/w3c/httpd.conf
References:
Created: Saturday May 12, 2012