public static Result setFileMode(String path,
                                   boolean ownerReadable, boolean ownerWritable, boolean ownerExecutable,
                                   boolean groupReadable, boolean groupWritable, boolean groupExecutable,
                                   boolean otherReadable, boolean otherWritable, boolean otherExecutable) {
    if (LINUX) {
      int modeValue = ((ownerReadable) ? MODE_OWNER_READABLE : 0) +
          ((ownerWritable) ? MODE_OWNER_WRITABLE : 0) +
          ((ownerExecutable) ? MODE_OWNER_EXECUTABLE : 0) +
          ((groupReadable) ? MODE_GROUP_READABLE : 0) +
          ((groupWritable) ? MODE_GROUP_WRITABLE : 0) +
          ((groupExecutable) ? MODE_GROUP_EXECUTABLE : 0) +
          ((otherReadable) ? MODE_OTHER_READABLE : 0) +
          ((otherWritable) ? MODE_OTHER_WRITABLE : 0) +
          ((otherExecutable) ? MODE_OTHER_EXECUTABLE : 0);
      String mode = String.format("%04d", modeValue);

      try {
        return runCommand(new String[]{"chmod", mode, path}, null, null, true);
      } catch (IOException | InterruptedException e) {
        // Improbable
        LOG.warn(String.format("Can not perform chmod %s %s", mode, path), e);
        return new Result(-1, "", "Cannot perform operation: " + e.getLocalizedMessage());
      }
    } else {
      LOG.debug(String.format("Not performing chmod command for file %s " +
          "because current OS is not Linux ", path));
      return new Result(-1, "", "Cannot perform operation: The current OS is not Linux");
    }
  }
Set the access modes for a file

@param path            the path to the file
@param ownerWritable   true if the owner should be able to write to this file; otherwise false
@param ownerReadable   true if the owner should be able to read this file; otherwise false
@param ownerExecutable true if the owner should be able to execute this file; otherwise false
@param groupWritable   true if the group should be able to write to this file; otherwise false
@param groupReadable   true if the group should be able to read this file; otherwise false
@param groupExecutable true if the group should be able to execute this file; otherwise false
@param otherReadable   true if other users should be able to read this file; otherwise false
@param otherWritable   true if other users should be able to write to this file; otherwise false
@param otherExecutable true if other users should be able to execute this file; otherwise false
@return the result of the operation
ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java