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

toiithl6  于 2021-06-01  发布在  Hadoop
关注(0)|答案(2)|浏览(229)

我正在使用以下查询将数据从配置单元导出到保存到本地文件系统的文本文件:

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

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

gtlvzcf8

gtlvzcf81#

您需要sudo或root访问才能执行此操作:

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

cgfeq70w2#

如果您在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

.

相关问题