code: public static int chmod(String filename, String perm, boolean recursive)
                              throws IOException, InterruptedException {
      StringBuffer cmdBuf = new StringBuffer();
      cmdBuf.append("chmod ");
      if (recursive) {
        cmdBuf.append("-R ");
      }
      cmdBuf.append(perm).append(" ");
      cmdBuf.append(filename);
      String[] shellCmd = {"bash", "-c" ,cmdBuf.toString()};
      ShellCommandExecutor shExec = new ShellCommandExecutor(shellCmd);
      try {
        shExec.execute();
      }catch(IOException e) {
        if(LOG.isDebugEnabled()) {
          LOG.debug("Error while changing permission : " + filename 
              +" Exception: " + StringUtils.stringifyException(e));
        }
      }
      return shExec.getExitCode();
    }
docs: Change the permissions on a file / directory, recursively, if
  needed.
  @param filename name of the file whose permissions are to change
  @param perm permission string
  @param recursive true, if permissions should be changed recursively
  @return the exit code from the command.
  @throws IOException
  @throws InterruptedException