Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Bash 4.1 is able to log the history to syslog. However I can't seem to make it work under FreeBSD 8.
I've tried re-compiling bash from ports with -DWITH_SYSLOG= but to no avail. Has anyone managed to get logging to work under FreeBSD? How about Linux?

share|improve this question – dmourati Oct 12 '14 at 23:31
up vote 3 down vote accepted

The better thing to do would be to turn on auditing, which will let you record every command run regardless of what shell they're using.

share|improve this answer

try this:

export HISTTIMEFORMAT="%Y-%m-%d %T "
export PROMPT_COMMAND='trap "" 1 2 15; history -a >(tee -a ~/.bash_history | while read line; do if [[ $line =~ ^#[0-9]*$ ]]; then continue; fi; logger -p -t "bash[$$]" "($USER) $line"; done); trap 1 2 15;'

this does the logging AND it prevents logging of timestamps that are used for the bash history file. The trap is needed, since bash will send the signals to the "subjob" after pressing strg+c multiple times (tested with bash 4.3). this will force the logout of the current user (e.g. logged in with sudo)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.