如何获得"drwx --- r-x +"使用CHMOD的文件夹权限? -Bash脚本 [英] How to get "drwx---r-x+" folder permission using CHMOD? - Bash script

查看:459
本文介绍了如何获得"drwx --- r-x +"使用CHMOD的文件夹权限? -Bash脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网络上移动某些文件时遇到问题,这似乎是由文件权限引起的.

I am facing a problem when moving some files across my network and seems to be caused by file permissions.

当前,我有具有此权限drwxrwxrwx的文件夹. 我需要运行一个bash脚本,将权限更改为drwx --- r-x +

Currently I have folders with this permissions drwxrwxrwx. I need to run a bash script that change permissions to drwx---r-x+

ACL必须存在.

我不太了解如何使用CHMOD命令获得相同的权限.到目前为止,我已经尝试过:

I don't quite understand how can I achieve the same permissions using CHMOD commands. I have tried so far:

chmod -R ugo = rx文件"

chmod -R ugo=rx "file"

但这似乎更改为dr-xr-xr-x,这还不够...

But this seems to change to dr-xr-xr-x, which is not enough...

问题是,我应该运行哪个命令来实现drwx --- r-x + ??

So the question is, which command should I run to achieve drwx---r-x+ ??

先谢谢了.

PS.此命令必须在MACOSX Maveriks中运行,因此"setfacl"命令将无济于事.

PS. This command must run in MACOSX Maveriks so "setfacl" command will not help.

推荐答案

权限drwx---r-x+分解如下:

  • d是一个目录.
  • rwx表示 u ser可读,可写且可访问.这三个位可以用八进制数7表示.
  • ---表示未为分配给该目录的 g 组设置上述三个位.没有设置任何位,因此八进制数为0.
  • r-x表示与前两个类别(即其他所有人或" o ther")不匹配的用户可以读取和访问目录的内容,但无法写入.此处的位在"ones"列和"fours"列中,因此代表此权限的八进制数字为5.
  • +表示存在与该目录关联的扩展安全信息",未在标准ls长格式"中显示.例如访问控制列表.
  • d is a directory, of course.
  • rwx means it's readable, writeable and accessible by the user. These three bits can be represented by the octal number 7.
  • --- means that the three aforementioned bits are NOT set for the group assigned to the directory. No bits are set, so the octal number is 0.
  • r-x means that users who aren't matched by the first two categories -- that is, everybody else, or "other" -- can read and access content of the directory, but can't write to it. The bits here are in the ones column and the fours column, so the octal number that represents this permission is 5.
  • + indicates that there is "extended security information" associated with this directory which isn't shown in standard ls "long format". An access control list, for example.

要设置此目录的基本权限,可以使用八进制简写:

To set the basic permissions of this directory, you can use either the octal short-hand:

$ chmod 705 directoryname

或者您可以使用符号"表示形式:

or you can use the "symbolic" representation:

$ chmod u+rwx,g-rwx,o+rx-w directoryname

很明显,速记是...较短.

Obviously, the shorthand is ... shorter.

对于+表示的扩展安全性信息,您需要找出设置内容以进行复制. ls命令具有-e选项,以显示扩展的安全设置.

For the extended security information denoted by the +, you'd need to find out what is set up in order to replicate it. The ls command has a -e option to have it show extended security settings.

要从命令行实际设置您的ACL,可以使用chmod'a =a-a+a选项.有关此问题的文档,可从man chmod的OSX中获得.在该手册页中:

To actually set your ACLs from the command line, you'd use chmod'a =a, -a and +a options. Documentation about this is available in OSX from man chmod. From that man page:

         Examples
          # ls -le
          -rw-r--r--+ 1 juser  wheel  0 Apr 28 14:06 file1
            owner: juser
            1: admin allow delete
          # chmod =a# 1 "admin allow write,chown"
          # ls -le
          -rw-r--r--+ 1 juser  wheel  0 Apr 28 14:06 file1
            owner: juser
            1: admin allow write,chown

这篇关于如何获得"drwx --- r-x +"使用CHMOD的文件夹权限? -Bash脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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