- Three major categories of file types
- Normal file: Includes text file, data file, executable binary program file
- Catalog files: The Linux system sees the directory as a special kind of file, which makes up the tree structure of the file system.
- Device files: The device is also seen as a file, such as your mouse, your hard disk, and so on in the Linux performance is a file
- identifier of the file type
There are a lot of different file types of Linux, the different file processing methods must be different, for example, the normal file and the directory file processing method is certainly different, then the system is how to recognize it? , and tag them with different codes in the file attributes .
Below is Different encodings for different files
- Normal file (-)
- Catalogue (d)
- Symbolic Link (l)
- Character device file (c)
- Quick Device file (b)
- Sockets (s)
- Named Pipes (p)
To view the type of file with a command
#ls-L
For example, in the Test folder , preceded by Drwxr-xr-x, where the first encoding D, that is, this is a directory, and other analogy
character device files, fast device files, and connection files can be found in the/dev directory!
- file Permissions
a file's permission system is divided into three parts , according to the user's attributes .
- Permissions for the owner of the file (U)
- Member permissions for the group to which the file belongs (g)
- Other user Rights (O)
The file's permission type is also divided into three parts
- Read R (Read): For the file, has the permission to read the contents of the file, for the directory, with the browse directory to get permission
- Writing w (write, write): For the file, there is the right to repair the contents of the file, for the directory, to delete, move files within the directory permissions
- Execute x (Execute, execute): For a file, have permission to execute the file, and for the directory, the user has permission to enter the directory
Like what
-rw-r--r--
The first "-" indicates that the file is a normal file
The Next "rw-" indicates that the file's owner has read and write permissions
The Next "r--" indicates that the same group of users as the file's owner has only read access
The Next "r--" means that the other peers just have read access
- Modify file Permissions command
use chmod to modify file permissions
format chmod [-r] {[ugoa][+-=][rwx]} < filename or directory name >
Note: In the format [] indicates that the option is optional , {} represents a whole,<> indicates a required parameter
The meaning of different options
- -R: If the operation is a directory, it means that the same permission settings are implemented recursively for all sub-items in that directory
- U denotes owner (user)
- G indicates the owning group user
- o indicates other users (other)
- A means all users (all)
+-=, respectively , to add, delete, set
Instance operations
Create a new test.txt file First
#touch Test.txt
#ls-L
Discover that the owning master has read and write permissions
Increase execution permissions on it
#chmod u+x Test.txt
#ls-L
Chmod can also use three-bit numbers to change file permissions
The first person to represent the owner of the file's permissions
The second digit represents the permissions of the group to which the file belongs
Third delegate permissions for other users of the file
4(read)R
2 ( write ) W
1(execution) X
#chmod Test.txt
#ls-L
The owner of the Test.txt file has permission to read and write, and other users do not have any permissions and will find it convenient
- Modify the owner and owning group of the file
You can use the chown command to change the user and user group permissions that the file or directory belongs to (change owner)
Note: The user and user groups must be guaranteed to exist before executing the system
a user user1 User2 first. Owning group has group1 group2
Change the testfile from the original owner to the user1 user2, the original group user1 to group2
#chown user2:group2 testfile
# Summary #
Another day, come on!