A question about permissions in Linux

Source: Internet
Author: User

problem Description: a user groupTestGroupto the directory/tmp/Testhave read, write, execute permission; user group test users to directory The Chinese part has only read permission, and the owner and owner of the file isRootwhen the user belonging to the user group test Groupafter the testuser logs onwithVimafter forced editing, the owner and owner of the file becomes testuser and the TestGroup , at this timeEchocan't write.

Verification process:

1.First, create a user as rootTestUser and Users group Testgroupafter, so that testuser with Testgroup as an additional group,againCreate a validation directory for/tmp/test, and change the group of directories to Testgroup and enable the group to have write permissions as follows.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/78/20/wKiom1Z2eLvRYCODAAAzyGnzNgI797.png "title=" 1.png " alt= "Wkiom1z2elvrycodaaazygnzngi797.png"/>

2, in this directory as the root user to create the files testfile, note that at this time the file testfile the group does not have write permissions.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/78/1E/wKioL1Z2eXLxcv2qAAAVd4iVbkQ348.png "title=" 2.png " alt= "Wkiol1z2exlxcv2qaaavd4ivbkq348.png"/>

3. Switch user to TestUser, and write the character "abc" to/tmp/test/testfile with Echo (because there is no write permission, it cannot be written).

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/78/20/wKiom1Z2eiXhaMwAAAAUkBk3JTE386.png "title=" 3.png " alt= "Wkiom1z2eixhamwaaaaukbk3jte386.png"/>

4, testuser with Vim Open and write "abc", forcibly save exit.

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/78/1E/wKioL1Z2esXT_ROQAAAGtUu9zd0265.png "title=" 4.png " alt= "Wkiol1z2esxt_roqaaagtuu9zd0265.png"/>

The VIM editor prompts you with the following information:

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/78/1E/wKioL1Z2ewaC5XjIAAAFv2ztEm8740.png "title=" 5.png " alt= "Wkiol1z2ewac5xjiaaafv2ztem8740.png"/>

Force write Save exit:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/78/1E/wKioL1Z2e6eSRahKAAASLJ5u_io946.png "style=" float: none; "title=" 6.png "alt=" Wkiol1z2e6esrahkaaaslj5u_io946.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/78/20/wKiom1Z2e5iQEHd6AAAL_YbAG0c294.png "style=" float: none; "title=" 7.png "alt=" Wkiom1z2e5iqehd6aaal_ybag0c294.png "/>

5, at this time to view the contents of the file as "ABC", and the document is the owner and the group actually become testuser.

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/78/20/wKiom1Z2fCjTopXAAAATk6B9EBg355.png "title=" 8.png " alt= "Wkiom1z2fcjtopxaaaatk6b9ebg355.png"/>

Extended Thinking : If the user group Testgroup to this directory/tmp/test/testfile there is no write permission, only read and Execute permissions. Neither Vim nor Echo can be written.


See this blog post of the vast number of netizens can try to verify the above process, I hope there are cattle people on this phenomenon can enlighten one or two.

Note: This verification process is based on CentOS 6.7 validation.



This article is from the "Roadtoom" blog, make sure to keep this source http://flyalways.blog.51cto.com/7680670/1726570

A question about permissions in 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.