How to implement different users have write access to the same file under Linux

Source: Internet
Author: User

The cause of the problem arises:

When a user creates a file, the owner and owner of the file it creates is the user itself, so having write permission on the group does not imply that the other user has write permissions

Solution:

Add Sgid permissions to a directory that is commonly accessed

Resolution process:

Scenario Example: A company's development team has three users: Hadoop, Habase, Hive has a file directory tmp/project for them to develop, how to make these three users have write access to it

The first step:

The additional group for modifying three users is Developteam

650) this.width=650; "title=" adds additional groups to the user. png "src=" http://s4.51cto.com/wyfs02/M01/78/D1/ Wkiol1ads8lshtshaabuv2ux9l0675.png "alt=" Wkiol1ads8lshtshaabuv2ux9l0675.png "/>

Switch to a different user to see if the user has write permissions

650) this.width=650; "title=" does not have write permission. png "src=" http://s1.51cto.com/wyfs02/M00/78/D1/ Wkiol1adtbqr7wxwaaasdnl5cci433.png "alt=" Wkiol1adtbqr7wxwaaasdnl5cci433.png "/>

Step Two: Add Write permission to the group

After the user is added to the same additional group, the group does not have permission to write, and it needs to add write permission to the file at this time

650) this.width=650; "title=" adds write permissions to the additional group. png "src=" http://s4.51cto.com/wyfs02/M02/78/D1/ Wkiol1adtgdhrqbfaaaizkislc8438.png "alt=" Wkiol1adtgdhrqbfaaaizkislc8438.png "/>

View user has write permission at this time no?

650) this.width=650; the "title=" user has Write permissions. png "src=" http://s3.51cto.com/wyfs02/M02/78/D1/ Wkiol1adtjxgpsrtaacgx27-ons450.png "alt=" Wkiol1adtjxgpsrtaacgx27-ons450.png "/>

View the group of files created by the user, add Write permission to the attached group, the user's owner or the user who created the file, or the other user is not able to write.

650) this.width=650; the files created by "title=" under their respective users are based on the user itself as the basic group. png "src=" http://s5.51cto.com/wyfs02/M00/78/D3/ Wkiom1adtl3j9s3kaaatlcs2k3u858.png "alt=" Wkiom1adtl3j9s3kaaatlcs2k3u858.png "/>

Step three: Give the file Sgid

Command: chmod g+s/tmp/project/

After adding Sgid to a file, the group of files becomes the genus of the file itself, not the creator of the file.

650) this.width=650; the "title=" basic group becomes the genus Group of the file itself. png "src=" http://s4.51cto.com/wyfs02/M00/78/D1/ Wkiol1adtunqg6goaabaovdalym504.png "alt=" Wkiol1adtunqg6goaabaovdalym504.png "/>

Other users can manipulate the file:

650) this.width=650; "title=" Hadoop users delete files from other users. png "src=" http://s2.51cto.com/wyfs02/M00/78/D2/ Wkiol1adti-cv24laaaucw85snk138.png "alt=" Wkiol1adti-cv24laaaucw85snk138.png "/>

To prevent other users from deleting operations, add stick permissions to the file

Command: chmod o+t/tmp/project/

650) this.width=650; "title=" Cannot delete other users ' files after adding stick. png "src=" http://s3.51cto.com/wyfs02/M02/78/D4/ Wkiom1adtlaxejh4aaadml7jaei274.png "alt=" Wkiom1adtlaxejh4aaadml7jaei274.png "/>

After adding sgid and stick to a file, other users can have write permissions to the file directory but cannot delete files created by other users.

This article is from "Life Like Summer Flower" blog, please make sure to keep this source http://langmei.blog.51cto.com/11016382/1730107

How to implement different users have write access to the same file under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.