Linux Create directory allows group users to create their own files, other groups of users to access and edit, cannot delete

Source: Internet
Author: User

Test group Permissions Sgid
Create kaifadata directory, allow group users to create their own files under the directory, allow other users to access and edit, do not allow deletion
1. Creation of three users Li Wang Zhang
[Email protected] ~]# Useradd Li
[Email protected] ~]# Useradd Wang
[Email protected] ~]# Useradd Zhang

2. Create a group Kaifa
[Email protected] ~]# Groupadd Kaifa

3. Add user to Kaifa Group
[Email protected] ~]# usermod-a-G Kaifa Li
[Email protected] ~]# usermod-a-G Kaifa Wang
[Email protected] ~]# usermod-a-G Kaifa Zhang
Check the group under Add
[[email protected] ~]# ID li
uid=513 (LI) gid=513 (LI) groups=513 (LI), 516 (KAIFA)

4. Create the Kaifadata directory under/tmp and modify all groups to Kaifa
[Email protected] tmp]# mkdir./kaifadata
[Email protected] tmp]# chgrp Kaifa./kaifadata

Write permissions to the development group
[Email protected] tmp]# chmod g+w./kaifadata

[Email protected] tmp]# ls-ld kaifadata
Drwxrws--x. 2 root kaifa 4096 Sep 05:19 kaifadata

5. Give Kaifadata directory authorization Sgid attribute
[Email protected] tmp]# chmod g+s kaifadata
6. Test to create the file. Can other members access to create a file with the same name using Li Wang Zhang separately
The file groups created are all development groups
[Email protected] kaifadata]$ Ls-al
Total 8
Drwxrws--x. 2 root Kaifa 4096 Sep 27 05:22.
DRWXRWXRWT. 7 root root 4096 Sep 27 05:11..
-rw-rw-r--. 1 li Kaifa 0 Sep 05:19 Li
-rw-rw-r--. 1 Wang Kaifa 0 Sep 05:22 Wang
-rw-rw-r--. 1 Zhang Kaifa 0 Sep 05:22 Zhang

7. Set Kaifadata Directory members can only delete their own files, cannot delete other people files
[Email protected] tmp]# chmod o+t kaifadata
Verify that other people files cannot be deleted
[Email protected] kaifadata]$ RM Wang
Rm:cannot remove ' Wang ': Operation not permitted

This article is from the "small bamboo listening to the Rain Pavilion" blog, please be sure to keep this source http://xzty1.blog.51cto.com/3363303/1559233

Linux Create directory allows group users to create their own files, other groups of users to access and edit, cannot delete

Related Article

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.