linux study (four) Linux basic file attributes

I. INTRODUCTION

  Linux system is a typical multi-user systems, different users have different status, with different privileges.

  To protect the security of the system, Linux system access the same file (including directory files) for different users to do different provisions.

In Linux we can use ll or ls -l command to display user and group attributes of a file and the file belongs.

Second, the document structure analysis

  We enter in a CRT ll instructions can view a folder under the ownership of the file, as shown below:

  Let's analyze

 

Attribute of each file is determined by the 10 characters (as in "dr-xr-xr-x") to the left of the first portion. We put ten characters apart to see:

10 characters, said:

  • 0 : determine the file type
  • Bit 1-3 : determine the owner of the file permissions for the file owner
  • 4-6 : determine the owner of the same group that owns the file permissions for the user group
  • Bit 7-9 : determine the other user who owns the file permissions for others

The first character: this represents the type of file, directory, file, or a link, etc.

  • d    directory
  • -    File
  • l    linked document (link file)
  • b   for storage interface device (random access device)
  • c   serial port device, such as a keyboard, a mouse (one reading unit)

The following characters: in groups of three into three groups represented by a combination of r, w, x three parameters, the position does not change

  • r   Representative read (Read)
  • w represents the write (write)
  • x   represents the executable (execute)
  • -    do not have permission

Third, change file attributes command

chgrp (change file is a group)

Syntax: chgrp[-R] is a group of the filename

例:chgrp oracleGroup xxx.log

Parameter options:

  -R : recursively change the file belongs to the group, that is, when you change a file's directory belong to the group, if coupled with -R parameter, then the group will change belongs to all the files in that directory.

chown (change the file owner, you can also change the file belongs to the group at the same time)

Syntax:
     chown [-R & lt] owner name of the file name
     chown [- R & lt] owner name: name of the file name is a group

例:
    chown root xxx.log
    chown root:root xxx.log

chmod (change file attributes 9)

A mode: digital setting 
    Syntax:
         the chmod[-R & lt] XYZ file or directory
     Example:
         the chmod 777xxx.log
 way: Symbol set 
    Syntax:
         the chmodoperation of the file or directory
     Example:
         the chmodU = rwx, RX = G, O =R & lt XXX .log
        chmodAX xxx.log # remove all human executable permissions

Digital Set

  Character file permissions are: "- rwxrwxrwx" nine permissions are three groups of three! Among them, we can use the number to represent each permission, the score table for each of the following rights:

  • r : 4
  • w : 2
  • x : 1

  For chestnut, each identity (owner / group / others) of each of three permission (r / w / x) cumulative score is needed, for example, when 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 we set to change permissions, the permissions of the file is 770 digital friends!

Symbol Set

  There is also a way to change the permissions from the previous description, we can find, essentially nine privileges are:

  • user
  • group
  • others

  Then we can use U , G , O to represent the rights of the Three Identities! In addition, A represents all, that is all identity. Read and write permissions can be written as R & lt , W , X , i.e. can use the table of view:

Guess you like

Origin www.cnblogs.com/riches/p/11883328.html