Chmod often used. But the basics are limited to the use of chmod 755 A1. or 777.
Today encountered a problem to think, let a folder can only see themselves, others can not see. I don't know, it's a few. Deliberately learn the meaning behind these numbers.
Syntax is: chmod ABC file
Each of these a,b,c is a number, representing the permissions of user, Group, and other respectively.
R=4,w=2,x=1
To rwx the property is 4+2+1=7;
To rw-the property is 4+2=6;
To r-x the property is 4+1=5.
For example, I now hope that this folder A1 only the owner can see, can be changed, can be implemented. Others cannot see, cannot modify, cannot execute
User 4+2+1=7;
7
Group 0+0+0 = 0
0
Other 0+0+0 = 0
0
Then the combination is 700.
CHMOD A1
If I want someone else to be able to do it, you can see. But it can't be changed.
User 4+2+1=7;
7
Group 4+0+1=5;
5
Other 4+0+1 = 5;
5
chmod 755 A1
Later on the table to add, it can be.
Ways to modify a file's read-write properties
For example: Modify the index.html file to write-readable executable:
chmod 777 Index.html
To modify all file attributes under the directory to write-readable executable:
chmod 777 *.*
You can replace the folder name with the suffix name.
For example: Modify the properties of all HTM files:
chmod 777 *.htm
Ways to modify folder properties
Modify the directory/images/xiao to writable and readable executable
chmod 777/images/xiao
Modify all folder properties under the directory
chmod 777 *
Replace the folder name with *.
To modify all files and folders and subfolder properties within a folder to be writable and read executable
Chmod-r 777/upload
Summary Linux directory and file permissions difference
Files: Read file contents (r), write data to File (w), execute file As command (x).
Table of Contents: Read the file name (R) contained in the directory, write information to the directory (add and delete links to index points), search directories (can use the directory name as the pathname to access the files and subdirectories it contains)
Specifically, this is:
(1) A user with read-only access cannot enter the directory with a CD: It must also have Execute permission to enter.
(2) Users who have Execute permissions can access files in the directory only if they know the file name and have read rights.
(3) must have read and execute permissions to the LS list, or use the CD command to enter the directory.
(4) Write permission to a directory, you can create, delete, or modify any file or subdirectory under the directory, even if the file or subdirectory belongs to another user.
View Directory Permissions
Statement to view file permissions:
In the terminal input:
Ls-l xxx.xxx (xxx.xxx is file name)
Then there will be similar messages, mostly these:
-rw-rw-r--
A total of 10 digits
Which: the front one-represents the type
The middle one of the three rw-represents the owner (user)
Then the three rw-represent groups (group)
The last three r--represent other people (other)
And then I'll explain the 9 digits in the back:
R indicates that the file 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)
-Indicates that the appropriate permissions have not been granted
Now it's time to talk about modifying file permissions.
In the terminal input:
chmod o W xxx.xxx
To give other people permission to write xxx.xxx this file
chmod GO-RW xxx.xxx
Indicates deletion of Read and write permissions for groups and other people in xxx.xxx
which
U on behalf of owner (user)
G represents the group in which the owner is located
O on behalf of others, but not u and g (Other)
A represents all the people, including U,g and O.
R indicates that the file 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)
Where: Rwx can also use numbers to replace
R------------4
W-----------2
X------------1
-------------0
Let's go:
Represents adding permissions
-Indicates delete permission
= means to make it a unique permission
When everyone is aware of the above, then some of our common permissions are easy to understand:
-RW-------(600) Only the owner has read and write permission
-rw-r--r--(644) Only the owner has read and write permission, the group and others only Read permission
-RWX------(700) Only the owner has access to read, write, execute
-rwxr-xr-x (755) Only the owner has the right to read, write, execute, group and others only read and execute
-rwx--x--x (711) Only the owner has permission to read, write, execute, group and others only execute
-rw-rw-rw-(666) Everyone has access to read and write
-RWXRWXRWX (777) Everyone has access to read and write and execute