File Permission in linux, File Permission in linux
Recently, I encountered a number of issues about minimizing permissions. Here I will summarize the file permissions in linux, which is actually very simple.
To introduce files in linux, you must first introduce the concepts of users and user groups.
Like windows, linux requires users to log on. The difference is that in linux, there is also a concept: user group. That is, the group to which the current user belongs. Why should we introduce such a seemingly useless user group? This is mainly for the convenience of team collaboration in linux. Each user has its own unique permission control. But sometimes, there are some public files or folders that you can use. I also use, but we don't want everyone to use.(Anti-theft connection: This article first from the http://www.cnblogs.com/jilodream)So we came up with the concept of a group. We can only add permissions for this group. In this way, all users in this group have operation permissions on this file.
Next let's take a look at the control of file permissions.
Both users and user groups have three permissions.
Read: r
Write: w
Execute: x
For example, the user permission of file f can be set:
Rwx: indicates that the current user has three permissions: read, write, and execute.
R-x: indicates that the current user has read and execution permissions. (Note: Generally, this permission is set for script execution)
Remember that the order of reading, writing, and execution is fixed. If the corresponding permission is not set, use-(to replace this bit ).
For computer users, if data exists at a location,We usually use 1 instead. If not, use 0 instead.
Therefore:
After r-x is equal to 0b101, the conversion is 5.
After rwx is equal to 0b111, it is 7.
--- 0 after 0b111 Conversion
For example, file permissions are set in three aspects:
Permission of the user to which the current file belongs.
Permissions of the user group to which the current user belongs.
Permissions of other users.
(Anti-theft connection: This article first from the http://www.cnblogs.com/jilodream)
Note that the order of the three is also fixed.
For example, the total permission of the current file is
R -- rw-r-x, which is converted to 4 (r --) 6 (rw-) 5 (r-x)
Generally, a file has 777 permissions, which means that the user, user group, and other users have rwx permissions.