The display information for the ll instruction is (only Nameservice1 a directory under the current directory):
Drwxr-xr-x 3 HDFs hdfs 4096 April 16:19 Nameservice1
The above information indicates: permissions (drwxr-xr-x 3), owning User (HDFS) and group (HDFS), size (4096), Time (April 14 16:19), name (Nameservice1).
The letters in the permission have a total of 10 digits:
There are two options for the 1th bit:-Indicates the file, and D indicates the directory. Here is D, indicating that Nameservice1 is a directory;
The 2nd to 4th bit rwx represents the permissions of the owner (the owning user HDFs);
The 5th to 7th bit R-x represents the permissions of the group (HDFS);
8th to 10th R-x represents the rights of other persons (other);
Other than that
R indicates that a 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 permission has not been granted
1. Permissions to modify files
To view the permissions information for the current file file temp:
ll | grep temp-rw-rw-r-- 1 root root 4405 March 11:50 Temp
Instructions for modifying file permissions:
chmod o+w Temp
To give the file temp permission to write to someone else, now view the permissions information for temp:
-rw-rw-rw- 1 root root 4405 March 11:50 Temp
We found that the 9th place had a W.
Where the meaning of the parameter representation is:
U on behalf of owner (user)
G represents the group where the owner resides
O stands for others, but not u and g (other).
A represents all people, including U,g and O.
R indicates that a 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 be replaced by numbers
R------------4
W------------2
X------------1
-------------0 Action:
+ means add permission
-Indicates delete permission
= means to make it the only permission when everyone understands what's above, it's easy to understand that some of the following permissions are common:
-RW-------(600) Only the owner has read and write permissions
-rw-r--r--(644) Only the owner has read and write permissions, and the group and other people only have Read permissions
-RWX------(700) Only the owner has read, write, execute permissions
-rwxr-xr-x (755) Only the owner has read, write, execute permissions, groups and other people only read and Execute permissions
-rwx--x--x (711) Only the owner has read, write, execute permissions, groups and other people only execute the permissions
-rw-rw-rw-(666) Everyone has access to read and write
-RWXRWXRWX (777) Everyone has access to read and write and execute
2. Modify the owner and group of the Directory
Modify the owner of the directory to Root:root (the first root represents the group and the second root represents the user). This directive needs to be used under root authority.
Chown-r Root:root Nameservice1
The ll will be executed at this time, showing the result as:
Drwxr-xr-x 3 root root 4096 April 16:19 Nameservice1
You can change the owner of a file by replacing it with the name of the file, for example:
Chown-r Root:root Test.txt
Change only the owner of a file or directory
Chown-r Owner:test.txt
Change only groups of files or directories
Chown-r: Group Test.txt
chmod Modify the permissions of a file/chown modify the file and directory owner