code: private static UnixUserGroupInformation getUgi(String userName)
        throws IOException {
      if (userName == null || !USERNAME_PATTERN.matcher(userName).matches())
        throw new IOException("Invalid username=" + userName);
      String[] cmd = new String[] { "bash", "-c", "id -Gn '" + userName + "'"};
      String[] groups = Shell.execCommand(cmd).split("\\s+");
      return new UnixUserGroupInformation(userName, groups);
    }
docs: Get the ugi for a user by running shell command "id -Gn"
  
  @param userName name of the user
  @return ugi of the user
  @throws IOException if encounter any error while running the command