Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script inside the WEB-INF folder that the Java runs. When I deploy the WAR, there are no execute permissions (644 instead of 755). How do I set the permissions of files inside the WAR?

share|improve this question
BTW, I create the WAR on Windows and deploy it on Ubuntu. Does that make a difference? – Kalisky May 8 '13 at 13:47
up vote 0 down vote accepted

In the webapps directory (or whatever directory you have the app deployed), just run a

chmod -R 2755 webapps

and you should be good.

share|improve this answer
But I want the WAR to be ready out of the box without having to set the permissions every time I deploy it – Kalisky May 22 '13 at 8:21
If you are manually extracting you may need to update the umask for the user doing this. If using hot deploy, you should be ok once you set the permissions on the webapps folder. – Schrute May 23 '13 at 0:46
Using hot deploy (simply copying the war to the webapps folder, and waiting for Tomcat to open it). So you mean change the permissions on the deployed folder, then when the next time Tomcat opens it, it won't change the permissions? – Kalisky May 23 '13 at 6:46
Well I mean the parent folder, the one Tomcat is polling. – Schrute May 26 '13 at 17:08
oh, now I get you... But this way I can't have other files with different permissions, they will all be with execution permissions... – Kalisky May 27 '13 at 9:29

Since the scripts belong to the application, have it set the permissions upon initialization. For a servlet in the init method something like:

String [] command = {"/bin/chmod","+x",files_to_be_changed_permissions};
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec( command );

allows the application to take care of setting permissions for its own files

share|improve this answer
If webapps are allowed to change file permissions on the underlying file system that would be a major security violation. – Michael Munsey Jan 30 '15 at 17:42
I'm pretty sure they are allowed to change permissions on their own files and usually I try it out before posting the answer, however, honestly I cannot remember if I also tested it. If you confirm by trial it does not work I can just remove it. – a1an Feb 22 '15 at 22:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.