Basic Attributes of Linux Files and basic attributes of linux Files
Linux is a typical multi-user system. Different users are in different positions and have different permissions. To protect the security of the system, Linux requires different users to access the same file (including directory files ).
1. in Linux, we can use the ll or ls-l command to display the attributes of a file and the users and groups to which the file belongs.
ls -l
In the instance, the first attribute of the test file is represented by "d. "D" indicates that the file is a directory file in Linux. The first character in Linux indicates that the file is a directory, file, or link file.
- When it is [D] Is the Directory
- When it is [-] Is a file;
- If [LLink file );
- If [B] Indicates the interface device that can be stored in the device file (random access device );
- If [C] Indicates the serial port device in the device file, such as the keyboard and mouse (one-time reading device)
The following characters are a group of three parameters, all of which are a combination of the three parameters of "rwx". Note that the positions of these three permissions will not change. If you do not have the permissions, the minus sign [-] will appear.
- [R] indicates read)
- [W] indicates writable (write)
- [X] indicates executable ).
The attributes of each file are determined by 10 characters in the first part on the left (for example)
2. Change File Permissions
Linux File permissions can be set in two ways: numbers and symbols.
There are nine basic permissions for Linux Files: owner, group, and others. Each of these three identities has its own read, write, and execute permissions.
The permission character of the file is "-rwxrwxrwx". The nine permissions are in a group of three or three! Here, we can use numbers to represent each permission. The score of each permission is as follows:
The three permissions (r/w/x) of each identity (owner/group/others) must be accumulated. For example, when the permission is: [-rwxrwx ---] The score is:
- Owner = rwx = 4 + 2 + 1 = 7
- Group = rwx = 4 + 2 + 1 = 7
- Others = --- = 0 + 0 + 0 = 0
So when we change the permission settings, the permission number for this file is 770.
Chmod [-R] xyz file or directory
Options and parameters:
- Xyz: The permission attribute of the numeric type just mentioned. The sum of the attribute values.
- -R: Perform recursive changes, that is, all files under the directory will be changed together.
For example, view the file attributes in the test file:
Here, there are 1 1.txt files with 777 permissions.
View the file attributes in the test1 file:
Here, there are 1 2.txt file, with 644 permissions. Now, the permission for modifying 2.txt is 777 the same as that for 1.txt. You can use chmod u = rwx, g = rx, o = r file name to set it.
chmod 777 test1/2.txt