仅更改其他人的权限
Change permissions for others ONLY
我在 HDFS 上有以下目录(大致遵循 POSIX 模型):
[ojoqcu@sandbox ~]$ hdfs dfs -ls /
Found 11 items
drwxrwxrwx - yarn hadoop 0 2016-03-14 14:19 /app-logs
drwxr-xr-x - hdfs hdfs 0 2016-06-27 09:40 /apps
drwxr-xr-x - yarn hadoop 0 2016-03-14 14:19 /ats
drwxr-xr-x - hdfs hdfs 0 2016-03-14 14:50 /demo
drwxr-xr-x - hdfs hdfs 0 2016-03-14 14:19 /hdp
drwxr-xr-x - mapred hdfs 0 2016-03-14 14:19 /mapred
drwxrwxrwx - mapred hadoop 0 2016-03-14 14:19 /mr-history
drwxr-xr-x - hdfs hdfs 0 2016-03-14 14:42 /ranger
drwxrwxrwx - spark hadoop 0 2016-06-27 10:02 /spark-history
drwxrwxrwx - hdfs hdfs 0 2016-06-27 09:38 /tmp
drwxr-xr-x - hdfs hdfs 0 2016-06-27 09:38 /user
很明显,'others'可以自由操作这些目录。
我希望保留所有者和群组权限 unchanged/as-is 但将 'others' 更改为自定义形式,例如
drwxr-xr-x - hdfs hdfs 0 2016-06-27 09:40 /apps
to
drwxr-x--- - hdfs hdfs 0 2016-06-27 09:40 /apps
drwxr-xr-x - hdfs hdfs 0 2016-03-14 14:19 /hdp
to
drwxr-xr-- - hdfs hdfs 0 2016-03-14 14:19 /hdp
在极端情况下,我可能只需要向其他用户提供读取权限或根本不提供访问权限,例如:
drwxrwxr-- - yarn hadoop 0 2016-03-14 14:19 /app-logs
drwxr-xr-- - hdfs hdfs 0 2016-06-27 09:40 /apps
drwxr-xr-- - yarn hadoop 0 2016-03-14 14:19 /ats
drwxr-xr-- - hdfs hdfs 0 2016-03-14 14:50 /demo
drwxr-xr-- - hdfs hdfs 0 2016-03-14 14:19 /hdp
drwxr-xr-- - mapred hdfs 0 2016-03-14 14:19 /mapred
drwxrwxr-- - mapred hadoop 0 2016-03-14 14:19 /mr-history
drwxr-xr-- - hdfs hdfs 0 2016-03-14 14:42 /ranger
drwxrwxr-- - spark hadoop 0 2016-06-27 10:02 /spark-history
drwxrwxr-- - hdfs hdfs 0 2016-06-27 09:38 /tmp
drwxr-xr-- - hdfs hdfs 0 2016-06-27 09:38 /user
如何在不指定所有者和组的位的情况下递归执行此操作?
取自此处:https://www.washington.edu/computing/unix/permissions.html
To change the mode of a file, use the chmod command. The general form is
chmod X@Y file1 file2 ...
where: X is any combination of the letters 'u' (for owner), 'g' (for
group), 'o' (for others), 'a' (for all; that is, for `ugo'); @ is
either '+' to add permissions, '-' to remove permissions, or '=' to
assign permissions absolutely; and Y is any combination of 'r', 'w',
'x'. Following are some examples:
chmod u=rx file (Give the owner rx permissions, not w)
chmod go-rwx file (Deny rwx permission for group, others)
chmod g+w file (Give write permission to the group)
chmod a+x file1 file2 (Give execute permission to everybody)
chmod g+rx,o+x file (OK to combine like this with a comma)
所以根据这个,答案将是:
chmod -R o-wx path
我在 HDFS 上有以下目录(大致遵循 POSIX 模型):
[ojoqcu@sandbox ~]$ hdfs dfs -ls /
Found 11 items
drwxrwxrwx - yarn hadoop 0 2016-03-14 14:19 /app-logs
drwxr-xr-x - hdfs hdfs 0 2016-06-27 09:40 /apps
drwxr-xr-x - yarn hadoop 0 2016-03-14 14:19 /ats
drwxr-xr-x - hdfs hdfs 0 2016-03-14 14:50 /demo
drwxr-xr-x - hdfs hdfs 0 2016-03-14 14:19 /hdp
drwxr-xr-x - mapred hdfs 0 2016-03-14 14:19 /mapred
drwxrwxrwx - mapred hadoop 0 2016-03-14 14:19 /mr-history
drwxr-xr-x - hdfs hdfs 0 2016-03-14 14:42 /ranger
drwxrwxrwx - spark hadoop 0 2016-06-27 10:02 /spark-history
drwxrwxrwx - hdfs hdfs 0 2016-06-27 09:38 /tmp
drwxr-xr-x - hdfs hdfs 0 2016-06-27 09:38 /user
很明显,'others'可以自由操作这些目录。
我希望保留所有者和群组权限 unchanged/as-is 但将 'others' 更改为自定义形式,例如
drwxr-xr-x - hdfs hdfs 0 2016-06-27 09:40 /apps
to
drwxr-x--- - hdfs hdfs 0 2016-06-27 09:40 /apps
drwxr-xr-x - hdfs hdfs 0 2016-03-14 14:19 /hdp
to
drwxr-xr-- - hdfs hdfs 0 2016-03-14 14:19 /hdp
在极端情况下,我可能只需要向其他用户提供读取权限或根本不提供访问权限,例如:
drwxrwxr-- - yarn hadoop 0 2016-03-14 14:19 /app-logs
drwxr-xr-- - hdfs hdfs 0 2016-06-27 09:40 /apps
drwxr-xr-- - yarn hadoop 0 2016-03-14 14:19 /ats
drwxr-xr-- - hdfs hdfs 0 2016-03-14 14:50 /demo
drwxr-xr-- - hdfs hdfs 0 2016-03-14 14:19 /hdp
drwxr-xr-- - mapred hdfs 0 2016-03-14 14:19 /mapred
drwxrwxr-- - mapred hadoop 0 2016-03-14 14:19 /mr-history
drwxr-xr-- - hdfs hdfs 0 2016-03-14 14:42 /ranger
drwxrwxr-- - spark hadoop 0 2016-06-27 10:02 /spark-history
drwxrwxr-- - hdfs hdfs 0 2016-06-27 09:38 /tmp
drwxr-xr-- - hdfs hdfs 0 2016-06-27 09:38 /user
如何在不指定所有者和组的位的情况下递归执行此操作?
取自此处:https://www.washington.edu/computing/unix/permissions.html
To change the mode of a file, use the chmod command. The general form is
chmod X@Y file1 file2 ...
where: X is any combination of the letters 'u' (for owner), 'g' (for group), 'o' (for others), 'a' (for all; that is, for `ugo'); @ is either '+' to add permissions, '-' to remove permissions, or '=' to assign permissions absolutely; and Y is any combination of 'r', 'w', 'x'. Following are some examples:
chmod u=rx file (Give the owner rx permissions, not w) chmod go-rwx file (Deny rwx permission for group, others) chmod g+w file (Give write permission to the group) chmod a+x file1 file2 (Give execute permission to everybody) chmod g+rx,o+x file (OK to combine like this with a comma)
所以根据这个,答案将是:
chmod -R o-wx path