简体   繁体   English

GCP linux 启动脚本授予所有用户对目录和文件的权限

[英]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.然后设置文件夹的组和该组的权限。

How to Manage Users with Groups in Linux 如何在 Linux 中使用组管理用户

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GCP VM启动脚本sed:无法读取:没有这样的文件或目录 - GCP VM startup script sed: can't read : No such file or directory 调用 GCP Cloud Scheduler 创建作业所需的所有权限 - What all the PERMISSION required to call GCP Cloud Scheduler Create Job 如何在 GCP 中列出包含给定权限的所有 IAM 角色 - How to list all the IAM roles that include a given permission in GCP GCloud Storage:如何授予在控制台中查看存储桶但只能查看单个存储桶中的文件的权限? - GCloud Storage: How to grant permission to see buckets in console but only see files in single bucket? 限制所有用户在 GCP/AWS/Azure 中将公共 IP 附加到 EC2/VM 的权限 - Restricting the permissions for all users of attaching a public IP to EC2/VM in GCP/AWS/Azure GCP 权限块 - GCP Permission Block 当应用程序脚本文件或容器文件从云端硬盘中删除时,Google 应用程序脚本 GCP 项目不会从控制台中删除 - Google apps script GCP projects are not deleted from console when apps script files or container files are trashed from Drive 使用 python 从 GCP 存储桶中递归读取所有子文件夹中的 csv 个文件 - Read csv files recursively in all sub folders from a GCP bucket using python macOS 12.4 - 启动服务无法访问用户目录中的文件 - macOS 12.4 - launchd service unable to access files in users directory 如何授予对 gcp 云 sql 的连接只读访问权限 - How to grant connectivity read only access to gcp cloud sql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM