Last active
May 25, 2026 00:38
-
-
Save AfroThundr3007730/07db5d690dfabd685ca1fe0f308908c7 to your computer and use it in GitHub Desktop.
Basic shell history logging to syslog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # /etc/profile.d/zzz-history-logging.sh | |
| _logger_hook() { | |
| logger -p user.notice -t "$0" --id=$$ -- \ | |
| "${USER}${SUDO_USER:+ (sudo:$SUDO_USER)}" :: \ | |
| "${HOSTNAME%%.*}${SSH_CLIENT:+ (ssh:${SSH_CLIENT%% *})}" :: \ | |
| "${PWD}" :: "${BASH_COMMAND:-$*}" | |
| } | |
| declare -rf _logger_hook | |
| trap '_logger_hook "$@"' DEBUG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment