How to enable command logging in LINUX
How to enable command logging in LINUX..
Step # 1 (Add logging command)
In Ubuntu
sudo -e /etc/bash.bashrc
In LINUX
sudo -e /etc/bashrc
Insert below lines at the end of file
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" ) [$RETRN_VAL]"'
Step # 2 (Enable Logging)
Set up logging for bash as "local6" with a new file
sudo -e /etc/rsyslog.d/bash.conf
local6.* /var/log/commands.log
Step # 3 (Restart Rsyslog)
sudo service rsyslog restart
Step # 4 (Enable Log rotation)
Enable log rotation create a new file
sudo -e /etc/logrotate.d/rsyslog
Add below line under the file
/var/log/commands.log
Regards,
IT Markaz Technologies
"Now Solutions is in your hands"