Common Linux commands-permission management commands

Source: Internet
Author: User

 

Chmod changes the permissions of files or directories

Format chmod parameter file name

R-read w-write x-Execute

O-ower owner g-group owner group o-others

+ Add a permission

-Cancel a permission.

= Grant the given permission and cancel all original Permissions

We can see that the test2 permission has changed. Sometimes it is more difficult to use this method to change permissions. All Linux systems provide another numeric representation method. In Linux, r is represented by 4, w is represented by 2, and x is represented by 1. We can directly write numbers when modifying them.

Chown changes the owner of a file or directory

Chown User File Name

The premise is that this user must exist.

Here we can see that test2 is changed, but test3 is also changed, because the two are hard-linked files.

 

Chgrp changes the group to which a file or directory belongs

Format: chgrp user group file name

Prerequisites: This User Group must exist in the system.

 

Umask sets a mask that limits the size of the new file.

Format umask mask

In Linux, the default mask is 022. We directly enter the umask command, which displays 0022,

The first one here is the special permission, and the last three are the mask of our permissions. The mask is represented by a number with the 777 permission to remove the file. The default permission of our file is 755,777-755 = 022, so the mask here is 022. You can view the permissions through umask-S. The output result is as follows:

At the beginning, we created a file and a directory. After careful observation, we found that our directory permissions are 755, but our file permissions are 644, this is inconsistent with the default one. Is it wrong? This is because there are permission restrictions in Linux. By default, the x permission of the new file is removed. In the lower half of this section, we can modify the permission to create a file and directory example.

From: Meng xiangyue's column

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.