Quick Linux Tip #105:
Question: I need to audit what root users typed in their sessions.
Try: sudo tail -f /root/.bash_history /home/*/.bash_history 2>/dev/null
Info: Streams multiple history files concurrently with header markers for simple multi-user monitoring.
Examples:
- $
echo 'export HISTTIMEFORMAT="%F %T "' >> ~/.bashrc# Add precise timestamps to history - $
echo 'PROMPT_COMMAND="history -a"' >> ~/.bashrc# Append commands immediately per line - $
sudo auditctl -w /etc/passwd -p wa -k passwd_watch# Advanced system auditing via auditd
Note: Bash flushes history on session logout by default unless PROMPT_COMMAND="history -a" is enabled. For immutable, tamper-proof session logging, utilize auditd or centralized syslog.
Leave a Reply