Linux Getting Started basic--linux permissions mechanism

Source: Internet
Author: User

The Linux privilege mechanism permission is the mechanism used by the operating system to restrict access to resources, and the permissions are generally divided into read, write and execute. Each file in the system has specific permissions, the owning user, and the owning group, which restricts which users and which groups can do what for a particular file.
Each process runs as a user, so the process has the same permissions as the user, and the greater the user's permissions, the greater the permissions the process has.
File permissions in Linux, each file has three permissions:
Impact of permissions on files on the directory
R reads readable file contents to list contents of directory
W Write modifiable file content to create or delete files in the directory
x execution can be executed as a command to access directory content
You must have X Execute permission for the directory, or you cannot view the contents of the directory
Ugolinux permissions are controlled based on the UGO model
U represents user,g on behalf of Group,o on behalf of other
Permissions for each file are set based on Ugo
Permissions three A group (RWX), corresponding Ugo set separately
Each file has a owning user and the owning group, corresponding to UG, which does not belong to the user or group that the file belongs to use O permission.
The command ls-l can view the details of the files in the current directory, such as the file code details:
Drwxrwxr-x 3 Liu Liu 4096 May 14:59 Code
The first part: UGO
Part II: Number of links (file has several links)
Part III: U: User
Part IV: G: Affiliation Group

Part V: Size
Part VI: Time (file creation modification time)
Part VII: File name
Ugo's permission is the first part, its length is 10 bits, the first bit is file type D is directory, the latter nine bits are divided into three groups, corresponding to UGO permissions respectively.
U-owned user owned permissions (RWX), G-owned group owned permissions (RWX), O other owned permissions (r-x)

Modify the user that the file belongs to, Group command Chown to modify the file's owning User:
Chown username filename
-R parameter recursively modifies the directory under which all files belong to the user
Command Chgrp to modify the owning group of the file
CHGRP groupname filename
-R parameter recursively modifies the owning group of all files under the directory
Modify Permissions Command chmod permissions to modify a file
chmod mode file

The pattern is the following format:
U,g,o represents users, groups, and other
A can replace Ugo
+,-delegate to join or delete the corresponding permission
R, W, X for three kinds of permissions
Pattern Example:
chmod U+RW filename
chmod g-x filename
chmod go+r filename
chmod a-x filename
For example, use VIM test to create a file and then Ls-l test
-rw-rw-r--1 Liu Liu 14 June 6 11:14 Test
then use chmod +x test, then ls-l test
-rwxrwxr-x 1 Liu Liu 14 June 6 11:14 Test
We can see the user who owns the test file, the group it belongs to, and the others that have permissions to execute it.
Modify Permissions The command chmod also supports the ability to digitally modify permissions, which are represented by three numbers for each of the three permissions:
-R = 4 (2^2)
-W = 2 (2^1)
-X = 1 (2^0)
When using numbers to represent permissions, each group of permissions corresponds to the sum of the numbers:
RW = 4+2 = 6
rwx = 4+2+1 = 7
R-x = 4+1 = 5
So using numbers to indicate that the UGO permission is represented in the following way:
chmod 660 filename = = RW-RW----
chmod 775 filename = = Rwxrwxr-x

Linux Getting Started basic--linux permissions mechanism

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.