I'm creating a package which includes some default settings for users. Things that generally appear under ~/.<some-name> or ~/.config/<app>/<some>.conf and similar files.

In most cases, these files are installed in the skeleton directory (/etc/skel) but those are going to be installed only in new users home directories. I'd like existing users to also get the files at the time the package gets installed.

What does the Debian standard say about that?

For a concrete example, I have a .lessfilter script that I'd like to add to my personal package so that way it gets installed on all of my machines.

So in my alex-tools.install file I have:

scripts/.lessfilter   /etc/skel

I know I can create an alex-tools.postinst script like so (not yet tested, use with care):

#!/bin/sh -e
# Finish up the installation


# Source debconf library.
. /usr/share/debconf/confmodule

if [ "$1" = "configure" ]
    # Install files in user folders
    for u in /root /home/*
        if ! test -f "${u}/.lessfilter"
            cp /etc/skel/.lessfilter "${u}/.lessfilter"
            chmod 700 "${u}/.lessfilter"
            chown "${u}" "${u}/.lessfilter"

But I'm thinking that this may not be considered "legal" in Debian and there may be a cleaner way to implement such?

Is there something about this in the Debian references?

1 Answer 1


I'm not sure about official recommendations for creating per-user configuration during package installation, but links I found certainly discourage it. However, if I was installing your package then this is my opinion on how I'd like it designed.

Installing configuration files

Many programs will first check a global configuration location (e.g. /etc/my_program) before checking a per-user configuration (e.g. ~/.my_program). When possible, the configuration should be placed at the global location.

Your concrete example of installing a per-user configuration file for ~/.lessfilter is interesting because that does not have a global configuration file option. In this case, if you are providing the package my_package then it could

  • create a global configuration at /usr/share/my_package/lessfilter
  • add a script /etc/profile.d/my_package with content like
[ -f "${HOME}/.lessfilter" ] || cp /usr/share/my_package/lessfilter "${HOME}/.lessfilter"

This would allow a lot of flexibility. An obvious downside is that /etc/profile might only affect interactive Bash sessions, and you may need to support other scenarios.


  • Oh, so each time someone logs in, the scripts under /etc/profile.d run. That's good. The cp could also be a ln -s ... in that case. That way I could offer a "neutral" script which does nothing at all. Then the user can switch between full fledged version or the script that does nothing. Dec 22, 2021 at 2:24
  • As a side note, I created a project called advgetopt which does have the ability to support global (/usr/share/...) admin (/etc/...) and user defined (~/.config/...) configuration files in read & write mode and somewhat varying formats. So I understand the normal way of having settings. Unfortunately, less is not yet as advanced as you have discovered. Also my personal package is in part for me to avoid having to do all that setup by hand each time I install a new Ubuntu server... Dec 22, 2021 at 16:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .