I have a daemon that needs access to (read/write) some files that a gui app also has access to (read/write). The daemon runs as root but the gui does not. Each time the daemon accesses the files, the owner becomes root:root. What is the preferred way to handle this?

This is in Ubuntu 16.04, doesn't need to be compatible with anything else.

is there also a best/preferred location to put these files?


Many solutions:

  • If the daemon doesn't need to be root, make it run as the user.
  • Change the UFLAGs of the daemon so that the file is created rw-rw-rw-.
  • Since the daemon is root, it can explicitly change the ownership of the file after it creates it.
  • Make the daemon run in a specific-group common with the user where both have R/W access to the group files.
  • Reconsider your design to avoid the situation.

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.