Linux permission setting chmod and linux permission chmod

Source: Internet
Author: User

Linux permission setting chmod and linux permission chmod

Set permissions in Linux. the chmod command is generally used.

1. Introduction

Permission setting chmod

Function: Change the permission command.
Common parameters:

1 = x (execution right execute) 2 = w (write Right write) 4 = r (Read right Read)

After setuid is set, the file has the permissions of the file owner, such as root permissions.

After setgid is set, the file created under the directory has the permission to the group to which the directory belongs.

After stickybit is set, files cannot be deleted
Operation prompt: chmod parameter file or directory name

2. File Permission Parsing

 

For example, this is the permission attribute of a txt file. ower is the permission that the file creator can operate on the file, and group is the permission that the file creator belongs, others is the operation permission of other users.

In Octal, the first digit 0 represents setuid + setgid + stickybit, and the second digit 7 represents the R + W + X of the owner, the third digit represents the sum of R + W + X of the Group. The same is true for Others.

So the detailed explanation of "0776" above is: rwxrwxrw-

For example, "7766" represents rwsrwSrwT

So where did the original execution mark x go? The system stipulates that, if there is x in this bit, these special signs will be displayed as lowercase letters (s, s, t ). otherwise, uppercase letters (S, S, T) are displayed)

Got it?

3. Command window

For example, "6677" is displayed in the property permission and command window as follows:

The specific meaning of the permission will not be mentioned. Do you think it is a little different from what I mentioned earlier when I look at the red mark in the command line window?

Yes, there is one more "-" in front, and the first one is used to indicate whether the file or directory is a symbolic link (in general, the shortcut)

If it is an example, the first digit is shown as l, pointing to a.txt

4. Command operations

Show file list details ls-l

Change permission chmod 776 h.txt

These two commands are commonly used.

There are also some other commands to set a specific type of permissions separately.

Chmod u + s temp -- add the setuid flag to the temp file. (setuid is only valid for the file)
Chmod g + s tempdir -- add the setgid flag to the tempdir directory (setgid is only valid for the Directory)
Chmod o + t temp -- add the sticky flag to the temp file to prevent accidental deletion (sticky is only valid for files)

With the preceding command, chmod u + s h.txt has the permissions of the creator of the h.txt file.

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.