====== User profile / history ======
=== Version 1 ===
[root@linux01] /etc > cat /etc/profile.d/login.sh
trap 1 2 3
export TMOUT=1800
readonly TMOUT
if [ "\$EUID" = "0" ]; then
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
fi
umask 027
tty -s && mesg n
### SECONDARY LOGGING
FROM=$(/usr/bin/who am i 2>/dev/null | awk '{print $1}')
TO=$(/usr/bin/whoami | awk '{print $1}')
FILE="${FROM}_${TO}"
# Create dir if it doesn't exist.
if [[ ! -d /var/adm/history ]]; then
mkdir -p /var/adm/history
chmod 1777 /var/adm/history
fi
HISTFILE=/var/adm/history/sh_history.${FILE}
EXTENDED_HISTORY=ON
HISTSIZE=10000
HISTDATEFMT=%d-%m-%y.%H:%M:%S
HISTTIMEFORMAT="%F %T "
# Store Bash History Immediately.
PROMPT_COMMAND='history -a'
# Ignore Specific Commands.
HISTIGNORE="history:ls:pwd:#*:ll:"
export HISTFILE EXTENDED_HISTORY HISTSIZE HISTDATEFMT HISTTIMEFORMAT
=== Version 2 ===
[root@linux01] /etc > cat /etc/profile.d/bash_history.sh
### Change the bash_history per user
HISTSIZE=10000
HISTTIMEFORMAT="%F %T "
histdir=/var/adm/history/${USER}
mkdir -p $histdir
USER1=$(who am i | awk '{print $1}')
if [ "${USER1}" = "" ]
then
HISTFILE=$histdir/.bash_history_${USER}
else
HISTFILE=$histdir/.bash_history_${USER1}
fi
export HISTSIZE HISTTIMEFORMAT HISTFILE
Possible exclude:
Another way to exclude bad entries is to use HISTIGNORE (not implemented)
HISTIGNORE=*QUQLYS*:*ORIG_PATH*:echo\ *TEST*