Automates hourly command logging for Linux users and optionally backs up logs to a remote server.
Logs typed commands only (not output) with user, timestamp, current directory, TTY/IP, and command details.
- Hourly log files per user
- Logs include: user, timestamp, current directory, TTY/IP, command
- Optional remote backup using
rsync - Automatic log rotation with
logrotate - Minimal performance impact
Linux_Command_Logger/
β
ββ README.md # Project documentation
ββ session_record.sh # Setup and configuration script
ββ /etc/profile.d/command_logging.sh # Script sourced by users' shells
- Make the setup script executable:
sudo chmod +x session_record.sh- Run the setup script:
sudo ./session_record.sh- Source the command logger script manually:
source /etc/profile.d/command_logging.sh- Add it to all new and existing usersβ shells:
echo "source /etc/profile.d/logging.sh" | sudo tee -a /etc/bash.bashrc
π‘ Tip: This ensures all future users automatically log commands when they log in.
- Linux user session monitoring
- Bash scripting for automation
- Log rotation and management (
logrotate) - Remote backup using
rsync - Security-conscious logging
- Store logs in a secure directory with proper permissions.
- Regularly check backup logs to ensure remote sync is working.
- Combine with cron jobs for hourly automation.
- Useful for auditing, training, or lab monitoring.