Search code examples
linuxamazon-web-servicesuser-management

How can I edit a file with copies in 2 different users in linux?


I use AWS vps server and apache2 is installed in it. I want to edit a file "index.html" from 2 different accounts (i.e. 1st user "ubuntu" and second user "www-data"). By now, I try to edit the file but I got permission error so first I change (chown) permission to "ubuntu " and edit file and again change (chown) permission back to "www-data" otherwise I will get permission error in web browser.

I used chmod 777 index.html but this didn't help.

Please help me finding some good solution. Because this is tough to edit. I do have sudo permission if needed.

Thanks in advance!


Solution

  • You have two options:

    1. create a dedicated group and add the ubuntu and www-data users to this group. Then set with chgrp the group of the file and finally give the right permissions to the group with chmod.
    2. If your server suports Access Control Lists (it should), you could use the setfacl command. You can read about the command here and here.