Os : debian8. There are two users :normal and root.
touch /var/log/all.log
chmod 777 /var/log/all.log
For normal.
vim /home/normal/.bashrc
export HISTTIMEFORMAT="%Y-%m-%d:%H-%M-%S: `whoami` : "
export PROMPT_COMMAND='history > /var/log/all.log'
source /home/normal/.bashrc
All the history command for normal(the user) will write into /var/log/all.log.
For root the same way.
vim /root/.bashrc
export HISTTIMEFORMAT="%Y-%m-%d:%H-%M-%S: `whoami` : "
export PROMPT_COMMAND='history > /var/log/all.log'
source /root/.bashrc
All the history command for root(the user) will write into /var/log/all.log.
Now i want to combine the two configuration file into one file.
Delete the two lines in both /home/normal/.bashrc and /root/.bashrc .
1. Combine them into /etc/profile
.
vim /etc/profile
export HISTTIMEFORMAT="%Y-%m-%d:%H-%M-%S: `whoami` : "
export PROMPT_COMMAND='history > /var/log/all.log'
source /etc/profile
All the history info for normal can't be written into /var/log/all.log.
All the history info for root can be written into /var/log/all.log.
2. Combine them into /etc/bash.bashrc .
vim /etc/bash.bashrc
export HISTTIMEFORMAT="%Y-%m-%d:%H-%M-%S: `whoami` : "
export PROMPT_COMMAND='history > /var/log/all.log'
source /etc/bash.bashrc
All the history info for normal can't be written into /var/log/all.log.
All the history info for root can be written into /var/log/all.log.
Why can't combine the two configuration file --/home/normal/.bashrc and /root/.bashrc-- into just one file?