我什么时候可以或应该在文件或目录上使用 chmod g+s ? [英] When could or should I use chmod g+s on a file or directory?

查看:35
本文介绍了我什么时候可以或应该在文件或目录上使用 chmod g+s ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近在部署到新的 (Solaris 9) 环境时,其中一个步骤是将一组文件和目录复制到它们的新位置,然后应用组 UID 位(使用chmod -R g+s") 到目录树中的所有文件,为所有内容提供 -rwxr-s--- 模式.结果是,除非单独打开并重新保存我们的 shell 脚本,否则它们都不会执行.我应该补充一点,在复制文件之前,我们已经在目标父文件夹上设置了 g+s;这已将所有新目录的初始模式设置为 drwxr-s--- 但文件的模式为 -rwxr-x---

In deploying to a new (Solaris 9) environment recently, one of the steps was to copy a set of files and directories to their new location and then to apply the group UID bit (using "chmod -R g+s") to all files in the directory tree giving a mode of -rwxr-s--- to everything. The result was that none of our shell scripts would execute unless they were individually opened and re-saved. I should add that we had earlier set g+s on the target parent folder prior to copying files; this had set the initial mode on all the new directories to drwxr-s--- but the files had a mode of -rwxr-x---

最终发现是哪个步骤导致了问题后,我们能够删除该步骤并继续进行.

Having eventually discovered which step caused the problem, we were able to cut out that step and proceed.

然而,我想了解s"位在应用于目录和文件时的含义,希望这能首先解释我们为什么会遇到问题.

I would like, however, to understand what the "s" bit means when applied to directories and files, in the hope that this will explain why we had the problem in the first place.

推荐答案

设置目录 g+s 使在该目录中创建的所有新文件的组都设置为目录的组.

Setting directories g+s makes all new files created in said directory have their group set to the directory's group.

如果您设置了 umask,那么这对于协作目的实际上非常方便,以便默认情况下文件具有组写入.

This can actually be really handy for collaborative purposes if you have the umask set so that files have group write by default.

注意:这是它在 Linux 中的工作方式,它在 Solaris 中的工作方式可能完全不同.

Note: This is the way it works in Linux, it could work completely differently in Solaris.

这篇关于我什么时候可以或应该在文件或目录上使用 chmod g+s ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆