We are creating a simple binary package for a war file and some scripts using dpkg-deb.

One issue is that say we are doing this as a local user called "goofy", then the files in the package will be owned by goofy.

When we later try to install this package as root, we were surprised that the files it put in /opt/ourpackage were all still owned by goofy.

Now goofy user wont exist on most peoples machines, so what is the best way to handle this?

We assume there are two options:

  1. make all the files be owned by a user we can assume exists on all servers - i.e. root.
  2. create some pre-installation scripts which create the goofy (or appropriate) user first.

What method is recommended?

IF the answer is 2, does anyone have any tried and tested scripts we could add to the package to do this?

We would have chosen option1, but this is hampered by the fact that the "user" who will be creating and building the packages is jenkins, so cant easily create files owned by root.

  • 2
    You're creating the package wrong. If you used debhelper, dh_fixperms will be automatically run, and it will change ownership to root:root unless specified otherwise. See also: unix.stackexchange.com/a/254266/70524
    – muru
    Feb 17, 2016 at 18:19
  • OK, so the answer seems to be the packager needs to make the files be owned by root before calling dpkg-deb. we are not using debhelper as the examples and documentation for it (and most other tools) are designed for systems which build from some upstream source. We don't have this - there is no make file or similar. Feb 18, 2016 at 11:46
  • You can package binaries with debhelper. Override dh_auto_configure, dh_auto_build, etc. steps. The rest of the steps can proceed as usual.
    – muru
    Feb 19, 2016 at 20:33

2 Answers 2


The solution in the end was to use fakeroot (sudo apt-get install fakeroot).

Then the packager can own the files to be packaged, but when we run:

fakeroot dpkg-deb --build debian

it spoofs the builder to think that all the files are owned by root, and keeps lintian happy and installs the files as root on the target server.


These days you can use --root-owner-group instead of fakeroot to create a package where all files will be deployed as root.

dpkg-deb --root-owner-group --build $builddir $outputdeb

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.