Permission management command:
1. chmod [changethe permissions mode of a file]:/bin/chmod
Syntax: chmod [{ugo} {+-=}{ rwx}] [file or directory name] // intuitive
E.g. chmodu + wx filename
Chmodo-x filename
Chmodg = rwx filename
Or: chmod [mode = 421] [file or directory] // recommended
Number of the permission pair:
R-4
W-2
X-1
E. g. rwxr-xr -- 754
Rw-r-x -- x 651.
752rwxr-x-w-
Chmod777 dir1 // set the directory dir1 to have all permissions for all users
Appendix: su-username: users that can be switched // experiment content
Return: exit
Expansion:
2. chown [changefile ownership]/bin/chown
Change file owner
Chown [user] [file name or directory name]
E. g. chown nobody file1 changes the owner of file file1 to nobody, and the nobody is the default user.
Appendix: Add User: 1) useraddafang
2) passwd afang // set a password for the passwd
3. chgrp [change file group ownership]/bin/chgrp
Change the group of a file or directory
Chgrp [user group] [file or directory]
Change the group of the file file1 to adm. adm is an existing group in the system.
Why do I need to change the user group? How do I use the group? Let's study ^_^ later.
4. umask/bin/umask
Display and set default file permissions
Umask [-S]
E. g. umask // view the default permissions.
Display-Special Permission bit, 022-user permission bit [u, o], representing the mask value;
Calculation: 777 -- 022 = 755 // This is the default permission for creating a directory
644 // It is the default permission for creating files, none of which are x
Note: The-S option is not available in many UNIX systems, so it can only be calculated based on the above!
Umask-S //-S displays the default permissions of new files or directories in the form of rwx, which is more intuitive.
* 4.1 change the default permission Value
Umask [mask value] // The Mask value must be calculated first, but do not change it!
Appendix: Linux permission rules: default file creation. executable permissions cannot be granted! X
The advantage is that it shields many attacks and viruses.