将历史记录追加到一个文件
将以下代码加入/etc/profile /etc/bashrc
export PROMPT_COMMAND='{ date "+[ %Y%m%d %H:%M:%S `whoami` `tty`] `history 1 | { read x cmd; echo "$cmd"; }`"; } \
>> /var/log/jhf_p_history'
chmod 766 jhf_p_history
/etc/profile每次登陆都执行一次
/etc/bashrc 用户登陆时候执行用户宿主目录下面执行.bash_profile .bash_profile调用.bashrc
bashrc调用/etc/bashrc
[root@localhost ~]# cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
[root@localhost ~]# cat .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
阅读(687) | 评论(0) | 转发(0) |