I have a program that is doing some stuff. It is running under user A.

A very little part of it is to transfer a file to a directory in the home of user B. The transfer is done by a API-call of the language it is written and not by a system-call of a shell-command.

Now I see multiple ways to do that transfer.

  • Run the program as root.
  • Put A and B into the same group and adjust the directory-ownership
  • sudo the program
  • make the move with a system-call and sudo that
  • put the file locally in A and make the transfer externally (outsource the problem)
  • ACL the directory of B
  • ...

I think the requirement is common since running a program via root is bad taste. What would be the most common way to handle it?


Program of A generates the file. B should be able to read and delete it.

  • I would go with the ACL option.
    – FedKad
    Apr 17, 2020 at 5:53
  • Is the issue that the file, from user B's perspective, is not readable or located in an inaccessible directory? This is not actually spelled out in the question. If that was not the case, no special handling of permissions would be necessary, obviously, as long as you copy the data rather than just rename/move the file (to get the correct ownership on B's end).
    – Kusalananda
    Apr 17, 2020 at 6:08
  • 1
    Added the requirement. A creates the file, B reads and deletes it.
    – chris01
    Apr 17, 2020 at 6:11
  • 1
    If you are already messing up with permissions and root's stuff, then you may consider using bindfs with proper user option to i.e create new files as another user
    – DevilaN
    Apr 17, 2020 at 6:47
  • I will check bindfs, thanks. Is there a way where I do not need to mess up with permissions and root stuff?
    – chris01
    Apr 17, 2020 at 7:26

1 Answer 1


If it's important to not see the other files of A user, then make a separate common directory where both users have read write rights and put the files there.

Or you can copy/move the file as soon as it is created with inotifywatch and chown to B, here is an example, put it in cron

Copy the files automatically to destination as soon as created

You must log in to answer this question.

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