更改生成的配置单元文件的权限

时间:2017-05-31 05:15:46

标签: unix hadoop hive

我使用以下查询将数据从hive导出到保存到本地文件系统的文本文件:

INSERT OVERWRITE LOCAL DIRECTORY '/local/file/system/directory'
  ROW FORMAT DELIMITED
  FIELDS TERMINATED BY ','
  NULL DEFINED AS ''
  SELECT * FROM staging_table WHERE date='2017-05-28';

查询按预期生成文件,但由于权限,我在删除文件时遇到问题。

-rw-rw-r-- 1 hive hive 12345 May 31 13:03 000000_0

是否可以更改文件的权限或所有者?

2 个答案:

答案 0 :(得分:0)

您需要Sudo或root访问权限才能执行此操作:

sudo chown -R NewOwnerName:NewGroupName /local/file/system/directory

答案 1 :(得分:0)

如果您在linus中,只需将权限更改为777即可对任何用户进行编辑

sudo chmod -R 777 directoryPath

sudo chmod 777 filePath

如果您是root用户,则不需要sudo

如果你在Windows中使用icacls

C:\>icacls "D:\test" /grant John:(OI)(CI)F /T

根据MS文档:

F = Full Control
CI = Container Inherit - This flag indicates that subordinate containers will inherit this ACE.
OI = Object Inherit - This flag indicates that subordinate files will inherit the ACE.
/T = Apply recursively to existing files and sub-folders. (OI and CI only apply to new files and sub-folders). Credit: comment by @AlexSpence