1

We have multiple guys logged in as root at the same time. How can I view their command history during login or after terminating their session.

Regards,

1 Answer 1

2

I merge them in the configuration file using:

shopt -s histappend

This is usually enough for me to see session info after the logout (by examining the history file). I also timestamp with:

export HISTTIMEFORMAT='%m-%d-%Y %H:%M:%S  '

Some people also set the history to reload and popular after each command. I don't, but this is the popular recipe for that:

# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

All of this ends up in a /etc/bashrc or a snippet in /etc/profile.d/

2
  • "All of this ends up in a /etc/bashrc or a snippet in /etc/profile.d/" U mean I should put "shopt -s histappened" in bashrc as well?
    – khmasood
    Feb 9, 2016 at 6:08
  • if you want to, yes.
    – ewwhite
    Feb 9, 2016 at 6:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .