Linux group management and permission management notes

1. Basic instructions

Add group

Basic grammar

groupadd group name

Function description
Add group

Practical demonstration
Insert picture description here
Add members to the group
Insert picture description here
Insert picture description here

Modify file owner

Basic grammar

chown user name file name
chown user name: group name file name

Function description
Change file owner
Change user owner and all groups

Actual demonstration
Insert picture description here
Insert picture description here

Modify the file group

Basic grammar

chgrp group name file name

Function description
The actual demonstration of the group where the file is modified

Insert picture description here

Modify permissions

Basic grammar

chmod u=rwx,g=rx,o=x file directory name
chmod o+w file directory name
chmod ax file directory name
chmod permission digital file directory name

Function description
Modify the group where the file is located.
Note:
Method 1: u: Owner g: All groups o: Others a: Everyone (the sum of u, g, and o)
* Method 2: Rule: r=4 w=2 x =1,rwx=4+2+1=7 The authority is expressed by a number, through + add authority through-delete authority *
For example: chmod 751 file directory name = chmod u=rwx,g=rx,o=x file directory name

Actual demonstration

2. Detailed explanation of file display content

Insert picture description here
probably
-rw-r--r--. 1 stu01 student 2554 12月 3 05:42 a.txt

Permission display content:
-rw-r--r--

1) The 0th bit determines the file type (d (directory),-(normal file), l (hard link), c (character device example: mouse and keyboard), b (block file, hard disk))
2) No. 1-3 Bit confirms that the owner (the owner of the file) has permissions for the file.
3) The 4th to 6th digits determine that the group (of the same user group) has the permission of the file
4) The 7th-9th digits determine that other users have the permission of the file

File display:
1 stu01 student 2554 12月 3 05:42 a.txt
1) If the first part is a file, it means the number of hard links. If it is a directory, it means the number of subdirectories.
2) The second part means all users.
3) The third part means all group names.
4) The fourth part means 4096 if the directory is 4096. , If the file means the file size
5) The fifth part 12月 3 05:42means the last modification time
6) The sixth part means the file name

Three, detailed explanation of rwx permissions

1. rwx acts on the file

1) [r] stands for readable (read): can be read, view
2) [w] stands for writable (write): it can be modified, but it does not mean that the file can be deleted. The prerequisite for deleting a file is the file The directory where you have write permission can delete the file.
3)[x] stands for execute: can be executed

2, rwx acts on the directory

1)[r] stands for readable (read): can be read, ls view the contents of the directory
2) [w] stands for writable (write): can be modified, create + delete + rename the directory in the directory
3) [x] stands Executable (execute): you can enter the directory

Guess you like

Origin blog.csdn.net/magicproblem/article/details/111039476