This script is found on the internet, a little bit of modification, can be implemented under Linux all users, whether remote or local landing, all operations on this machine will be recorded, and generate a "user/ip/time" files stored in the specified location, Convenient for the administrator to see what different users are doing on the server!
At present, this code only implements the record user's Operation command, but like VI Edit will only record VI this command, but in the document modified content cannot record ... Have time to study again!
Append the following code to the/etc/profile file
ps1= "' WhoAmI ' @ ' hostname ':" ' [$PWD] '
history
user_ip= ' who-u am I 2>/dev/null| awk ' {print $NF} ' |sed-e ' s/[()]//g '
if [' $USER _ip ' = ' "]
then
user_ip= ' hostname '
fi
if [! -d/tmp/history]
then
mkdir/tmp/history
chmod 777/tmp/history
fi
if [!-d/tmp/history/${ LOGNAME}]
then
mkdir/tmp/history/${logname}
chmod 300/tmp/history/${logname}
fi
export histsize=4096
dt= ' date + '%y%m%d_%h%m%s ' '
export histfile= '/tmp/history/${logname}/${user_ip} history.$ DT "
chmod 600/tmp/history/${logname}/*history* 2>/dev/null
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/