目录权限“ S”是什么意思?(不是小写,而是大写)


39

我下载了Eclipse,将其解压缩,做了其他一些事情,突然间我注意到了这种有趣的行为:

^_^ ~/Downloads > sudo chmod 0000 eclipse/

^_^ ~/Downloads > stat eclipse/
  File: 'eclipse/'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 801h/2049d  Inode: 529725      Links: 9
Access: (2000/d-----S---)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-11-22 19:54:57.752017352 +1100
Modify: 2012-09-20 18:16:26.000000000 +1000
Change: 2012-11-22 20:07:49.354016510 +1100
 Birth: -

^_^ ~/Downloads > sudo chmod 0755 eclipse/

^_^ ~/Downloads > stat eclipse/
  File: 'eclipse/'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 801h/2049d  Inode: 529725      Links: 9
Access: (2755/drwxr-sr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-11-22 19:54:57.752017352 +1100
Modify: 2012-09-20 18:16:26.000000000 +1000
Change: 2012-11-22 20:08:19.042016478 +1100
 Birth: -

“ S”权限对目录意味着什么?为什么不让我摆脱它呢?

谢谢。

Answers:


65

'S'=目录的setgid位已设置,但执行位未设置。

's'=设置目录的setgid位,并设置执行位。

SetGID =当另一个用户在这样的setgid目录下创建文件或目录时,新文件或目录的组将被设置为目录所有者的组,而不是创建它的用户组。

要删除setGID位:

chmod g-s eclipse/

来自man chmod:

您可以使用u + s和gs等符号模式设置或清除位,也可以使用数字模式设置(但不清除)位。

链接到一个类似的问题:https : //unix.stackexchange.com/questions/27250/uppercase-s-in-permissions-of-a-folder


3
如果s在目录的用户位中(例如)drwsrwxr-x 2 someuser somegroup 4096 May 18 11:39呢?它似乎没有为目录中创建的文件设置所有者...
SeldomNeedy
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.