在/etc/profile里面加上这些就够了
改个权限即可chmod 777 /usr/local/crazy/records
tips:普通用户若有sudo su - 切换root权限,切换前记录在自己名称目录下,切换后记录在root目录下, 但记录的都是登陆账户的操作记录
切换前dump,日志记录
[root@localhost /usr/local/crazy/records/chenliang ]# tail -f bash_history
2016-06-16 17:36:29 ##### chenliangpts/3 (124.192.156.166) #### mysqldump -uroot -pESBecs00 kingshard>kingshard.sql
sudo切换后dump,日志记录
- vim /etc/profile
if [ ! -d /usr/local/crazy/records/${LOGNAME} ]
then
mkdir -p /usr/local/crazy/records/${LOGNAME}
chmod 300 /usr/local/crazy/records/${LOGNAME}
fi
export HISTORY_FILE="/usr/local/crazy/records/${LOGNAME}/bash_history"
export PROMPT_COMMAND='{ date "+%Y-%m-%d %T ##### $(who am i |awk "{print \$1\" \"\$2\" \"\$5}") #### $(history 1 | { read x cmd; echo "$cmd"; })"; } >>$HISTORY_FILE'
改个权限即可chmod 777 /usr/local/crazy/records
tips:普通用户若有sudo su - 切换root权限,切换前记录在自己名称目录下,切换后记录在root目录下, 但记录的都是登陆账户的操作记录
切换前dump,日志记录
[root@localhost /usr/local/crazy/records/chenliang ]# tail -f bash_history
2016-06-16 17:36:29 ##### chenliangpts/3 (124.192.156.166) #### mysqldump -uroot -pESBecs00 kingshard>kingshard.sql
sudo切换后dump,日志记录
- [root@localhost /usr/local/crazy/records/root ]# tail -f bash_history
2016-06-16 17:36:12 ##### chenliang pts/3 (124.192.156.166) #### mysqldump -uroot -pESBecs00 kingshard>kingshard.sql3
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29096438/viewspace-2016094/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29096438/viewspace-2016094/