13

I am running Ubuntu 12.10 and, if possible, I would like to get the list of configuration files available for a given package that is already installed.

I would prefer to do this using dpkg or apt if possible, but no problem if other tools such as aptitude or dselect are needed/recommended.

3 Answers 3

19

There's no need to use anything other than cat, if I understood your intention correctly:

cat /var/lib/dpkg/info/<package>.conffiles

should give you what you're after. For instance for package zsh:

% cat /var/lib/dpkg/info/zsh.conffiles
/etc/zsh/zlogin
/etc/zsh/zlogout
/etc/zsh/zprofile
/etc/zsh/zshenv
/etc/zsh/zshrc
/etc/zsh/newuser.zshrc.recommended

Regarding a case where there's no such file for a given package - it's up to the package maintainer to designate certain files as configuration. If this hasn't been done properly, you should file a bug where appropriate.

In such cases you have a couple of options.

  1. List files belonging to the package that are in /etc/:

    dpkg -L package | grep '/etc'
    
  2. Fetch and inspect the source package to find out how it was compiled (which should also show you where it expects its configuration files to be located).

    apt-get source package
    less package-x.y.z/debian/rules
    
  3. Look up the upstream project page to find documentation.

3
  • If a given package is not having such a file .conffiles under this path, does it mean it is no using configuration files? Apr 16, 2013 at 13:14
  • Not necessarily - it might be that there are indeed configuration files used by the package but the packager did not designate any files as part of the packaged application's configuration files. Apr 16, 2013 at 14:00
  • The .conffiles file will list all configuration files that ship with the package and are marked as such by the packager. An automatically-installed one that does not appear there is a packaging bug, but be aware that some files (particularly user-specific configuration in a user's dotfiles) cannot ship with the package and can't really be automatically located unless you already know what they are.
    – Darael
    Jul 10, 2017 at 16:51
2

Let's for example test the package apt to get the config file(s).

It can be tricky to understand what .conffiles you should check to see the info so I suggest using grep to find the clue.

locate *.conffiles | grep apt

/var/lib/dpkg/info/apt-config-icons.conffiles
/var/lib/dpkg/info/apt.conffiles
/var/lib/dpkg/info/aptdaemon.conffiles
/var/lib/dpkg/info/apturl-common.conffiles
/var/lib/dpkg/info/libatk-adaptor:amd64.conffiles

And to cat any of these in particular if you are interested according to Marcin's Kaminski answer.

Another trick is to read the manual, for instance man apt will lead you to SEE ALSO section from where you can call man apt.conf where you will see the location of the config file for apt in this case: /etc/apt/apt.conf.

However, config file /etc/apt/apt.conf may not even exist. Be aware of that when searching for the config files.

In Linux config files should be inside the /etc/ directory. You may use dpkg-query -L your_package | grep etc to list all package files and directories inside the /etc/ directory.

1

How about dpkg -S [package-name]? Cant see it being mentioned here.

root@homehub:/# dpkg -S nginx

nginx-common: /usr/share/nginx/html
nginx-full: /usr/share/man/man8/nginx.8.gz
libnginx-mod-http-xslt-filter: /usr/share/doc/libnginx-mod-http-xslt-filter/copyright
nginx-common: /etc/logrotate.d/nginx
libnginx-mod-mail: /usr/share/doc/libnginx-mod-mail/changelog.gz
libnginx-mod-http-upstream-fair: /usr/share/doc/libnginx-mod-http-upstream-fair
libnginx-mod-http-auth-pam: /usr/share/doc/libnginx-mod-http-auth-pam/changelog.Debian.gz
libnginx-mod-http-image-filter: /usr/lib/nginx/modules/ngx_http_image_filter_module.so
nginx-common: /etc/nginx/snippets
libnginx-mod-mail: /usr/share/doc/libnginx-mod-mail/copyright
nginx-common: /etc/nginx/snippets/fastcgi-php.conf
libnginx-mod-http-xslt-filter: /usr/share/doc/libnginx-mod-http-xslt-filter/changelog.Debian.gz
nginx-full: /usr/share/doc/nginx-full/copyright
nginx-common: /usr/share/doc/nginx-common
nginx-common: /etc/ufw/applications.d/nginx
libnginx-mod-http-upstream-fair: /usr/share/doc/libnginx-mod-http-upstream-fair/changelog.gz
libnginx-mod-stream: /usr/share/nginx/modules-available/mod-stream.conf
nginx-common: /etc/nginx/sites-enabled
libnginx-mod-http-upstream-fair: /usr/share/doc/libnginx-mod-http-upstream-fair/copyright
libnginx-mod-http-subs-filter: /usr/share/doc/libnginx-mod-http-subs-filter/changelog.gz
libnginx-mod-http-dav-ext: /usr/share/nginx/modules-available/mod-http-dav-ext.conf
nginx-common: /etc/nginx/koi-utf
nginx-common: /etc/nginx/mime.types
nginx-common: /usr/share/vim/addons/syntax/nginx.vim
nginx-common: /usr/share/doc/nginx-common/NEWS.Debian.gz
nginx-common: /usr/share/doc/nginx-common/README.Debian
nginx-full: /usr/share/doc/nginx-full
libnginx-mod-mail: /usr/share/nginx/modules-available/mod-mail.conf
libnginx-mod-http-auth-pam: /usr/share/doc/libnginx-mod-http-auth-pam/changelog.gz
nginx: /usr/share/doc/nginx
nginx-common: /etc/nginx/win-utf
libnginx-mod-http-dav-ext: /usr/share/doc/libnginx-mod-http-dav-ext
....

And sometimes depending on filename structure it might be good if piped out to grep names containing ".conf":

root@homehub:/# dpkg -S nginx |grep ".conf"

nginx-common: /etc/nginx/snippets/fastcgi-php.conf
libnginx-mod-stream: /usr/share/nginx/modules-available/mod-stream.conf
libnginx-mod-http-dav-ext: /usr/share/nginx/modules-available/mod-http-dav-ext.conf
libnginx-mod-mail: /usr/share/nginx/modules-available/mod-mail.conf
libnginx-mod-http-auth-pam: /usr/share/nginx/modules-available/mod-http-auth-pam.conf
nginx-common: /etc/nginx/fastcgi.conf
nginx-common: /etc/init/nginx.conf
nginx-common: /etc/nginx/conf.d
libnginx-mod-http-subs-filter: /usr/share/nginx/modules-available/mod-http-subs-filter.conf
libnginx-mod-http-geoip: /usr/share/nginx/modules-available/mod-http-geoip.conf
libnginx-mod-http-echo: /usr/share/nginx/modules-available/mod-http-echo.conf
libnginx-mod-http-upstream-fair: /usr/share/nginx/modules-available/mod-http-upstream-fair.conf
nginx-common: /etc/init/nginx.conf
libnginx-mod-http-xslt-filter: /usr/share/nginx/modules-available/mod-http-xslt-filter.conf
nginx-common: /etc/nginx/snippets/snakeoil.conf
nginx-common: /etc/nginx/nginx.conf
libnginx-mod-http-image-filter: /usr/share/nginx/modules-available/mod-http-image-filter.conf

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.