code: @Override
    public void setPermission(Path p, FsPermission permission
        ) throws IOException {
      FsAction user = permission.getUserAction();
      FsAction group = permission.getGroupAction();
      FsAction other = permission.getOtherAction();
      
      File f = pathToFile(p);
      
      // Fork chmod if group and other permissions are different...
      if (group != other) {
        execSetPermission(f, permission);
        return;
      }
      
      boolean rv = true;
      
      // read perms
      rv = f.setReadable(group.implies(FsAction.READ), false);
      checkReturnValue(rv, p, permission);
      if (group.implies(FsAction.READ) != user.implies(FsAction.READ)) {
        f.setReadable(user.implies(FsAction.READ), true);
        checkReturnValue(rv, p, permission);
      }
  
      // write perms
      rv = f.setWritable(group.implies(FsAction.WRITE), false);
      checkReturnValue(rv, p, permission);
      if (group.implies(FsAction.WRITE) != user.implies(FsAction.WRITE)) {
        f.setWritable(user.implies(FsAction.WRITE), true);
        checkReturnValue(rv, p, permission);
      }
  
      // exec perms
      rv = f.setExecutable(group.implies(FsAction.EXECUTE), false);
      checkReturnValue(rv, p, permission);
      if (group.implies(FsAction.EXECUTE) != user.implies(FsAction.EXECUTE)) {
        f.setExecutable(user.implies(FsAction.EXECUTE), true);
        checkReturnValue(rv, p, permission);
      }
    }
docs: Use the command chmod to set permission.