Set the default shell that users use to bash.
http://stanlo-solaris.blogspot.com/search/label/useradd
Next add this to your /etc/profile file
HISTTIMEFORMAT='%F %T '
export HISTTIMEFORMAT
Then create a .bash_logout script for the user.
#----------------------------------------------------------
# Record bash history
#
# Written : Stan Lovisa
# Date : 29-01-2010
# Mod :
#
#----------------------------------------------------------
TSATMP=$(date +%Y%M%d-%T)
if [ ! -d ~/.hist ]
then
mkdir ~/.hist
fi
who am i > ~/.hist/$$.bash_history.${TSATMP}
history >> ~/.hist/$$.bash_history.${TSATMP}
banner bye
Each time the user logs out a history file is created in $HOME/.hist
Sample output:
480 2011-06-21 14:44:24 lr
481 2011-06-21 14:44:29 l tmp/
482 2011-06-21 14:44:35 l dat
483 2011-06-21 14:44:42 cd dat
484 2011-06-21 14:44:44 c
485 2011-06-21 14:44:44 l
486 2011-06-21 14:44:50 l 2011/
487 2011-06-21 14:44:56 ls 2011/
488 2011-06-21 14:45:07 cd ../..
489 2011-06-21 14:45:09 l tmp/
490 2011-06-21 14:45:17 lf tmp
491 2011-06-21 14:45:25 lf /tmp
492 2011-06-21 14:46:05 digs -x 172.19.1.50
493 2011-06-21 18:06:09 . s.bashrc
494 2011-06-21 18:06:20 ssh stl@suse-dell
495 2011-06-22 08:04:00 . s.bashrc
496 2011-06-22 08:04:00 c
497 2011-06-22 08:04:03 history
498 2011-06-22 08:04:13 cd /etc/
499 2011-06-22 08:04:15 vi profile
500 2011-06-22 08:07:38 cd
501 2011-06-22 08:07:41 vi .profile
502 2011-06-22 08:07:53 l
503 2011-06-22 08:07:56 lf
504 2011-06-22 08:08:10 vi .bash_logout
505 2011-06-22 08:11:41 history
No comments:
Post a Comment