Linux system is a multi-user multi-tasking time-sharing system, any user who wants to use system resources must first request an account from the system administrator and then enter the system as this account.
On the one hand, the user's account can help the system administrator to track the users who use the system and control their access to system resources, and on the other hand can help users organize files and provide security protection for users.
Each user account has a unique user name and a separate password.
User groups
Each user in Linux must belong to a group and cannot be independent of the group. Each file in Linux has the concept of owner, group, other group
-Owner
-Group
-Other groups
-Change the group where the user is located
Owner
Typically the creator of the file, who created the file, becomes the owner of the file naturally
You can see the owner of the file with the Ls‐ahl command
You can also use the Chown user name file name to modify the file owner
The group where the files are
When a user creates a file, the group where the file is located is the group that the user is in
All groups of files can be seen with the Ls‐ahl command
You can also use the CHGRP group name file name to modify the group in which the file resides
Other groups
Other users of the system are other groups of files, except for the owner of the file and the user in the same group
File permissions
Ls-l
4 4096 June : Test
-10 characters to determine what different users can do with a file
-the first character represents the file (-), the directory (d), and the link (L: indicates that this is a symbolic link file, which actually points to another file)
-The remaining characters are set per 3 (RWX), read (R), write (W), execute (x)
-First set of rwx: The file owner's permissions are read, write, and execute
-Second set of rwx: Permissions for user groups are read, write, and execute
-Third group R-x: permissions for other users who are not in the same group as the file owner are read and executed, but cannot be written
Also available as a number: R=4,w=2,x=1 so rwx=4+2+1=7
-4 indicates the number of files connected
-Root indicates that the user
-Root indicates that the user is in the same group
-4096 indicates file size (bytes)
-June 24 13:20 indicates last modified date
-Test indicates file name
Changes to the permissions of the file
chmod [U|g|o|a] filename [-r]
-R is recursive traversal of subdirectories
U on behalf of Ueser G for Group O on behalf of other User A represents all
chmod changing the permissions of a file or directory
chmod 755 ABC: Give ABC permission rwxr-xr-x
chmod U=RWX,G=RX,O=RX ABC: ibid. u= User Rights, g= group permissions, o= different groups of other user rights (note: U=rwx,g=rx,o=rx three are connected)
chmod u-x,g+w ABC: for ABC to remove user-executed permissions, increase group Write permissions
chmod a+r ABC: Add read permissions to all users
chmod a+x Auth.log #含义为 giving the owner executable permission to the Auth.log file
chmod 777 Auth.log #含义为给auth. log file gives any readable, writable, executable permission
chmod MySQL auth.log #含义为 Change the owner of the file Auth.log to MySQL
Chgrp-r MySQL apache2 #含义为, change the directory apache2 group to MySQL
Change owner (chown) and user Group (CHGRP) commands
Chown xiaoming ABC: Change the owner of ABC to Xiaoming
CHGRP Root ABC: Change the group that the ABC belongs to IS root
Chown root./ABC: Change ABC the owner of this directory is root
Chown‐r root./ABC: Change the ABC directory and the owner of all files and directories below it is root
Change the user group
When you add a user, you can specify which group to add the user to, as well as root administrative permissions to change the group in which a user resides
-USERMOD‐G Group name User name
You can use
-Usermod‐d directory name User name, change the initial directory of the user login
Comprehensive case
"Question 1.1" establishes two user groups Group1 and group2, and three users Dennis, Daniel, Abigale, and assigns the first 2 users under the Group1 user group, and the latter is assigned under the GROUP2 user group
"Question 1.2" to Dennis User login, create a Hello.java file
Question 1.3 Logs in with a Daniel user to see if you can access the/home/dennis directory and read or write the Hello.java file it created
"Question 1.4" to Dennis User login, modify the directory/home/dennis and Hello.java file read and Write permissions (correct: Modify directory permissions, should use 770, not 760, otherwise insufficient permissions)
"Question 1.5" repeat "question 1.3"
"Question 1.6" change Abigale user group from group2 to Group1
You can then use CAT/ETC/PASSWD to view and determine
Reference
-Groupadd group name, adding groups to Linux
-Vi/etc/group, see all the group information in Linux, can be edited
-Cat/etc/group, view all the group information in Linux, can not be edited
-USERADD‐G group name User name, create a user and specify which group to assign the user to
-VI/ETC/PASSWD, see all user information in Linux, can be edited
-CAT/ETC/PASSWD, view all the user information in Linux, can only see can not edit
---------------------------------------------------------------------------------------------------------
Reference Document: Http://www.runoob.com/linux/linux-user-manage.html
Linux user groups and file permissions