make linux directory writable using bash command through java code

ぃ、小莉子 提交于 2019-12-11 03:38:24

问题


I have a directory /webroot in my linux server. Which permission set is 771, that means 1 for others. But I want to make it 773 through java code which like is :

Process p1 = Runtime.getRuntime().exec("chmod 773 /webroot");

But it can not change the permission.

I also capture the error stream which is like as :

chmod: changing permissions of `/webroot/': Operation not permitted 

I saw a nearly related post yesterday, but i could not find the appropriate answer. At this time, what can I do now?

Please any help.


回答1:


I think the error is pretty clear here. What user is your Java code running as? It most likely doesn't have permissions to run chmod on that directory.

Do a ls -l on that directory to see who it is owned by. Make sure that your Java code is running at that same user.



来源:https://stackoverflow.com/questions/8410360/make-linux-directory-writable-using-bash-command-through-java-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!