Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Linux assigns user groups / permissions to files / directories (chown chgrp chmod)

Shulou Source: shulou.com Published: 2022-06-01 01:52:27 10月04日 Update

File permissions under linux

For all files under linux, there are corresponding owner permissions, group permissions, and other user permissions

corresponding read r write w executable x

Corresponding to the number 4 2 1

Use whoami to view the group to which the currently logged in user belongs. Enter whoami on the terminal to view all members of the currently logged in user group. Enter groups on the terminal to view all groups and corresponding groups. idcat /etc/groups View the group to which the user belongs (may not be the currently logged in user). Enter groups username on the terminal to modify the group to which the file belongs. chgrp

Change the group to which a file belongs

For example, here's a file a.txt, and you want to put a.txt in the root group chgrp root a.txt

Recursive modification of the group to which all files and folders belong in the directory

For example, there is now a directory test, the test directory has many files and folders, and it belongs to the root group chgrp -R ./ The test root-R parameter is used to recursively attribute all files in a directory to the root group. It is important to note that chown can not only modify the owner, but also modify the group to which it belongs. Syntax: modify the user chown username file to modify the user chown-R username directory to modify the user chown username: group name file chown-R username: group name directory to modify the corresponding owner, group, other user permissions chmod such as having a file test.txt modify the owner permissions readable writable executable, the group readable writable, other users only readable chmod 764 test.txt If you want to recursively set all files in the test directory chmod -R 764./test.txt tes

Tags: File user ownership directory permissions owner user name terminal recursion attribution login input at the same time folder user group next function parameter only need member Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Microsoft vpn Shulou Technology Xiaomi