View and modify (rpm) linux file permissions

Original link: https: //www.cnblogs.com/sxdcgaq8080/p/7498906.html

command:

chmod 777 scan_record.js

format:

chmod permissions digital file name

 

r read permission to read 4

w write permission to write 2

operating authority execute 1 x

 

Permissions corresponding to the digital rights group Description:

Total is divided into four parts

[File or folder permissions owner] [] [] [others rights group permissions]

[Files is -, folder d] [r / w / x [sum] r / w / x [sum] r / w / x] are added

The basic Linux file permissions have nine, respectively, is owner / group / others Three Identities have their own read / write / execute permissions.

 

 

The OK, the interface description is completed, the actual examples described:

d rwx rwx rwx = 777 indicates a directory operation rights of

- rwx rwx rwx = 777 represents the operating authority file

 

 

 - rwx rwx rwx = 777 represents the operating authority file

- rw- r-- r-- = 644 represents the operating authority file

 

 

I understand enough to say OK! ! !

 

------------------------------------------------------------------------------------------------------------------------------------------

Detailed text =================================== ============= ======================================

 File permissions can right-click on the file in the Linux system -> Properties to view.

  But this time we are using a rights-wide commands to view and modify files

  To give an example, we have established a fileA file in mnt folder, and then create a zhaoyuqiang.html page fileA folder.

Built it, we have to fileA file and zhaoyuqiang.html file for something, huh

Permissions to view the files

  Let's look at zhaoyuqiang.html access to this page file.

Methods: In the terminal enter:
LS xxx.xxx the -l (xxx.xxx is the file name) to view the file permissions are among the xxx file

So similar message appears, it is mainly these: -rw-rw-r--

 A total of ten digits, where: the front - represents the type

The middle three rw- on behalf of the owner (user) has the authority

  Then the three r-- represents the group (group) have rights

  Finally, the three r-- behalf of someone else (other) has the authority

 then

r indicates that the document can be read (Read)

w indicates that the file can be written (write)

x indicates that the file can be executed (if it is a program of the words)

- indicates that the corresponding permission has not been granted

After root root user is the owner.

Note that : to view the file directory permissions problem:  If there are folders / a / b / c

File then execute ls -l / a / b not have permission to view b, c authority, but rather to view.

ls -l / a view of the b file permissions

ls -l / a / b to view the file permissions c

ls -l / a / b / c to view the file permissions c

 

Introduction to modify permissions

Enter in a terminal:

chmod o w xxx.xxx

  Express grant permission to others to write the file xxx.xxx

chmod go-rw xxx.xxx

  Express permission to delete the group xxx.xxx and others to read and write

  among them:

u behalf of the owner (user)

g on behalf of the owner's group (group)

o behalf of someone else, but not u and g (other)

a representative of all of them, i.e. including u, g, and o

r indicates that the document can be read (Read)

w indicates that the file can be written (write)

x indicates that the file can be executed (if it is a program of the words)

  Wherein: rwx may be replaced with a digital

r ------------4

w -----------2

x ------------1

- ------------0

  action:

Adding expressed permission

- Indicates delete permissions

= Indicates making it the only permission

When we all understand the above things, then we are following some of the common permissions are easily understood:

-rw ------- (600) Only the owner has read and write permissions

-rw-r - r-- (644) Only the owner has read and write permissions, group and others have only read access

-rwx ------ (700) Only the owner has read, write, and execute permissions

-rwxr-xr-x (755) Only the owner has read, write, and execute permissions, group and others have only read and execute permissions

-rwx - x - x (711) Only the owner has read, write, and execute permissions, group and others have only execute permissions

-rw-rw-rw- (666) everyone has read and write permissions

Permissions -rwxrwxrwx (777) everyone has read, write and execute

 

Linux file and directory access permissions

Using chmod and change digital file or directory access
      permissions to files and directories, he said that with these three characters rwx behalf of the owner, user groups and permissions for other users. Sometimes, the characters seem to be too cumbersome, so there is another approach to digital rights to represent , but only three digits.
r: the corresponding value. 4
W: value corresponding to 2
X: value of 1 corresponding to
: - the value 0 corresponding to
the key number set mode is the value, at the beginning will be confused many beginners, is very simple.

(A) We will rwx as a binary number, if there are 1 indicates, there does not represent 0, then rwx rx r- - can be represented by: 111,101,100 each of which three and then converted into a decimal number, is 754.

(B) can also be understood as a simple calculation: (4 + 2 + 1) (4 + 1) (4) = 754
, for example, we want zhaoyuqiang.html the file permissions are:
           own the same group of users other user
-readable Yes Yes Yes
writable Yes Yes 
executable is
so, we first obtain permission string according to the table: rw-rw-r--, then converted into a binary number is 110110100, and then converted into each of three a decimal number, you get 664, so we execute the command:

The figure can be seen that after 664 zhaoyuqiang.html executed, it becomes a permissions

         - rw- (own) rw- (the same group of users) r - (other users)

 

According to the above rules, together rwx = 7 is 421, a full-open permission rwxrwxrwx file, values were expressed as 777; and completely open the file permission "---------" represents a number which is 000. Here are a few examples:
-rwx ------: 700 is equal to a digital representation.
-rwxr-r--: 744 is equal to a digital representation.
-rw-rw-rx: 665 is equal to a digital representation.
drwx-x-x: represents a number equal to 711.
drwx ------: 700 is equal to a digital representation.

 

Want to join a permission to modify all the files under a directory, including file permissions subdirectories should also be amended, that is to say, I had to change the permissions fileA folder permissions to subfolders of fileA file is also modified together, to start using the parameter represents -R recursive processing.
E.g:

As shown above, after 700, fileA fileA edit access permissions into a permission drwx ------ but is still zhaoyuqiang.html-RW-r-- -rw .

The figure above, for fileA modify permissions -R 744, the result fileA authority and its subfolders zhaoyuqiang.html have become -rwxr - r--.

By comparison of the two:

[root @ localhost ~] # chmod 700 / mnt / fileA NOTE: Only the authority fileA directory to 700
[the root @ localhost ~] -R & lt # the chmod 744 / mnt / fileA Note: shows a whole / mnt / fileA catalog the files and subdirectories permissions are set to 744

 

 

Note or modify the permissions on the file problem : for example, there is a file / a / b / c.

Execution: chmod 700 / a modification of a file's permissions

       chmod 700 / a / b b a modified file permissions

       chmod 700 / a / b / c c a modified file permissions

To view the file and directory permissions separately

 

 

Use the command chown to change the ownership of a directory or file
    files and directories can not only change the permissions, its ownership and user group can modify, and set permissions Similarly, the user can set through a graphical interface, or execute the chown command to modify.
Let's take a look at the implementation of directory ls -l situation:

The figure, zhaoyuqiang.html permission to view the file, the red area indicates user group zhaoyuqiang.html this file is root, root for the owner

  We have to do is modify the User Group and owner of the file.
(1) execute the following command, the transfer of ownership to the user zyq zhaoyuqiang.html file:

 The image above the red zone file belongs to the user group has indeed changed the zyq.
(2) To change the belonging group, use the following commands:

The figure can be seen that we modify the owning group fileA folder is zyq.

(3) also modify the user group and owner of the file.

      This approach, I believe we all thought

(4) to simultaneously modify user group and owner fileA and its subfolders zhaoyuqiang.html of.

     The use of the -R argument on it.

 

Well, about a file permissions issue when it comes to this place.

 

 

=====================================================================================================

Reprint of this said, very comprehensive, we hope to be able to have effective help, while reproduced when indicate the source of this article, to respect the original author. Thank you! ! ! ! ! !

Guess you like

Origin www.cnblogs.com/qcq0703/p/11140869.html