It is a pain to handle folder permission for new linux users or VPS users. Even some Pro-Linux users also face this problem. However, I will explain here how to give two users to read-write access of a same folder.
Lets start. (Every Command need to execute by root or super user or sudo)
First Create Two User if you don’t have already.
Now as you have two user user1 and user2 , you need to create a group which will be a common for both of them.
Now, you need to add the users to this group.
adduser user1 group12
adduser user2 group12
To test if those users are added to that group or not by below command.
If you see that group group12 then all ok.
Now, you need to create folder.
By default it will created by user root and group root. But Now we need to change this folders group.
chown -R root.group12 /root/folder
Now you will need to give that group to read-write access of that folder including create folders,files etc.
chmod -R g+rwx /root/folder
Now those users will be able to read and write inside that folder.