[Linux] Linux practical operation --- group management and authority management

Group management and authority management


One, group management

(1) Basic introduction of Linux group

Insert picture description here


(2) File/directory owner

Insert picture description here


① View the owner of the file

指令:ls –ahl

Case 1: Create a group police, then create a user tom, put tom in the police group, and then use tom to create a file ok.txt to see how the situation is

Insert picture description here
Insert picture description here
Insert picture description here


② The owner of the modified file

指令:chown 用户名 文件名

Case 1: Use root to create a file apple.txt, and then change its owner to zhangfei

Insert picture description here


(3) Creation of group

指令:groupadd 组名

Case 1: Create a group, ,monster

Insert picture description here


Case 2: Create a user fox and put it into the monster group

Insert picture description here


(4) The group of the file/directory

Insert picture description here


① Modify the group where the file is located

指令:chgrp 组名 文件名

Case 1: Use the root user to create a file orange.txt to see which group the file belongs to, and then modify the group where the file belongs to the fruit group.

Insert picture description here
Insert picture description here


(5) Other groups

Insert picture description here


(6) Change the user's group

Insert picture description here
Insert picture description here


Case 1: Change the user zwj from the original group to the wudang group.

Insert picture description here


Two, authority management (important)

(1) Permission introduction

Insert picture description here


(2) Detailed explanation of rwx permissions

Insert picture description here


(3) Actual case of file and directory permissions

Insert picture description here
Insert picture description here


(4) Modify permissions

Insert picture description here


① Pass +-= change authority

Insert picture description here


Case 1: Give the owner of a1.txt the read-write and execute permission, the read-execute permission to the group where it belongs, and the read-execute permission to other groups.

Insert picture description here


Case 2: Remove the execute permission to the owner of the a1.txt file and increase the group write permission

Insert picture description here


Case 3: Add read permission to all users of the a1.txt file

Insert picture description here


② Change authority by number

Insert picture description here


Case 1: Modify the permissions of the /home/a1.txt file to rwxr-xr-x, and use the digital method to achieve

Insert picture description here


(5) The owner of the modified file

Insert picture description here


Case 1: Please modify the owner of the /home/abc.txt file to tom

Insert picture description here


Case 2: Please modify the owner of all files and directories in the /home/kkk directory to tom

Insert picture description here

Insert picture description here


(6) Modify the group of the file

Insert picture description here


Case 1: Please modify the group of the /home/abc.txt file to shaolin

Insert picture description here


Case 2: Please modify the group of all files and directories in the /home/kkk directory to shaolin

Insert picture description here


(7) Best Practice-Police and Bandit Game

Insert picture description here


① Create a group

Insert picture description here


② Create user

Insert picture description here

Insert picture description here
Insert picture description here


③ Jack creates a file, he can read and write, and people in this group can read it, but no one in other groups has any permissions.

ps: The login user is jack at this time

Insert picture description here


④ Jack modifies the file so that other people in the group can read, and this group can read and write

Insert picture description here


⑤ xh go to the police to see if you can read and write

Insert picture description here

ps: It can be seen that Jack's home directory does not allow any operation by others , so you need to let go of a little permission and increase the permission to read and write to this group of people

Insert picture description here
Insert picture description here

ps: After modifying the group, you need to log in to xh again

Insert picture description here


Guess you like

Origin blog.csdn.net/weixin_45260385/article/details/114442518