Blog

Feb
25

Shell History

AIX (in common with other Unix versions) logs a lot of information including a list of all the commands executed in each shell. Unfortunately you first have to correctly configure it. The most important files are controlled by the following variables:

HISTSIZE = Maximum size of the history file
HISTFILE = Location/filename used to record commands executed.
Smit commands are also recorded
LOG = Smit menus accessed (default = $HOME/smit.log)
SCRIPT = Commands/scripts run by smit (default = $HOME/smit.script)

Creating separate use history files

This is a sample “.profile” to create separate histories for each user that switches user to root:

[[ ! -d $HOME/histories ]] && mkdir $HOME/histories
alias free=”/home/root/scripts/free”
alias prompt=”. /home/root/scripts/prompt”
# Set Putty Window Title
H=$(hostname) ; N=$(host $H | awk ‘{print $NF}’)
echo “33]0;$H – $N07”
#———————————————-

 

[[ ! -d $HOME/histories ]] && mkdir $HOME/histories
HISTSIZE=65536
HISTFILE=$HOME/histories/.”$(who am i | nawk ‘{print $1}’)_history”
LOG=$HOME/histories/smit.log.$(logname)
SCRIPT=$HOME/histories/smit.script.$(logname)
alias smit=’smit -l $LOG -s $SCRIPT’
alias smitty=’smit -l $LOG -s $SCRIPT’
# add timestamps to history
export HISTTIMEFORMAT=”%Y-%m-%d %H:%M:%S %z”

 

Extended History for each user

Separate history files for each day by changing “/etc/profile”:
# Change the location and size of the users history
FILEDATE=`date +%m%d%Y` HISTFILE=/var/adm/shell/history/$LOGIN.sh.history.$ FILEDATE HISTSIZE=65536
export HISTFILE HISTSIZE
 

Time stamp your entries in the shell history by changing “/etc/environment”

# Added for extended shell history EXTENDED_HISTORY=ON
cat .kshrc
TTY=$(tty|cut -f3-4 -d/)
export HISTFILE=$HOME/.sh_hist$(echo ${TTY} | tr -d ‘/’)
Time stamp your entries in the shell history by changing “/etc/environment”: # Added for extended shell history EXTENDED_HISTORY=ON
Use: history -t to get a timestamp with every command that is executed.