Linux permission details

Source: Internet
Author: User

Linux permission details

Permission
Permission is a mechanism used by the operating system to restrict access to resources. Permissions are generally divided into read, write, and execute permissions. Each user has specific permissions, users, and groups. This mechanism is used to restrict users and groups that can perform operations on specific files.
Each process runs as a user. Therefore, the process has the same permissions as the user. if the user has a higher permission, the process has a higher permission.
In Linux, each file has the following three permissions:
Effect of permissions on files on folders
R (read) the content of the readable file can list the contents of the Directory
W (write) can write data to a file. You can create or delete files in a directory.
X (execution) can be used as a command to execute accessible contents in the directory
The directory must have the x permission (also known as the browsing permission) and only the r permission is meaningless. Otherwise, the directory cannot be viewed.

UGO
Linux permissions are controlled based on the UGO model.
U stands for user, G stands for group, and o stands for other.
The permissions of each file are set based on the UGO mode.
Three permissions (rwx) are set for each UGO.
Each file has a user and a group, which correspond to U and G respectively. O permissions are assigned to users that neither belong to the file nor belong to the user group.
Ls-l file. c. view the detailed permissions of the file. c file
Result:
D rwxr-xr -- 2 username groupname 208 xxxxxxxxxxx filename
File Type UGO file connections user group file size creation time file name

Chown username filename: Change the object to the specified user
Chown-R username directory: Change the user of all files in the directory to the specified user.
Chgrp groupname filename: Change the group to which the file belongs to the specified user group.
Chgrp-R groupname directory: Change the user group to which all files in the directory belong to the specified user group.

Chmod u/g/o + rw filename/derictoryname is the file or directory owner/owner group/other users to add Read and Write Permissions
Chmod u/g/o-rw filename/derictoryname is the file or directory owner/owner group/other users to remove the write permission
Chmod u/g/o-R-rw filename/derictoryname removes the write permission from the user/group/other users of all files in the directory
All files in the chmod g + s directname folder inherit the group to which the folder belongs.
Linux Default Permissions
Each terminal has an umask permission to determine the default permissions for newly created files and directories.
Umask uses numbers to indicate default permissions. For example, 022 corresponds to UGO permissions.
Default directory permission: 777-umask
Default file permission: 666-umask
The umask of common users is usually 002.
The root user's umask is generally: 022
You can use a single umask to view umask attribute values.
Umask num: Change umask to num

This article permanently updates the link address:

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.