Linux File Basic Properties

Source: Internet
Author: User
Tags comparison table

Linux system is a typical multi-user system, different users in different positions, with different permissions. To protect the security of the system, the Linux system makes different rules about the access of different users to the same file (including folder files).

in Linux we can use the LL or LS–L command to display the properties of a file and the users and groups to which the file belongs, such as:

<span style= "FONT-SIZE:14PX;" >[email protected]:~$ ls-l Total dosage 56drwxrwxr-x 6 Deng Deng 4096  June  9 17:56 dumpdrwxrwxr-x 3 Deng Deng 4096  February  erh-mongo-munin-08e7aeb-rw-r--r--1 Deng Deng 8445  June  6 09:21 examples.desktopdrwxrwxr-x 3 Deng Deng 4096  June 08:35 tech163drwxr-xr-x 2 Deng Deng 4096  June  6 11:19 public drwxr-xr-x 2 Deng Deng 4096  June  6 11 : 19 Template Drwxr-xr-x 2 Deng Deng 4096  June  6 11:19 video Drwxr-xr-x 2 Deng Deng 4096  June  6 11:19 picture Drwxr-xr-x 5 D Eng Deng 4096  June  9 17:25 document Drwxr-xr-x 3 Deng Deng 4096  June 11 09:51 Download Drwxr-xr-x 2 Deng Deng 4096  June 
   6 11:19 Music drwxr-xr-x 2 Deng Deng 4096  June 10 18:13 Desktop </span>

instance, the first property of the dump file is represented by "D". "D" represents the file in Linux as a folder file.

The first character in Linux means that the file is a folder, a file, or a linked file, and so on.

    • When [ D ] is a folder
    • When [ - ] is the document;
    • If [ l ] is indicated as a linked document (link file).
    • If [ b ] is indicated as a storage interface device (a random access device) in the device file;
    • If [ C ] is indicated as a serial port device in the appliance file. such as keyboard, mouse (disposable reading device).

in the following characters, a group of three and a combination of three parameters are all "rwx".

Of [R] stands for readable (read), [W] stands for writable (write), [x] stands for Run (execute). Note that the location of the three permissions does not change, assuming there are no permissions. There will be a minus sign [-].

The properties of each file are determined by the 10 characters of the first part of the left (for example).


0-9 of these numbers are used to indicate from left to right. The No. 0 bit determines the file type. 第1-3位 determines the permissions that belong to the owner (all of the files) that owns the file. 第4-6位 determines the permissions that belong to the group (the same group of users) who have the file. 第7-9位 determines the permissions that other users have on the file.

Among them, the 1th, 4, and 7 are read permissions. Assuming that the "R" character is represented, then there is read permission, assuming that the "-" character is indicated, there is no Read permission; 2nd, 5, and 8 bits represent write permissions. Assume that the "W" character indicates that there is write permission, assuming that the "-" character indicates no write permission, and that 3rd, 6, 9 bits represent the operational permissions. Assume that the "X" character is used. There is a run permission, assuming the "-" character, there is no run permission.

Linux file owner and owner Group

for a file, it has a specific whole person, which is the user who has full rights to the file. At the same time, in a Linux system. Users are categorized by group, and one user belongs to one or more groups. Users other than the entire file can be divided into the same group of users and other users. Therefore, the Linux system according to all the files, files all the same group of users and other users to provide different access to files. In the above example, the dump file is a folder file. Both the master and the group are Deng, the owner has the readable, writable, and operational permissions, and other users in the same group have readable and operational permissions, and other users have readable and operational permissions.

Change file Properties1. CHGRP: Change file group

Grammar:

<span style= "FONT-SIZE:14PX;" >CHGRP [-R] Genus group name file name </span>

Number of parameters options

-R: Recursively change the group of files, that is, when you change the genus Group of a folder file. Assume that you add the-r parameter. Then the group of all the files under this folder will change.


2, Chown: Change the file owner, can also change the file group at the same time

Grammar:

<span style= "FONT-SIZE:14PX;" >chown [–R] is the main name file name Chown [-R] belongs to the main name: Group name File name </span>

3, chmod: Change the file 9 properties

There are two ways to set Linux file attributes, one is a number. One is the symbol.

There are nine basic permissions on Linux files, each of which has its own Read/write/execute permissions for each of the owner/group/others three identities.

First review the data just mentioned above: The file's permission character is: "-rwxrwxrwx", these nine permissions are three three a group!

Of We can use numbers to represent individual permissions, and the score comparison table for each permission is as follows:

    • R:4
    • W:2
    • X:1

each identity (owner/group/others) of the respective three permission (r/w/x) score is required to accumulate, such as when the permission is: [-rwxrwx---] score is:

    • Owner = rwx = 4+2+1 = 7
    • Group = RWX = 4+2+1 = 7
    • others=---= 0+0+0 = 0

so wait a minute. When we set a change in permissions. The number of permissions for this file is 770! The syntax for the Change permission directive chmod is this:

<span style= "FONT-SIZE:14PX;" >chmod [-r] XYZ file or folder </span>

Options and number of references:

    • XYZ: is the permission attribute of the number type just mentioned. Is the sum of the numeric values of the Rwx property.
    • -R: Continuous change of recursion (recursive), that is, all files under the sub-folder will be changed
symbol Type change file permissions

Another way to change permissions. From the previous introduction we can find that basically nine permissions each is (1) User (2) group (3) others three identities!

Then we will be able to represent three kinds of identities by u, G, O!

In addition, a represents all the identities! Then the permission to read and write can be written as R, W, x! That is, the ability to use the following way to see:

chmod U
G
O
A
+ (Increase)
-(remove)
= (set)
R
W
X
File or folder

<pre name= "code" class= "CPP" ><span style= "FONT-SIZE:14PX;"  >[email protected]:~$ chmod a+x dump[email protected]:~$ ls-l Dump total usage 16drwxrwxr-x 2 Deng Deng 4096  June  9 17:14  *drwxrwxr-x 2 Deng Deng 4096  June  9 17:14 doubandrwxrwxr-x 2 Deng Deng 4096  June  9 17:56 newsdbdrwxrwxr-x 2 Deng Deng 4096  June  9 17:56 test</span>




Linux File Basic Properties

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.