{"id":2105,"date":"2012-03-06T20:07:47","date_gmt":"2012-03-06T12:07:47","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=2105"},"modified":"2023-04-28T09:49:42","modified_gmt":"2023-04-28T09:49:42","slug":"how-to-set-the-sgid-bit-on-a-directory-on-centos-6-2-linux-server","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-set-the-sgid-bit-on-a-directory-on-centos-6-2-linux-server\/","title":{"rendered":"How to set the SGID bit on a Directory on CentOS 6.2 Linux Server"},"content":{"rendered":"<p>In Linux, the SGID (Set Group ID) bit is used to set the group ownership of a file or directory. When a directory has the SGID bit set, any files or subdirectories created within that directory inherit the group ownership of the parent directory instead of the user&#8217;s default group. In this guide, we will show you how to set the SGID bit on a directory on CentOS 6.2 Linux server.<\/p>\n<h2>Step 1: Identify the Directory<\/h2>\n<p>The first step is to identify the directory for which you want to set the SGID bit. For example, let&#8217;s say you want to set the SGID bit on a directory called &#8220;data&#8221; located in the &#8220;\/var&#8221; directory.<\/p>\n<h2>Step 2: Set the SGID Bit on the Directory<\/h2>\n<p>To set the SGID bit on the directory, use the following command:<\/p>\n<pre>sudo chmod g+s \/var\/data<\/pre>\n<p>This command will set the SGID bit on the &#8220;data&#8221; directory located in the &#8220;\/var&#8221; directory. Any files or subdirectories created within this directory will inherit the group ownership of the &#8220;data&#8221; directory.<\/p>\n<h2>Step 3: Verify the SGID Bit is Set<\/h2>\n<p>To verify that the SGID bit is set on the directory, use the following command:<\/p>\n<pre>ls -l \/var\/data<\/pre>\n<p>This command will display the permissions of the &#8220;data&#8221; directory, including the SGID bit. The output should look something like this:<\/p>\n<pre>drwxrwsr-x 2 root root 4096 Apr 13 2023 data<\/pre>\n<p>Note the &#8220;s&#8221; in the group permissions column, which indicates that the SGID bit is set.<\/p>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo chmod g+s<\/span> &#8211; Set the SGID bit on a directory<\/li>\n<li><span class=\"fw-bold\">ls -l<\/span> &#8211; Display permissions of a directory or file<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this guide, we have shown you how to set the SGID bit on a directory on CentOS 6.2 Linux server. By setting the SGID bit on a directory, any files or subdirectories created within that directory inherit the group ownership of the parent directory. This can be useful in a variety of situations, such as when multiple users need to access and modify files within a shared directory. We hope this guide has been helpful to you. If you have any comments or suggestions for improvements, please feel free to share them below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux, the SGID (Set Group ID) bit is used to set the group ownership of a file or directory. When a directory has the SGID bit set, any files&#8230;<\/p>\n","protected":false},"author":6,"featured_media":1554,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1],"tags":[1244,1253,1536,2070,1779],"class_list":["post-2105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-centos","tag-centos-6-2","tag-linux","tag-permissions","tag-sgid"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=2105"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/2105\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/1554"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=2105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=2105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=2105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}