I have a script (nginx-sb-setup.sh) inside of my deb package in usr/local/bin directory.

During postinst, I want to copy this usr/local/bin/nginx-sb-setup.sh which is inside of my deb package to /usr/local/bin.

I have learned that dpkg -i doesn't run in the same folder as the deb file. When I gave pwd in postinst, I have found that it runs in /.

And I unable to properly link the file in such way to successfully copy it to my target location.

During install, I get error saying,

cp: cannot stat 'usr/local/bin/nginx-sb-setup.sh': No such file or directory

Please help.

  • "dpkg -i doesn't run in the same folder as the deb file" - how so? If I download a .deb file, without exceptions I run dpkg -i filename.deb in the same folder the .deb file is in. I've not yet had to copy any files from inside the .deb package anywhere. Then again I never have .deb files in any bin directory either. Apr 10 at 7:37
  • Where did you download the .deb package anyway and why? Ngnix.org has clear installation instructions which don't involve downloading separate packages. Following them I just now installed it successfully on a Debian 11 system. Apr 10 at 7:45
  • @StephenKitt, perhaps I should have posted file / folder structure of the package. Then you could have known that I have missed the install file. My bad.
    – Hasan
    Apr 11 at 4:46

1 Answer 1


My package was missing the debian/install file. Inside of the file, we need to write our local script and target location and it gets automatically copied.

The example install file looks like this,

usr/local/bin/nginx-sb-setup /usr/local/bin/

And the script gets automatically removed from /usr/local/bin during package removal; no need to remove it in postrm.

You must log in to answer this question.

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