Linux-permission management
Permission management:
Chmod (Change File Permission), chown (change file owner), passwd (Set User Password), SU (User Switch), useradd (add user), groupadd (Add User Group)
Given system permissions involves system security issues, it is very important to manage system permissions.
1. Change the File Permission In CHMOD. File permissions are divided into three parts: Owner (file owner) permissions, user group permissions, and other user permissions. Each part has R (readable), w (writable ), X (executable), there is a letter at the beginning to indicate the file type, such as D indicates the directory,-indicates the common file, C indicates the device, in this way, it is a string of 10 letters. For example, the "-" in the middle of drwxr-xrwx indicates that the property has been removed. Of course, the corresponding operation cannot be performed, for example, the file attribute indicated in the preceding example is that other users in the user group cannot write data to the file.
Common parameters: NNN (where NNN is a number). The File Permission can also be represented by a string of numbers. The first n represents the master permission, and the second represents the user group permission, and so on. In the rwx sequence, R is represented by number 4, W is represented by number 2, and X is represented by number 1. Therefore, if the number is 5, the corresponding permission is r-X, for example, 753 is equivalent to-rwxr-X-WX. G + RW, o-w, U + W, G represents the user group, O represents the file owner, u represents other users, and +/-represents adding/removing this permission. -R: Change the attributes of all files in the directory and Its subdirectories. Note: If you want to enter the directory, you must set it to executable. If you want to run the program, you must also set it to executable.
Example: chmod-r 766 filename; chmod U + x filename.
2. chown: Change the file owner. Another item in the file property is the file owner, which is represented as "user. User Group". Sometimes you need to change this item.
Common parameters:-R: Change the attributes of all files in the directory and Its subdirectories.
Example: chown-r root. Root filename;
3. passwd: Change the user password;
Common parameters: None
Example: passwd and passwd username require the root permission to change the user password;
4. Su: Change the user to change the account currently logged in to another account and log in again.
Common parameters: None
Example: su root;
5. useradd: Add users. root permissions are required. User maintenance Commands include userinfo, usermod, and userdel for query, modification, and deletion.
Common parameters:-G adds a user to a specified user group;
Example: useradd-G mygroup username.
6. Add groupadd, add groups, and maintain group commands as well as groupmod and groupdel.
Common parameters: None
For example, groupadd mygroup.