A single file name or directory name is no longer than 255 characters, and the absolute path length of the file or directory is not more than 4096 characters;
First, the file owner and user group
A file has many properties, including file type, file permissions, file hiding permissions, file owner, user group, file size, creation date, modification date, access date, and so on, such as the following properties of the/etc/inittab file:
1. File Types
(1) D: Catalogue; find/-type D query; (2)-: general file; Find/-type f query; (3) L: Link file; Find/-type l query; (4) B: block device, i.e. storage device, such as/dev/sda;find/-type b (5) C: a character device, i.e. a serial port device such as a keyboard, such as a/dev/zero;find/-type C query, (6) S:socket, such as/var/run/acpid.socket;find/-type s query; (7) P:pipe files, such as we can create pipe files through Mknod mypipe p; Find/-type p query;
2. File owners and user groups
First of all: The file owner is not related to the user group itself, such as the user group can be root, but the file owner is xiazdong; case analysis: (1) A file owner of the file is Xiazdong, the user group is root, the current login user is Xiazdong, If you want to make the owner of the file root, can it be successful? (2) The file owner of a file is Xiazdong, the user group is root, the current logged on user is root, and if you want to make the file owner root, can it be successful? To sum up: Change the owner of the file, the user group should be the role of Root, another point: a user will always belong to one or more user groups, a user group can have multiple users, such as root users belong to the root user group, but we can also create a user Xzdong, and belong to the group1 user group, but also belong to the group2 user group;
3. Mtime, Atime and CTime of documents
Mtime: File content modification time; atime: file access time; CTime: File permissions, time the owner was modified; LS
--time=atime/ctime
CommandThe CHGRP, Chown command is used to set the file owner, user group, (1) chgrp Xiazdong test.txt: Set the Test.txt file user group to Xiazdong; (2) Chgrp Xiazdong Dir: Set dir's file user group to Xiazdong, (3) chown Xiazdong test.txt: Set test.txt file owner to Xiazdong; (4) Chown Xiazdong:root Test.txt: Set Test.txt's file owner to Xiazdong and user group to root;
ii.. File PermissionsFile permissions Specify the file owner's permissions on the file/directory, the permissions of the members of the user group to the file/directory, and other people's permissions to the file/directory, (1) R: Read access, (2) W: Writable, (3) x: Executable, and for directories and files, these permissions represent different meanings. For the file: (1) R: can read the contents of the file, (2) W: can write the contents of the file, but cannot delete the file, if you want to give permission to delete files, you need to specify directory permissions, (3) x: Execute the file, not every file requires this permission, such as TXT file does not need; For the Directory: (1) R: can read the directory structure, that can execute the LS view directory under the file name, (2) W: Can change the structure of the directory, that is, add, delete files under the directory, rename the file, (3) x: Access to the directory, that is, CD to the directory; , but does not have X permission, only LS out of the file name, but not the document attributes, as shown: note: If the dir directory exists test.txt file, if the Xiazdong user does not have the Dir write permission, even if the test.txt has RWX permission, also cannot delete test.txt; The most important thing to note is that no matter what the file permissions are set (only the general permission is discussed here, the special permissions are not counted), root can rwx the file or directory; case:-rwxr--r--means (1) The file owner can read, write, and execute the file; (2) The owning user group is able to read the file, (3) The other person can read the document;
Commandchmod command can set the permissions of the file; Note: We can set the permissions by numbers or symbols, if it is a number, then 4 represents r,2 on behalf of w,1 X, if it is 5 for r-x,6 on behalf of rw-,7 on behalf of RWX; G for Group,o representative Others,r is R,w is w,x is X, nothing is written to indicate that a permission is not; (1) chmod 755 test.txt: Giving Test.txt rwxr-xr-x (2) chmod u=rwx,go=r Test.txt: Give Test.txt rwxr--r--(3) chmod a=r test.txt: Give Test.txt r--r--r--(4) chmod a+x test.txt: Add x permission to all people in Test.txt; (5) chmod a-x test.txt: To test.txt all the people delete the X permission; (6) chmod u=rwx,go= test.txt: Give Test.txt rwx------The following sections are the exclusive features of the Ext file system
third, file hidden properties(1) A: Files can only be added, cannot be modified, deleted; often used in log files, (2) I: Files can not be modified, deleted, even if root is not, for fixed files;
Command
1, lsattrlist attribute, that is, lists the hidden properties of the file or directory; lsattr file: Lists the hidden properties of the files, lsattr-d dir: Lists the hidden properties of the directory, 2, chattr change attribute, That is, modify the hidden properties of a file or directory, (1) I: If this property is set, the directory or file cannot be modified (even if root cannot modify or delete him). (2) A: If you set this property, you can only add content, not modify or delete the content; chattr +ai file: Add property; Chattr-ai file: Delete property; chattr =a file: Set properties;
Iv. Special permissions of the fileThe file has 3 special attributes: (1) SUID: The X-permission position of the user's owner is "s", such as/USR/BIN/PASSWD, (2) SGID: The X-permission position of the user group is "s", such as/usr/bin/locate, (3) Sbit: In the other X-permission location is "T", such as/tmp;
SUIDSuid can only be given a binary file, and the user has X permission to the file, give suid effect; Suid effect: When the general user has X permission to the binary file B, and B file already has the SUID permission, when the general user executes B, the user will have the permission of the file owner;
SGID
Sgid can give directories or files, the performer must have X permission; Sgid use: Team development, and a directory is the team's shared directory, anyone who creates files in this directory, the user group of the file is the team, not the individual user group; Sgid effect: (1) When a file Sgid is given: When the performer executes, This performer will have the permission of the user group, (2) when the directory Sgid: When the performer enters the directory, the effective user group is the user group of the directory, such as the user creates a file, the user group of this file is the user group of the directory, for example, create the Chmodtest directory, the permission is drwxrwsrwx, Test.txt is created after entering the directory with Xiazdong, the Test.txt file owner is Xiazdong, but the user group is root;
Sbit
can only be assigned to directories, if the directory is assigned to Sbit, then user a file or directory created in this directory only root and user A can delete, others cannot delete;
CommandSet SUID, SGID, Sbit, through chmod settings; suid:4sgid:2sbit:1 (1)-rwsrw-r--: Digital representation: chmod 4764 file, the first number 4 is set SUID; symbol: chmod u=rwxs , G=rw,o=r file (2)-rwxrwsr--: Digital representation: chmod 2764 file, the first number 2 is set sgid; symbol: chmod u=rwx,g=rwxs,o=r file (3)-rwxrwxr-t: Digital representation : chmod 1764 file, the first digit 1 is set sbit; symbol: chmod u=rwx,g=rwx,o=rt file u+s: Plus suid;g+s: plus sgid;o+t: plus sbit; blog.csdn.net/xiazdong/article/details/7926672
Getting Started with Linux: File permissions, users, user groups (more clearly)