{"id":1098,"date":"2010-06-14T23:58:49","date_gmt":"2010-06-14T18:28:49","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/2010\/06\/14\/how-to-set-up-shared-folderrepository-between-two-or-more-users-on-linux\/"},"modified":"2016-12-19T15:19:22","modified_gmt":"2016-12-19T09:49:22","slug":"how-to-set-up-shared-folderrepository-between-two-or-more-users-on-linux","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-set-up-shared-folderrepository-between-two-or-more-users-on-linux\/","title":{"rendered":"How to Set-up shared folder\/repository between two or more users on Linux"},"content":{"rendered":"<p>We had a case where we wanted two different applications (run by different users) to be able to read and write from the same file system.<br \/>\nThis is how we solved this problem:<\/p>\n<ol>\n<li>Create a group which these users will belong to :[shell]groupadd GROUP_NAME[\/shell]<\/li>\n<li>Edit user1 and user2 to be a member of this group:[shell]<br \/>\nusermod -a -G GROUP_NAME user1 ;<br \/>\nusermod -a -G GROUP_NAME user2;<br \/>\n[\/shell]<\/li>\n<li>Create a shared directory. In our case, it had to be the document root for an Apache site. Thus we chose the location SHARED_FOLDER<\/li>\n<li>Now we need to change the group of this folder :[bash]chgrp -R GROUP_NAME SHARED_FOLDER [\/bash]<\/li>\n<li>We&#8217;ll also need to grant the group write access on this folder :[bash]chmod g+w SHARED_FOLDER [\/bash]<\/li>\n<li>Now we&#8217;ll need to set the GroupID flag on this folder. For a directory, the set-groupID flag means that all files created inside that directory will inherit the group of the directory. Without this flag, a file takes on the primary group of the user creating the file. This property is important to people trying to maintain a directory as group accessible. The subdirectories also inherit the set-groupID property. (http:\/\/www.dartmouth.edu\/~rc\/help\/faq\/permissions.html).[bash]chmod +s SHARED_FOLDER[\/bash]<\/li>\n<li>Now in your .bashrc \/ .bash_profile, set the umask as 002. Setting this umask ensures that all the newly created files by this user will have the permission &#8220;rw-rw-r&#8221;. Thus giving the group write permission.:\u00a0[bash] umask 002 [\/bash]<\/li>\n<\/ol>\n<p>Now when either of the users create any file in the SHARED_FOLDER, all the users of this group will have the read\/write permissions on that file. Not only this, these permissions will be on the subfolders and the files with-in that folder as well.<\/p>\n<p>But, if any of these users create a file outside the SHARED_FOLDER, the primary group of that file\/folder will be the same as the primary group of that user. Thus files\/folder only in the SHARED_FOLDER are shared between these users.<\/p>\n<p>This is just one of the many great abilities that Linux provides.<\/p>\n<p>Hope this saves you some time.<\/p>\n<p>Your feedback and suggestions are welcome.<\/p>\n<p>Regards<br \/>\n~~Himanshu Seth~~<\/p>\n<p>http:\/\/www.tothenew.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We had a case where we wanted two different applications (run by different users) to be able to read and write from the same file system. This is how we solved this problem: Create a group which these users will belong to :[shell]groupadd GROUP_NAME[\/shell] Edit user1 and user2 to be a member of this group:[shell] [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":17},"categories":[1],"tags":[284,285,286,260,283,287],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1098"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1098"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1098\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}