让linux目录写入通过Java code。使用bash命令 [英] make linux directory writable using bash command through java code
问题描述
我在Linux服务器的目录/根目录。这权限设置为771,这意味着1为别人着想。但我想让它773通过Java code这喜欢的是:
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?
请任何帮助。
推荐答案
我认为错误的是pretty清楚这里。什么是用户的Java code运行的?它很可能不会对这个目录的权限运行搭配chmod
。
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.
做一个的ls -l </ code>上的目录,看看谁是归。请确保您的Java code在同一用户运行。
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.
这篇关于让linux目录写入通过Java code。使用bash命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!