Thursday, October 4, 2012

WTF are you doing?

Tracking su usage
  
In a multi-administrator environment, it may be required to keep track of who did what because you want to have someone to blame ;-) . To accomplish that we must add a little code under the /etc/profile file that will result in the creation of a new history file which name is associated with the login of the user and saves all his actions.

HST=$(hostname)
USR=$(who -um | awk '{print $1}')
NAME=$(whoami)
if [[ ! -d $HOME/.sh_hist ]]
then
        mkdir $HOME/.sh_hist
fi
HISTFILE=${HOME}/.sh_hist/${HST}_${USR}_as_${NAME}_$(date +%m%d%y_%H%M%S).hist
export HISTFILE

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.