如何给文件夹写权限

how to give write permission to a folder

我有一个用户 elasticsearch,我想授予它写入文件夹的权限

/var/lib/elasticsearch/elasticsearch/nodes/0/indices/pGmjsSJHRAiMUC5paYfjag/0 

所以我做了

chmod 777 /var/lib/elasticsearch/elasticsearch

但我仍然收到错误消息?

failed to write in data directory [/var/lib/elasticsearch/elasticsearch/nodes/0/indices/pGmjsSJHRAiMUC5paYfjag/0] write permission is required

添加-R会递归改变权限

chmod -R 777 <path>