AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 38638
Accepted
Jake McGraw
Jake McGraw
Asked: 2009-07-10 13:48:46 +0800 CST2009-07-10 13:48:46 +0800 CST 2009-07-10 13:48:46 +0800 CST

控制 UNIX 目录内容用户组所有权

  • 772

我想创建一个目录,任何用户都可以在其中创建文件,但是在创建文件后,该文件的用户和组所有权被设置为预定义的值。我知道有一种方法可以使用 GUID、UID 来做到这一点,但我总是忘记 chmod 组合。

unix filesystems permissions
  • 3 3 个回答
  • 516 Views

3 个回答

  • Voted
  1. Best Answer
    MikeyB
    2009-07-10T13:57:19+08:002009-07-10T13:57:19+08:00

    您可以为 GID 执行此操作:

    chgrp users /path/to/directory
    chmod g+s /path/to/directory
    

    您不能为 UID 执行此操作。直接地。

    您可以编写一个经常运行命令的 cron 条目:

    chown -R user:group /path/to/directory
    chmod -R 644 /path/to/directory
    

    (确保挂载 /path/to/directory 在 nosuid 上的文件系统,以避免有人将 setuid shell 放入目录的竞争条件)

    • 6
  2. moshen
    2009-07-10T13:55:59+08:002009-07-10T13:55:59+08:00

    chown user:group file?

    • 0
  3. therek
    2009-07-10T13:58:27+08:002009-07-10T13:58:27+08:00

    我很抱歉这么说,但请使用 RTFM。来自chmod(1):

           Modes may be absolute or symbolic.  An absolute mode is an octal number
           constructed from the sum of one or more of the following values:
    
           4000    (the setuid bit).  Executable files with this bit set will
                   run with effective uid set to the uid of the file owner.
                   Directories with this bit set will force all files and sub-
                   directories created in them to be owned by the directory
                   owner and not by the uid of the creating process, if the
                   underlying file system supports this feature: see chmod(2)
                   and the suiddir option to mount(8).
           2000    (the setgid bit).  Executable files with this bit set will
                   run with effective gid set to the gid of the file owner.
           1000    (the sticky bit).  See chmod(2) and sticky(8).
           0400    Allow read by owner.
           0200    Allow write by owner.
           0100    For files, allow execution by owner.  For directories,
                   allow the owner to search in the directory.
           0040    Allow read by group members.
           0020    Allow write by group members.
           0010    For files, allow execution by group members.  For directo-
                   ries, allow group members to search in the directory.
           0004    Allow read by others.
           0002    Allow write by others.
           0001    For files, allow execution by others.  For directories
                   allow others to search in the directory.
    
    • -2

相关问题

  • 在命令行上从 csv 文件中过滤带有空格字符的字段

  • 如何将 VAR 从子 shell 导出到父 shell?

  • 查找文件大小(以 MB 为单位)

  • 如何及时了解有关 UNIX 软件补丁和升级的最新信息?

  • 您为服务器使用和推荐哪种 UNIX 文件系统?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve