创建用户和组:使用命令useradd创建用户,如sudo useradd example_user;使用命令groupadd创建组,如sudo groupadd example_group;将用户添加到组中:使用命令usermod将用户添加到组中,如sudo usermod -a -G example_group example_user;更改文件或目录的所有者和所属组:使用命令chown更改文件或目录的所有者,如sudo chown example_user:example_group file.txt;使用命令chgrp更改文件或目录的所属组,如sudo chgrp example_group file.txt;设置文件或目录的权限:使用命令chmod设置文件或目录的权限,如sudo chmod 755 file.txt;使用命令chown和chgrp结合设置权限,如sudo chown example_user:example_group file.txt && sudo chmod 755 file.txt;查看当前用户和组的权限:使用命令id查看当前用户所属的组,如id;使用命令groups查看当前用户的组,如groups;
请注意,配置用户和组的权限需要使用root权限或sudo权限。




