问题
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