Linux chmod command parsing and linuxchmod Parsing
Chmod command
Permission: All Users
Usage: chmod [-cfvR] [-- help] [-- version] mode file...
Note: The file calling permissions for Linux/Unix are divided into three levels: file owner, group, and others. Chmod can be used to control how files are called by others.
Parameters:
Mode: permission setting string in the following format: [ugoa...] [[+-=] [rwxX]...] [,...], where
U indicates the owner of the file, g indicates that the owner of the file belongs to the same group, o indicates that the owner of the file belongs to other people, and a indicates that all three are.
+ Adds a permission,-Indicates canceling the permission, and = indicates a unique permission.
R indicates that the file can be read, w indicates that the file can be written, and x indicates that the file can be executed only when the file is a subdirectory or the file has been set to executable.
-C: if the permission of the file has been changed, the change action is displayed.
-F: Do not display an error message if the file permission cannot be changed.
-V: displays details of permission changes.
-R: Change the permissions of all files and sub-directories in the current directory in the same way (that is, change one by one in the way of delivery)
-- Help: displays auxiliary instructions
-- Version: displays the version.
Example:
Chmod ugo + r file.txt set the file file.txt to be readable by all users.
Chmod a + r file.txt sets the file file.txt to be readable by all users.
Chmod ug + w, o-w file.txt set file.txt and file.txt as the owner of the archive, which can be written to the same group but not to others.
Chmod u + x ex1.py sets ex1.py to be executed only by the owner of the file.
Chmod-R a + r * sets all files and subdirectories in the current directory as readable by anyone.
Use numbers to indicate Permissions
Syntax: chmod abc file
Parameter: each a, B, and c is a number, indicating the permissions of the User, Group, and Other respectively.
R = 4, w = 2, x = 1.
If you want the rwx attribute, 4 + 2 + 1 = 7.
If you want the rw-attribute, 4 + 2 = 6.
If you want the r-x attribute, 4 + 1 = 7.
Example:
Chmod a = rwx file and chmod 777 file have the same effect.
Chmod ug = rwx, o = x file, and chmod 771 file have the same effect.
If you use chmod 4755 filename, this program can have root permissions.