2

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.

2
  • Look into gaining OS permissions, I think it might help Commented Dec 7, 2011 at 4:23
  • If you dont mind, can you please let me know more details? I am totally new in linux server. Commented Dec 7, 2011 at 4:24

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

5 Comments

All permission are as follows : drwxrwx--x 9 root root 4096 Dec 7 09:47 webroot , But how I can run java code using root user?
I wouldn't recommend it. You may be able to use sudo. Otherwise, maybe this is an initial setup that you need to complete outside of Java.
Hey I used Process p1 = Runtime.getRuntime().exec("sudo chmod 773 /webroot"); but it cant change directory permission and captured error stream is as follows: sudo: sorry, you must have a tty to run sudo
@Pritom its strange what you're trying to do - I'd suggest sticking with ziesemer's suggestions.. but if you really want to hammer away you'll need to edit the sudoers file and include a !requiretty for your user
I am using tomcat6 and username is 'tomcat', now what could I add to my sudoers file???

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.