private Pair<Integer, String> exec(String user, String cmd) throws IOException {
    LOG.info("Executing Shell command: " + cmd + " , user: " + user);

    LocalShell shell = new LocalShell(user, cmd);
    try {
      shell.execute();
    } catch (Shell.ExitCodeException e) {
      String output = shell.getOutput();
      throw new Shell.ExitCodeException(e.getExitCode(),
        "stderr: " + e.getMessage() + ", stdout: " + output);
    }
    LOG.info("Executed Shell command, exit code: {}, output n{}", shell.getExitCode(),
      shell.getOutput());

    return new Pair<>(shell.getExitCode(), shell.getOutput());
  }
Below function executes command with retries with given user. Uses LocalShell to execute a
command.
@param user user name, default none
@param cmd  Command to execute
@return A pair of Exit Code and Shell output
@throws IOException Exception while executing shell command
hbase-it/src/main/java/org/apache/hadoop/hbase/chaos/ChaosAgent.java