December 9

log all bash shell activity to separate file

log location:
echo 'local6.* /var/log/commands.log' >> /etc/rsyslog.d/bash.conf
add the following rule in the end of /etc/bashrc file:
export PROMPT_COMMAND='RETRN_VAL=$?; logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/^[ ]*[0-9]\\+[ ]*//" ) [$RETRN_VAL]"'

restart the service:

service rsyslog restart

done 🙂


Copyright 2021. All rights reserved.

Posted 9 December 2025 by admin in category "simple memo

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.