Permission-comprehensive permission drill and example

Source: Internet
Author: User
Tags superuser permission
We still have a problem. Under the current permission, the files and directories created under the Music directory have the general permissions of user bill and karen. That is,-rw

Application scenarios

Assume there are two users named bill and karen respectively. They all have music CD sets and want to create a shared directory.

They store their own music files in this directory.

User bill obtains the superuser permission through sudo.

========================================================== ====

Step 1

Bill created a group named music and added the user bill and karen to the group.

========================================================== ====

Step 2

Bill created a directory for storing music files.

Sudo mkdir/usr/local/share/Music

Because the object that bill is operating on is a file outside his main directory, he needs to have the permissions of the Super User.

========================================================== ====

Step 3

View Music directory permissions

[Allyes_op @ allyes ~] $ Ls-ld/usr/local/share/Music

Drwxr-xr-x 2 root 4096 May 30/usr/local/share/Music

You can see that this directory is owned by the root user. The permission value is 755.

========================================================== ====

Step 4

To make the directory shareable, Bill needs to change the group to which the directory belongs and grant the group write permission to the reorganization.

[Allyes_op @ allyes ~] $ Sudo chown: music/usr/local/share/Music/

[Allyes_op @ allyes ~] $ Sudo chmod 775/usr/local/share/Music/

========================================================== ====

Step 5

We still have a problem. Under the current permission, the files and directories created under the Music directory have the general permissions of user bill and karen. That is,-rw-r --.

This is because the default permission mask in the system is 0022.

This will not allow group members to write files belonging to other members in the group.

The solution is to change the permission mask used by bill and karen to 0002.

[Allyes_op @ allyes ~] $ Umask 0002

========================================================== ====

Step 6

Another problem is that every file and directory created by the member will be set to the valid Group of the user rather than the muisc group.

You can set setgid to fix this problem.

[Allyes_op @ allyes ~] $ Sudo chmod g + s/usr/local/share/Music

========================================================== ====

Note:

Here we have another problem. The mask set by the umask command can only take effect in the current shell session.

In the following content, we will introduce how to make the mask value of the umask command take effect permanently.

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.