Linux study notes _4: group management and authority management

Group management and authority management

Group management: In the Linux system, each user must belong to a group and cannot be independent of the group. All files have the concept of owner, group, and other groups

  • File/directory owner : the creator of the file, when the user creates the file, the default group of the file is the group of the current user
    • ls -ahlTo view the owner of the file
    • chown userName fileName, Modify the file owner. The group and user of the file do not necessarily have an association between the user and the group, because the user of the file can be modified.
    • chgrp [-R] groupName fileName, Modify the group of the file. The group and user of the file do not necessarily have an association between the user and the group it belongs to, because the group to which the file belongs can be modified. Add -R, recursively modify the owner and group of all files in the directory.
    • chwom [-R] userName:groupName fileNameOrdictionaryName, Modify the file owner and group. If it is a directory, add -R, recursively modify the owner and group of all files in the directory.
  • Other groups : In addition to the owner and the group where you belong, the other user groups of the system are the other groups of the file.
  • Change the user's group : Use the rootuser's management authority to change the user's group.
    • usermod -g groupName userName, Change the user’s group

Permission management: mainly for the permissions of directories and files

Directory permission description:

Insert picture description here
The above screenshot is the first:

file type Paraphrase
- Normal file
d table of Contents
l Soft connection
c Character devices (mouse, keyboard, etc.)
b Block files (disks, etc.)

Numbers 2-4 of the above screenshot are the file owner's authority for the file; number 5-7 are the file's authority for the user in the group where the file is located; number 8-10, the file's other group users' authority for this file;

file type Interpretation (acts on the file) Interpretation (acts in the catalog) Digital representation
r Read, view Read, view 4
w Modification (not necessarily including deletion, the premise of deleting a file is to have wpermission to the directory where the file is located ) Modify, create, delete, rename 2
x carried out enter 1
- No permission No permission 0

The rest of the above screenshot:

  • The blue box represents the file:, 1is the number of hard links to the file. n, The directory contains the number of subdirectories
  • (Light) The pink underline indicates: the user and the group the file belongs to
  • The light purple box is: file size (bytes); if it is a folder, it is a fixed value of 4096
  • The pink box is: Last modified date
  • The red box is: file name
Modify permissions:chmod
Alphabet Paraphrase
u owner
g All groups
o other people
a Everyone u( g, , osum)
  • One +way: -, , =change permissions
    • chmod u=rwx,g=rx,o=x [dictionaryNameOrfileName], Add read, write, and execute permissions for a certain directory (file) owner, add read and execute permissions for all groups, and add execute permissions for others.
    • chmod o+w [dictionaryNameOrfileName], To add write permission for others in a directory (file).
    • chmod a-x [dictionaryNameOrfileName], Remove the execution permission for the owner of a certain directory (file).
  • Second way: 4, 2, 1change permissions, i.e., the above-described example a digital equivalent of the following alternative available
    • chmod 751

Guess you like

Origin blog.csdn.net/Nerver_77/article/details/106820809