[英]GCP linux startup script to grant all users permission to directory and files
I am attempting to run the following startup script on a GCP vm instance:我正在尝试在 GCP vm 实例上运行以下启动脚本:
mkdir /home/example_user/
mkdir /home/example_user/test
echo "hello world" >> /home/example_user/test/.env
chmod 777 /home/example_user/
When I login to the created vm, and the startup script has finished running.当我登录到创建的虚拟机时,启动脚本已经完成运行。 I try to confirm the permissions were set properly via:
我尝试通过以下方式确认权限设置正确:
nano /home/example_user/test/.env
Permission denied
没有权限
I would like that an user that logins via ssh does not need to prefix sudo
with there commands, or enter root via sudo su
prior to我希望通过 ssh 登录的用户不需要在
sudo
前面加上命令,或者在之前通过sudo su
输入 root
nano /home/example_user/test/.env
I have tried我努力了
chmod 777 /home/example_user/
chmod a+x /home/example_user/
chmod -R a+x /home/example_user/
How do I properly give access permissions to all users on the vm instance within the startup script?如何在启动脚本中正确授予 vm 实例上的所有用户访问权限?
Change permissions of the folder and its children recursively:递归更改文件夹及其子文件夹的权限:
chmod -R 777 /home/example_user/
However, there are better strategies.但是,有更好的策略。 Linux implements the concept of groups.
Linux 实现了组的概念。 Add the users that should have access to a shared folder to the same group.
将应该有权访问共享文件夹的用户添加到同一组。 Then set the folder's group and the permissions for that group.
然后设置文件夹的组和该组的权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.