{"id":12414,"date":"2019-03-26T23:16:47","date_gmt":"2019-03-26T23:16:47","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12414"},"modified":"2019-03-26T23:16:47","modified_gmt":"2019-03-26T23:16:47","slug":"how-to-create-a-shared-directory-for-all-users-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/26\/how-to-create-a-shared-directory-for-all-users-in-linux\/","title":{"rendered":"How to Create a Shared Directory for All Users in Linux"},"content":{"rendered":"<p>As a system administrator, you may have a certain directory that you want to give read\/write access to every user on a Linux server. In this guide, we will review how to enable write access to all users on a particular directory (shared directory) in Linux.<\/p>\n<p>This calls for setting the appropriate access permissions, and the most effective as well as reliable method to allocating a common group for all the users who will share or have write access to the specific directory.<\/p>\n<p>So, start by creating the directory and common group in case it doesn\u2019t already exist on the system as follows:<\/p>\n<pre>$ sudo mkdir -p \/var\/www\/reports\/\r\n$ sudo groupadd project \r\n<\/pre>\n<p>Then add an existing user who will have write access to the directory:\u00a0<strong>\/var\/www\/reports\/<\/strong>\u00a0to the group project as below.<\/p>\n<pre>$ sudo usermod -a -G project tecmint \r\n<\/pre>\n<div id=\"attachment_24422\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Create-Common-Directory-Group.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24422\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2017\/01\/Create-Common-Directory-Group.png\" alt=\"Create Common Directory Group\" width=\"569\" height=\"136\" aria-describedby=\"caption-attachment-24422\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24422\" class=\"wp-caption-text\">Create Common Directory Group<\/p>\n<p>The flags and arguments used in the above command are:<\/p>\n<ol>\n<li><code>-a<\/code>\u00a0\u2013 which adds the user to the supplementary group.<\/li>\n<li><code>-G<\/code>\u00a0\u2013 specifies the group name.<\/li>\n<li><code>project<\/code>\u00a0\u2013 group name.<\/li>\n<li><code>tecmint<\/code>\u00a0\u2013 existing username.<\/li>\n<\/ol>\n<p>Afterwards, proceed to configure the appropriate permissions on the directory, where the option\u00a0<code>-R<\/code>\u00a0enables recursive operations into subdirectories:<\/p>\n<pre>$ sudo chgrp -R project \/var\/www\/reports\/\r\n$ sudo chmod -R 2775 \/var\/www\/reports\/\r\n<\/pre>\n<p>Explaining the permissions\u00a0<strong>2775<\/strong>\u00a0in the\u00a0<strong>chmod<\/strong>\u00a0command above:<\/p>\n<ol>\n<li><code>2<\/code>\u00a0\u2013 turns on the\u00a0<strong>setGID<\/strong>\u00a0bit, implying\u2013newly created subfiles inherit the same group as the directory, and newly created subdirectories inherit the set GID bit of the parent directory.<\/li>\n<li><code>7<\/code>\u00a0\u2013 gives\u00a0<strong>rwx<\/strong>\u00a0permissions for owner.<\/li>\n<li><code>7<\/code>\u00a0\u2013 gives\u00a0<strong>rwx<\/strong>\u00a0permissions for group.<\/li>\n<li><code>5<\/code>\u00a0\u2013 gives\u00a0<strong>rx<\/strong>\u00a0permissions for others.<\/li>\n<\/ol>\n<p>You can create more system users and add them to the directory group as follows:<\/p>\n<pre>$ sudo useradd -m -c \"Aaron Kili\" -s\/bin\/bash -G project aaronkilik\r\n$ sudo useradd -m -c \"John Doo\" -s\/bin\/bash -G project john\r\n$ sudo useradd -m -c \"Ravi Saive\" -s\/bin\/bash -G project ravi\r\n<\/pre>\n<p>Then create subdirectories where the new users above will store their project reports:<\/p>\n<pre>$ sudo mkdir -p \/var\/www\/reports\/aaronkilik_reports\r\n$ sudo mkdir -p \/var\/www\/reports\/johndoo_reports\r\n$ sudo mkdir -p \/var\/www\/reports\/ravi_reports\r\n<\/pre>\n<p>Now you can create files\/folders and share with other users on the same group.<\/p>\n<p>That\u2019s it! In this tutorial, we reviewed how to enable write access to all users on a particular directory. To understand more about users\/groups in Linux, read\u00a0<a href=\"https:\/\/www.tecmint.com\/manage-users-and-groups-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Manage Users\/Groups File Permissions and Attributes<\/a>.<\/p>\n<p>Remember to offer us your thoughts about this article via the feedback form below.<\/p>\n<p><a style=\"font-size: 1rem;\" href=\"https:\/\/www.tecmint.com\/create-a-shared-directory-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>As a system administrator, you may have a certain directory that you want to give read\/write access to every user on a Linux server. In this guide, we will review how to enable write access to all users on a particular directory (shared directory) in Linux. This calls for setting the appropriate access permissions, and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/26\/how-to-create-a-shared-directory-for-all-users-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Create a Shared Directory for All Users in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12414","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12414"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12414\/revisions"}],"predecessor-version":[{"id":12415,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12414\/revisions\/12415"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}