Linux /opt/* 文件夹和权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17557013/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:12:12  来源:igfitidea点击:

Linux /opt/* folder and permissions

linuxubuntupermissions

提问by SkyWalker

I'm using the folder /opt/to install common software that would otherwise not be available as part of the package installer of the system and that should be available to many (developer) users in Linux (using Ubuntu at the moment):

我正在使用该文件夹/opt/来安装常用软件,否则这些软件将无法作为系统软件包安装程序的一部分使用,并且应该可供 Linux 中的许多(开发人员)用户使用(目前使用 Ubuntu):

/opt/dev/eigen/3.1.3
/opt/dev/boost/1.54
/opt/git/myproject1.git
/opt/git/myproject2.git 

Putting the common software there would be the common practice right? how about permissions? I tend to chmod -R 777 /opt/devbut this is a very bad practice I guess. Suggestions on best practices in this area? probably something along the lines of adding a developers group and giving them all permissions or?

把通用软件放在那里就是通用的做法吧?权限怎么样?我倾向于,chmod -R 777 /opt/dev但我猜这是一个非常糟糕的做法。关于该领域最佳实践的建议?可能类似于添加开发人员组并授予他们所有权限或?

Note git is a special case but still all developers need access to it because pushing changes implies creating directory and files under that path with the developer credentials.

注意 git 是一个特例,但所有开发人员仍然需要访问它,因为推送更改意味着使用开发人员凭据在该路径下创建目录和文件。

采纳答案by mh00h

According to these sites:

根据这些网站:

https://bbs.archlinux.org/viewtopic.php?id=35867https://askubuntu.com/questions/169314/default-permissions-for-opt-directory

https://bbs.archlinux.org/viewtopic.php?id=35867 https://askubuntu.com/questions/169314/default-permissions-for-opt-directory

plus my experience, a correct permission to use is 755 for subdirectories in /opt. If your useris part of the root group, you could also set permissions to 775. You should be fine with this as long as there's nothing considerably sensitive in your /opt folder. If there is, then you might consider storing those in a separate subdirectory from /opt with even more limited permissions.

加上我的经验,对于 /opt 中的子目录,正确的使用权限是 755。如果您的用户是 root 组的一部分,您还可以将权限设置为 775。只要您的 /opt 文件夹中没有任何相当敏感的内容,您应该可以接受。如果有,那么您可以考虑将它们存储在来自 /opt 的单独子目录中,并具有更有限的权限。