Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report